Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Compression Techniques FFmpeg 2 pass encoding

  • FFmpeg 2 pass encoding

    Posted by Jack Passmore on October 22, 2010 at 6:30 pm

    Hi All,

    I was hoping for some help. I think I’m doing this correctly, but I’m not sure. Can someone confirm for me that I am indeed doing 2 pass encoding using the following ffmpeg command?

    ffmpeg -i video.avi -pass 1 -ab 320k -acodec libfaac -vcodec libx264 -vpre fast_firstpass -vf “crop=1440:1080:240:0,scale=640:480” -b 2000k -bt 2000k -threads 0 video.mp4

    Thanks!
    John

    Michael Rampe replied 15 years, 6 months ago 2 Members · 3 Replies
  • 3 Replies
  • Michael Rampe

    October 22, 2010 at 9:13 pm

    [Jack Passmore] “ffmpeg -i video.avi -pass 1 -ab 320k -acodec libfaac -vcodec libx264 -vpre fast_firstpass -vf “crop=1440:1080:240:0,scale=640:480″ -b 2000k -bt 2000k -threads 0 video.mp4”

    This is doing the first pass only. For 2 pass libx264 using your example as a base:

    ffmpeg -i video.avi -an -vcodec libx264 -vpre fast_firstpass -b 2000k -bt 2000k -vf “crop=1440:1080:240:0,scale=640:480” -pass 1 -threads 0 /dev/null && ffmpeg -i video.avi -ab 320k -acodec libfaac -vcodec libx264 -vpre normal -b 2000k -bt 2000k -vf “crop=1440:1080:240:0,scale=640:480” -pass 2 -threads 0 video.mp4

    NOTE: this is all one line.

    First pass: ignore audio and write to null as you will not use this video. libx264 generates it’s own log file which will be used in the second pass. Use && to run the second ffmpeg line if the first one is successful. Second pass: write audio and video to output format.

    Michael

  • Jack Passmore

    October 27, 2010 at 5:54 pm

    Great thanks,

    This seems to work except for some of the videos where I get an error message and I’m not sure why. Maybe the first pass is dropping frames or something?

    [libx264 @ 0x10181f400] 2nd pass has more frames than 1st pass (25082)bits/s ts/s
    [libx264 @ 0x10181f400] continuing anyway, at constant QP=28
    [libx264 @ 0x10181f400] disabling adaptive B-frames

  • Michael Rampe

    October 27, 2010 at 11:00 pm

    My mistake. There is a mismatch in the video presets.

    -vpre fast_firstpass should be used with -vpre fast in the second pass instead of -vpre normal as I posted. It also appears that normal is not in the current SVN anymore.

    Most of the libx264 presets are “matched” by a fast first pass preset and they need to be used together to work properly.

    Check inside the ffpresets folder within your FFmpeg install to see the available presets for your build.

    Michael

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy