Converting YouTube flv to mp4

Note: The following was originally posted on twitter because I play around with video files a lot and I thought I’d answer some questions that people sometimes ask me.

Some of you might wonder about what I do when I say I losslessly remux FLV files from YouTube to mp4. Here’s an overview:

If you’re slightly familiar with YouTube formats, you’ll realise that YouTube uploads files in a combination of FLV and MP4. All HD formats (720p and above) are mp4s; all non-HD formats are in FLV/3GP (with the exception of 360p which comes in both mp4 and flv).

FLV and mp4s are essentially container formats (i.e. they contain video/audio streams that are encoded using certain codes).

For YouTube, all videos, no matter whether they are FLV or mp4, contain H264 MPEG-4 AVC video streams; audio are AAC streams.

So technically, all YouTube videos can be converted from FLV format to mp4 format without loss in quality.

When I remux FLV videos to mp4, I don’t actually put them through a video encoder such as Handbrake to convert; because not only does this result in the video losing quality; the sound is also impacted. What I do is that I actually use a freeware software called FLVExtract to extract the streams and “mux” them back into mp4 format using a software that is able to package the streams as an mp4. A freeware software such as YAMB/MeGUI will allow you to do this. When repackaging the streams, one thing you have to be careful is selecting the right frame rate. If the wrong frame rate is used, the video/audio can go completely out of sync. Standard frame rates are 15, 23.97, 25 (PAL) and 29.97; however, YouTube FLVs can come at strange frame rates such as 29.917. FLVExtract tells you what frame rate you should use.

For me because I handle a lot of FLV files at a go, I’ve actually written a command batch file that allows me convert many FLV files to mp4 all at once. But for most of you who wanna just convert 1 file, FLVExtract and YAMB/MeGUI should suffice.

Subjects: Technology 技術

Mood: Random

Tags: video conversion, YouTube