Youtube Notes

The days of joining Flash Video content losslessly are numbered...

It seems that the vast majority of people wanting to join FLV files have Youtube h264 clips. Unfortunately Youtube seems to encode each part at a different frame rate, frame size (and aspect ratio), and even different audio rate. Joining losslessly only works if each part is identically encoded. Joining raw packets with my program used to work fine, but it looks like there is no longer a use for it with such varied encodes that often require full recoding of audio and video.

I'm not sure what is going on as I don't upload to Youtube (and hardly download much these days), but something is going badly wrong!

You are better off using a program like Avidemux (free) and spending time learning it's various features in Audio/Video manipulation. Sometimes you can get away with just an audio re-encode, other times you need to do a complete A/V re-encode with a fixed frame rate. Avidemux has a joining feature built in called 'Append'. While you're at it, you may as well repackage the file as an MP4 - which is increasingly the new standard. You may need to recode each part first (with some loss of quality) to several identically encoded files, then join/append the files. Other times I've experienced A/V sync issues and resorted to joining the resultant MP4 files with VideoReDo, which is often able to fix sync issues automatically.


An example

Edward Scissorhands - Hollywood Backstories (3 parts).
Part 1  Part 2  Part 3

Part1, 42.2 MB, Time: 9:07, Video: H264 480x360 4:3 ~25fps, Audio: AAC 44100Hz 105 Kbps
Part2, 22.3 MB, Time: 5:39, Video: H264 540x360 3:2 ~25fps, Audio: AAC 44100Hz 57 Kbps
Part3, 29.7 MB, Time: 6:52, Video: H264 540x360 3:2 ~25fps, Audio: AAC 44100Hz 58 Kbps

(It appears that all postings by EviLQuicK, SALLYtheDoll22267, and msradx are the same)

Normal lossless joining fails immediately on playback at the start of part 2. Straight off you can see the frame size and audio rates are different between part 1 and the other two parts. Joining parts 2 and 3 works fine, but part 1 is too different to join to the other parts. The reason the frame size is different on parts 2 and 3 is the aspect ratio is wrong, it looks stretched and should be 4:3 like part 1. Somehow the user's original video and audio got mangled in the process of splitting and uploading to Youtube.

In order to fix it we should change parts 2 and 3 frame size to 480x360 (4:3), and change the audio data rate to 128 Kbps. You can hear sample 1 has a higher fidelity to 2 and 3, so we should upsample these parts rather than downsample the first and lose further detail. I found that part1 also needed to be recoded to match the other 2 parts characteristics. In all cases I chose to set the frame rate to an exact fixed rate of 25 fps to ensure compatibility.

Luckily h264 does a really good job, so even a lossy re-encode will still look pretty good. We can help matters by lowering the contant rate factor (if using one pass encode) from the default of 26 (which is still very good) and experiment to roughly match the original source file size. I chose a rate factor of 20 to get about the same size (or slightly larger) than the source. The final joined MP4 plays quite smoothly over the joins and the aspect ratio is correct throughout for the entire file.