====== Video Conversion ======
* [[faac]]
* [[Handbrake]]
* [[libav]]
* [[mp4box]]
* [[x264]]
==== Creating a Streamable MP4 ====
== Convert to Y4M ==
* 16x9
* 480p
First, take the original source and extract the video to a YUV4MPEG container. At the same time, choose the new aspect ratio and video size.
ffmpeg -i source.mp4 -s hd480 -aspect 16:9 source.y4m
== x264 Y4M ==
Next, use x264 to reencode the video. By default, x264 uses the medium preset. Use a constant bitrate for encoding the video, so that the stream is a smooth experience, and the software can accurately predict the download to delivery ratio.
* medium preset (default)
* high profile h264
* two-pass encoding
* constant bit rate
x264 --preset medium --profile high --pass 1 --bitrate 1000 --vbv-bufsize 2000 -o video.264 source.y4m
x264 --preset medium --profile high --pass 2 --bitrate 1000 --vbv-bufsize 2000 -o video.264 source.y4m
When you're happy with the outcome, you can come back and re-encode the video at a higher quality rate.
x264 --preset placebo --profile high --pass 1 --bitrate 1000 --vbv-bufsize 2000 -o video.264 source.y4m
x264 --preset placebo --profile high --pass 2 --bitrate 1000 --vbv-bufsize 2000 -o video.264 source.y4m
== AAC audio re-encode ==
Next, source the original audio to WAV so that we can re-encode it at the target bit rate, which is also fixed. This also discards any container issues that the original may have had.
* Source to WAV
* WAV to AAC
ffmpeg -i source.mp4 audio.wav
ffmpeg -i audio.wav -b 96k audio.m4a
== MP4 Muxing (MP4box) ==
Next, use MP4Box to join the audio and video together, as well as specify the exact framerate, and setting the interframe rate to a smaller value than normal to also aid streaming.
mp4box -add video.264 -add audio.m4a -fps 25 -inter 500 mp4box.mp4
== qt-faststart ==
Finally, move all the metadata about the MP4 to the front of the file, so that clients can know about the souce material.
qt-faststart mp4box.mp4 qt.mp4