Differences
This shows you the differences between two versions of the page.
video_conversion [2013/07/11 17:29] |
video_conversion [2013/07/11 17:29] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== 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. | ||
+ | |||
+ | <code> | ||
+ | avconv -i source.mp4 -s hd480 -aspect 16:9 source.y4m | ||
+ | </code> | ||
+ | |||
+ | == 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 | ||
+ | |||
+ | <code> | ||
+ | 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 | ||
+ | </code> | ||
+ | |||
+ | When you're happy with the outcome, you can come back and re-encode the video at a higher quality rate. | ||
+ | |||
+ | <code> | ||
+ | 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 | ||
+ | </code> | ||
+ | |||
+ | == 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 | ||
+ | |||
+ | <code> | ||
+ | avconv -i source.mp4 audio.wav | ||
+ | avconv -i audio.wav -b 96k audio.m4a | ||
+ | </code> | ||
+ | |||
+ | == 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. | ||
+ | |||
+ | <code> | ||
+ | mp4box -add video.264 -add audio.m4a -fps 25 -inter 500 mp4box.mp4 | ||
+ | </code> | ||
+ | |||
+ | == 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 |