View Full Version : Help me to join two mp4 files into one with mp4box, plz
alexVS
3rd December 2015, 15:40
I've got 2 files from the same hockey game from youtube. And I want to join them. Originally the game was divided into 4 big parts (30 min each), and I guess they were encoded with a slightly different parameters.
But they look VERY similar.
https://drive.google.com/folderview?id=0BxXhOUrQZl8XQm93U0VjNmlSVU0&usp=sharing
files: 02.mp4 and 03.mp4
I tried yamb, no success (audio joined, video - only first file)
I tried use command line
"d:\yamb\mp4box.exe" -force-cat -add "d:\02.mp4#1:fps=29.970" -cat "d:\02.mp4#2:lang=en" -cat "d:\03.mp4#1:fps=29.970" -cat "d:\03.mp4#2:lang=en" -new "d:\new2.mp4"
Second part full of green arfifacts.
Help, please!
I uploaded short samples to google drive
sneaker_ger
3rd December 2015, 17:40
One of the files uses weighted prediction and the other one does not. Such a change of encoding parameters is not allowed to happen in mp4 or mkv containers and that's why the video can get messed up if you try to append them losslessly using mp4box.
Possible solutions:
- re-encode one of them to match the encoding parameters of the other one (or if you don't know how to do that:)
- splice them in e.g. AviSynth and re-encode the complete file
- try downloading a different version from YouTube and see if it can be appended (WebM/VP9 in mkvtoolnix?)
(May work for some players but not really recommended:
- make sure all h.264 headers are repeated throughout the stream and then append losslessly.)
Soulvomit
3rd December 2015, 18:33
I was able to losslessly join your samples with none of the playback artifacts, at least not with the latest VLC or QuickTime, but it wasn't easy. But before getting into that, can you post the YouTube links to all the parts? I would like to know whether or not the sources behave the same.
http://sendspace.com/file/ufuomw
alexVS
4th December 2015, 16:16
Four parts of the game on youtube
https://www.youtube.com/watch?v=z0xDQ8apgVA
https://www.youtube.com/watch?v=PJknSsVdEm8
https://www.youtube.com/watch?v=e59mefFUl0I
https://www.youtube.com/watch?v=l-qZ846aOvU
Downloaded with YouTubeDownloaderHD (portable in ZIP) ver. 2.9.9.25 (saved as 480p)
02.mp4 is extraction from first, 03.mp4 is from second.
BTW I managed to join them. 02, 03 and other extractions with the help of batch file I found in the net. Just changed paths, names and it worked.
ffmpeg -y -i "01.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts "source01.ts"
ffmpeg -y -i "02.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts "source02.ts"
ffmpeg -y -i "03.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts "source03.ts"
ffmpeg -y -i "04.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts "source04.ts"
ffmpeg -y -i "05.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts "source05.ts"
ffmpeg -y -i concat:"source01.ts|source02.ts|source03.ts|source04.ts|source05.ts" -absf aac_adtstoasc -c copy -f mov "destination.mp4"
pause
I haven't any idea what ffmpeg does here, and what these parameters means, but looks like it works without reencoding the source.
foxyshadis
5th December 2015, 09:48
The beauty of TS is that you don't need to care how segments were encoded, it doesn't strive for efficiency and just repeats each one's information constantly. MP4 is much stricter, a little unfortunate but it's a bit late to change that. MKV might be able to do it but would need some tweaking. Your solution is probably the simplest solution to keeping them in a single file without re-encoding.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.