1
I would like to encode a video in H.264 with multi-pass. I tried :
ffmpeg -y -ss 00:00:12.0 -i "c:\vid\example.mkv" -vframes 420 -vcodec libx264 -preset veryslow -refs 8 -b:v 1200k -an -pass 1 -f h264 /dev/null
ffmpeg -y -ss 00:00:12.0 -i "c:\vid\example.mkv" -vframes 420 -vcodec libx264 -preset veryslow -refs 8 -b:v 1200k -acodec copy -pass 2 "c:\vid\encoded.mkv"
but it shows error messages :
/dev/null: No such file or directory
ratecontrol_init: can't open stats file
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Did I do something wrong? I'm not sure how to use multi-pass with FFmpeg by the way, any ideas how to fix the error?
Are you sure you need to use two-passes? Unless you're targeting a specific output file size just use a single pass with
– llogan – 2016-01-29T17:21:47.780-crf
instead. See FFmpeg Wiki: H.264 Video Encoding Guide for more info on that. Why did you add-refs 8
? The preset will handle refs. Lastly, you can change-f h264
to-f matroska
since that's the container format your second command uses.@LordNeckbeard If I specify
-refs 8
, will the preset mess it up? And do you mean crf is better than 2-pass? – Happy Face – 2016-01-29T17:30:22.137Are you trying to output to a certain file size? You didn't explain why you're using 2-pass or why you're adding
-refs
. Adding-refs
should override the refs set by the preset, but I'm unsure why you're setting that in the first place. – llogan – 2016-01-30T01:39:42.057@LordNeckbeard Basically I want to encode a video as lossless as possible without having gigantic file size like using
-qp 0
or-crf 0
. – Happy Face – 2016-01-30T05:38:25.953Then use the highest crf value that still provides an acceptable quality and the slowest preset you have patience for. However, one of the two answers here should be an appropriate solution to the specific error for the question you posted. – llogan – 2016-01-30T07:55:27.847