-1

I have a lot home video from my smartphone and from camera. But they take up much space. I want to compress/convert these in x264 files by ffmpeg. I find following config:

ffmpeg -y -i input.mov -c:v libx264 -preset medium -b:v 4500k -pix_fmt yuvj420p -pass 1 -an -f mp4 nul
ffmpeg -y -i input.mov -c:v libx264 -preset medium -b:v 4500k -pix_fmt yuvj420p -pass 2 -c:a aac -b:a 256k -f mp4 out.mp4

Could you, please, help me improve these config to convert files with acceptable quality and small size.

1 Answers1

0

It looks like you're doing a two-pass encode. This is usually only useful if you're concerned with hitting an exact target file size. I think in your case you might not actually need it.

I'd leave off some of those other arguments as well because generally ffmpeg/x264 "do the right thing".

To that end, you could likely get what you need with one pass:

ffmpeg -y -i input.mov -c:v libx264 -tune film -c:a copy output.mp4

The difference to your original command:

  • Rely on some x264 defaults (-preset medium being one of them)
  • -tune film will tell x264 that the source is "live" (as opposed to animation, still, etc)
  • Audio is copied directly (probably low enough already that re-encoding won't gain you a whole lot)

If you still find that the file sizes are too large, you can reduce the quality a little (-crf in the following, default is 23):

ffmpeg -y -i input.mov -c:v libx264 -tune film -crf 24 -c:a copy output.mp4

If you increase the -crf value, it will decrease the file size, but also decrease the output video quality. I'd suggest playing with the -crf value until you find a value that you're happy with.

WIlfinity
  • 905
  • 9
  • 10
  • I'm using those settings on some old home video (MPEG2 digitized Hi8 and Video8 recordings) in yuv420p 720x576, but the resulting files are more than 4000kbits/s - barely less than my 5800kbit/sec input files. That's 300+MB for a 10 minute clip, which seems way off when full-HD TV episodes typically are 4-500MB for 45-60 minutes? I've tried to increase CRF, but I get very visible artifacts. Given the low quality of the input-video, it should be possible to get really quite small output files? – mseebach Dec 28 '15 at 13:39
  • @mseebach Perhaps in your case you need to re-encode the audio also. Can you try the command without `-c:a copy`? – WIlfinity Dec 31 '15 at 18:22