0

So I was trying to get a hang of ffmpeg but I am not very good at it. I am trying to get all .mkv files converted to .m4v with a H264 codec. From another project I know that the h264_cuvid decoder worked perfectly well for my needs. I also checked via ffmpeg -decoders that I wrote it correctly. So the windows-batchfile (I frankenstein-ed together from other forums) looks like this:

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'

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). So I am trying to find a solution to throw my whole library into a folder and convert it to a usable format.

2 Answers2

0

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. In order to use h264_cuvid, you need an NVIDIA GPU with the HW codec. See https://developer.nvidia.com/nvidia-video-codec-sdk/download for more informations.

sgiraz
  • 141
  • 2
  • 11
0

Just re-mux if you can

Do the .mkv files already contain H.264 or another format supported by .m4v? If yes, then you can just stream copy (re-mux) the video with -c:v copy and not have to re-encode:

for %%a in ("*.mkv") do ffmpeg -i "%%a" -c:v copy "newfiles\%%~na.m4v"
pause

h264_cuvid is a decoder

It is not an encoder, and Raspberry does not support CUVID anyway. See FFmpeg Wiki: Hardware.


If you must encode

Use libx264

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.

Or h264_omx for hardware accelerated encoding

If your Raspberry and ffmpeg supports OpenMax you can use h264_omx:

for %%a in ("*.mkv") do ffmpeg -i "%%a" -c:v h264_omx "newfiles\%%~na.m4v"
pause
  • You need your ffmpeg to be compiled with --enable-omx --enable-omx-rpi to use this.
  • It is a simple and limited encoder compared to libx264 so results will not be as good.
  • See FFmpeg hardware acceleration on Raspberry PI.

h264_mmal for hardware accelerated decoding

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:

for %%a in ("*.mkv") do ffmpeg -c:v h264_mmal -i "%%a" -c:v h264_omx "newfiles\%%~na.m4v"
pause
llogan
  • 121,796
  • 28
  • 232
  • 243