[英](Folderwide) Bulk conversion in ffmpeg to a H264 codec
So I was trying to get a hang of ffmpeg but I am not very good at it.所以我试图掌握 ffmpeg 但我不太擅长。 I am trying to get all.mkv files converted to.m4v with a H264 codec.
我正在尝试使用 H264 编解码器将所有.mkv 文件转换为.m4v。 From another project I know that the h264_cuvid decoder worked perfectly well for my needs.
从另一个项目中,我知道 h264_cuvid 解码器非常适合我的需求。 I also checked via
ffmpeg -decoders
that I wrote it correctly.我还通过
ffmpeg -decoders
检查了我写的是否正确。 So the windows-batchfile (I frankenstein-ed together from other forums) looks like this:所以 windows-batchfile(我从其他论坛一起 frankenstein-ed)看起来像这样:
for %%a in ("*.mkv") do ffmpeg -i "%%a" -c:v h264_cuvid -preset fast -crf 20 -b:v 128k "newfiles\%%~na.m4v"
pause
What I get is sadly only:可悲的是,我得到的只是:
unknown encoder 'h264_cuvid'
未知编码器“h264_cuvid”
How do I solve this?我该如何解决这个问题?
If it is easier to start from scratch following is what I am trying to achieve如果从头开始更容易,那么我正在努力实现以下目标
I am pretty new to this whole conversion/coding thing.我对整个转换/编码的事情很陌生。 I got a raspberry pi as a homeserver for my video files.
我有一个树莓派作为我的视频文件的家庭服务器。 Sadly it can only direct stream correctly encoded files (H.264), otherwise the Pi is trying to encode the videos itself (what causes buffering).
可悲的是,它只能引导 stream 正确编码文件(H.264),否则 Pi 正在尝试对视频本身进行编码(导致缓冲的原因)。 So I am trying to find a solution to throw my whole library into a folder and convert it to a usable format.
所以我试图找到一种解决方案,将我的整个库放入一个文件夹并将其转换为可用的格式。
I suggest you to use another codec because the h264_cuvid is strictly related to NVIDIA CUDA, and it doesn't run on Raspberri Pi of course.我建议您使用其他编解码器,因为 h264_cuvid 与 NVIDIA CUDA 严格相关,当然它不能在 Raspberri Pi 上运行。 In order to use h264_cuvid, you need an NVIDIA GPU with the HW codec.
为了使用 h264_cuvid,您需要带有硬件编解码器的 NVIDIA GPU。 See https://developer.nvidia.com/nvidia-video-codec-sdk/download for more informations.
有关详细信息,请参阅https://developer.nvidia.com/nvidia-video-codec-sdk/download 。
Do the .mkv
files already contain H.264 or another format supported by .m4v
? .mkv
文件是否已经包含 H.264 或.m4v
支持的其他格式? If yes, then you can just stream copy (re-mux) the video with -c:v copy
and not have to re-encode:如果是,那么您只需stream使用
-c:v copy
(重新复用)视频,而不必重新编码:
for %%a in ("*.mkv") do ffmpeg -i "%%a" -c:v copy "newfiles\%%~na.m4v"
pause
It is not an encoder, and Raspberry does not support CUVID anyway.它不是编码器,树莓派也不支持 CUVID。 See FFmpeg Wiki: Hardware .
请参阅FFmpeg Wiki:硬件。
for %%a in ("*.mkv") do ffmpeg -i "%%a" -c:v libx264 -preset fast -crf 20 -b:v 128k "newfiles\%%~na.m4v"
pause
See FFmpeg Wiki: H.264 for more info.有关更多信息,请参阅FFmpeg Wiki:H.264 。
If your Raspberry and ffmpeg
supports OpenMax you can use h264_omx:如果您的 Raspberry 和
ffmpeg
支持 OpenMax,您可以使用 h264_omx:
for %%a in ("*.mkv") do ffmpeg -i "%%a" -c:v h264_omx "newfiles\%%~na.m4v"
pause
ffmpeg
to be compiled with --enable-omx --enable-omx-rpi
to use this.--enable-omx --enable-omx-rpi
编译ffmpeg
才能使用它。If your ffmpeg
was compiled with --enable-mmal
, and your Raspberry supports Broadcom Multi-Media Abstraction Layer, and your input video formats are either H.264, VC-1, MPEG-2, or MPEG-4, then you can also add hardware decoding:如果您的
ffmpeg
是使用--enable-mmal
编译的,并且您的 Raspberry 支持 Broadcom 多媒体抽象层,并且您的输入视频格式是 H.264、VC-1、MPEG-2 或 MPEG-4,那么您可以还添加硬件解码:
for %%a in ("*.mkv") do ffmpeg -c:v h264_mmal -i "%%a" -c:v h264_omx "newfiles\%%~na.m4v"
pause
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.