new mp4 (h.264) derivative technique — simpler and easy!

Greetings video geeks!  8-)

We’ve updated the process and way we create our .mp4 files that are shown on video pages on archive.org

It’s a much cleaner/clearer process, namely:

  • We opted to ditch ffpreset files in favor of command-line argument 100% equivalents.  It seems a bit easier for someone reading the task log of their item, trying to see what we did.
  • We no longer need qt-faststart step and dropped it.  we use the cmd-line modern ffmpeg “-movflags faststart”
  • Entire processing is now done 100% with ffmpeg, in the standard “2-pass” mode
  • As before, this derivative plays in modern html5 video tag compatible browsers, plays in flash plugin within browsers, and works on all iOS devices.   it also makes sure the “moov atom” is at the front of the file, so browsers can playback before downloading the entire file, etc.)
Here is an example (you would tailor especially the “scale=640:480″ depending on source aspect ratio and desired output size;  change or drop altogether the “-r 20″ option (the source was 20 fps, so we make the dest 20 fps);  tailor the bitrate args to taste):
  • ffmpeg -y -i stairs.avi -vcodec libx264 -pix_fmt yuv420p -vf yadif,scale=640:480 -profile:v baseline -x264opts cabac=0:bframes=0:ref=1:weightp=0:level=30:bitrate=700:vbv_maxrate=768:vbv_bufsize=1400 -movflags faststart -ac 2 -b:a 128k -ar 44100 -r 20 -threads 2 -map_metadata -1,g:0,g -pass 1 -map 0:0 -map 0:1 -acodec aac -strict experimental stairs.mp4;
  • ffmpeg -y -i stairs.avi -vcodec libx264 -pix_fmt yuv420p -vf yadif,scale=640:480 -profile:v baseline -x264opts cabac=0:bframes=0:ref=1:weightp=0:level=30:bitrate=700:vbv_maxrate=768:vbv_bufsize=1400 -movflags faststart -ac 2 -b:a 128k -ar 44100 -r 20 -threads 2 -map_metadata -1,g:0,g -pass 2 -map 0:0 -map 0:1 -acodec aac -strict experimental -metadata title='”Stairs where i work” – lame test item, bear with us – http://archive.org/details/stairs’ -metadata year=’2004′ -metadata comment=license:’http://creativecommons.org/licenses/publicdomain/’ stairs.mp4;

Happy hacking and creating!

PS: here is the way we compile ffmpeg (we use ubuntu linux, but works on macosx, too).

This entry was posted in Technical, Television Archive, Video Archive and tagged , , , , , . Bookmark the permalink.

3 Responses to new mp4 (h.264) derivative technique — simpler and easy!

  1. Mocha says:

    Why do you encode audio on the first pass? Also, usually when doing 2 pass you just direct the output of the first pass to /dev/null. Maybe I’m wrong, but I believe you need to revise your method into something more like this:

    $ ffmpeg -y -i INPUT.avi -vcodec libx264 -pix_fmt yuv420p -vf yadif,scale=640:-1 -profile:v baseline -x264opts cabac=0:bframes=0:ref=1:weightp=0:level=30:bitrate=700:vbv_maxrate=768:vbv_bufsize=1400 -movflags faststart -r 20 -threads 0 -map_metadata -1,g:0,g -pass 1 -an -f null /dev/null

    $ ffmpeg -y -i INPUT.avi -vcodec libx264 -pix_fmt yuv420p -vf yadif,scale=640:-1 -profile:v baseline -x264opts cabac=0:bframes=0:ref=1:weightp=0:level=30:bitrate=700:vbv_maxrate=768:vbv_bufsize=1400 -movflags faststart -ac 2 -b:a 128k -ar 44100 -r 20 -threads 0 -map_metadata -1,g:0,g -pass 2 -map 0:0 -map 0:1 -acodec aac -strict experimental -metadata title='Title string' -metadata year='1234' -metadata comment='Comment string' OUTPUT.mp4

  2. traceypooh says:

    That’s right, that is typical. however, encoding the audio in pass 1 is mostly harmless albeit a bit extra CPU (no problem for our fairly massive computing resources).

    The *real reason* we encode audio in pass 1 is especially because some of our TV recordings can have defects/glitches, being MPEG-TS source. sometimes we fail our standard invocation, and falling back to some minor cmd-line arg changes (typically “-vf” removals) works. I found that it was a bit more reliable to keep the audio encoding in pass 1, in case something about it caused issues in pass 2 (that is, I’d rather know about any issues earlier in pass 1! 8-)

    Thanks for the tip — that’s proper to mention it since for most users, that’s the way to go (“-an” during pass 1, etc.). appreciated much! cheers

  3. Pingback: Growing Socials News and Alerts | Google Alert – archive.org

Comments are closed.