how to combine mp4 parts into one continuous file?

Using applications, configuring, problems
Message
Author
User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

how to combine mp4 parts into one continuous file?

#1 Post by nubc »

I have a movie in 10 parts (mp4 files). I would like to combine the 10 parts into one file. In the past I have accomplished this task in a roundabout way: I burn the 10 parts as a project with Pburn, and then rip the resulting DVD to hard drive. I would like to avoid this approach because it consumes a lot of time, and because I see synchronization errors in the end product. (No, I would rather burn video as data to DVD media, and then let VLC sort out the playback.) I am sure there are several ways to combine many parts into one file. Please suggest how you would do it. Important point: I am interested in making a file, not a DVD.
Last edited by nubc on Thu 06 Feb 2014, 21:16, edited 1 time in total.

User avatar
ally
Posts: 1957
Joined: Sat 19 May 2012, 19:29
Location: lincoln, uk
Contact:

#2 Post by ally »

hey nub

a quick google found this:

http://superuser.com/questions/43588/ho ... ng-quality

there is a command line ffmpeg example....

:)

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#3 Post by nubc »

I wanted to point out another fact. The 10 parts were not generated by simply dividing up the original full file. For each partial file, about 5 seconds at the end of the preceding file are repeated at the beginning of the next file, so that a line of dialog will be repeated each time the video progresses to the next part.

User avatar
ally
Posts: 1957
Joined: Sat 19 May 2012, 19:29
Location: lincoln, uk
Contact:

#4 Post by ally »


User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#5 Post by nubc »

I don't have and never possessed the original complete file. I am not complaining about the 5-second overlap between parts. I still wish to combine the 10 parts into one file, even with slightly overlapping parts.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#6 Post by mikeb »

Hmm I do this using avidemux.
Load the first one and use file--->append for the rest.

As for the overlaps, once the 10 parts are contactecated in the editor you could select and cut the overlaps before exporting the final file.

Since you are only joining just leave as copy video, copy audio and just set theformat to mp4...this will result in no recompression and a fast result. For mp4 choose the safe mode when loading the segments... seems to work ok that way.

mike

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#7 Post by Flash »

Maybe if you put all the mp4 files into one folder and made an .iso file of it, most media players would play all the files in the .iso file without stopping. Multimedia -> Isomaster might be a way to make the .iso file.

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#8 Post by nubc »

Using Avidemux (GTK+) in Precise 5.7.1, I am getting errors at every step. First I get H.264 detected warning with option to select safe mode. When I select safe mode, I get "No audio decoder for this file. Save (A+V) will generate bad AVI. Save audio will work." I append the remaining 9 files, then Save project, and get this message:

Code: Select all

Assert failed :0
 at line 386, file /build/buildd/avidemux-2.5.4/avidemux/ADM_encoder/adm_encConfig.cppADM_backTrack
videoCodecGetMode()
ADM_Composer::saveAsScript(char const*, char const*)
saveCrashProject()
ADM_backTrack
videoCodecGetMode()
ADM_Composer::saveAsScript(char const*, char const*)
A_saveWorkbench(char const*)
FileSel_ReadWrite(void (*)(char const*), int, char const*, char const*)
avidemux2_gtk() [0x8164c59]
GUI_FileSelWrite(char const*, void (*)(char const*))
HandleAction(Action)
guiCallback(_GtkMenuItem*, void*)
g_cclosure_marshal_VOID__VOID
g_closure_invoke

g_signal_emit_valist
g_signal_emit
gtk_widget_activate
gtk_menu_shell_activate_item
I close Avidemux, and restart it, and get asked if I want to save a crash file.

User avatar
GustavoYz
Posts: 883
Joined: Wed 07 Jul 2010, 05:11
Location: .ar

#9 Post by GustavoYz »

I bet you can get better results with ffmpeg, but you can easilly use cat:

Code: Select all

cat part1.mp4 part2.mp4 part3.mp4 part4.mp4 > movie_full.mp4

tempestuous
Posts: 5464
Joined: Fri 10 Jun 2005, 05:12
Location: Australia

#10 Post by tempestuous »

GustavoYz wrote:you can easilly use cat:

Code: Select all

cat part1.mp4 part2.mp4 part3.mp4 part4.mp4 > movie_full.mp4
No, that's completely wrong in this instance.
If the MP4 files (or any other type of media file) were true binary splits - in other words cut down into manageable filesizes with no regard to the actual media content, then yes, that would work.

But as nubc has described it, these MP4 files appear to have been segmented according to their media content. So the only proper way to rejoin them is with an application that will concatenate the files within a standards-compliant MP4 file container.

As ally and mikeb mentioned, avidemux should do the job, but I suspect the particular version of avidemux will need to have been compiled against suitable MP4 libraries in order to understand the correct codec and MP4 multiplexing.
Apparently the version of avidemux in Precise 5.7.1 does not meet this requirement? I don't feel like spending the time to investigate, myself.
ffmpeg, too, should work, but again there may be certain critical dependencies involved.

Some Googling reveals that the utility of choice appears to be MP4Box, from the GPAC Multimedia Opensource Project -
http://gpac.wp.mines-telecom.fr/
You will see that there's source code available for Linux, and a compilation HOWTO here -
http://gpac.wp.mines-telecom.fr/2011/04 ... on-ubuntu/
... but those dependencies look messy, and I'm guessing the compilation may throw up a lot of errors ...

I'm a Linux fan, but as a media professional I use Windows and Mac for my work. I can't be bothered jumping through hoops to make Linux do what my everyday Windows/Mac tools do effortlessly.
So if you're not opposed to using Windows for this task, just go ahead and download MP4Box -
http://www.videohelp.com/tools/mp4box
and MP4Box GUI -
http://www.videohelp.com/tools/My-MP4Box-GUI
Once both are installed, launch the gui, and go to the tab labelled "Join".

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#11 Post by mikeb »

Do these mp4 happen to be from a flash vido site like you tube... if they are from the temp folder the codec info is obfusticated in some way and some players and editors cannot detect the codecs in use and hence the problem. If you use a download mp4 addon or similar this problem does not happen.
Otherwise its a literal error..they have a weird audio codec in use.

I have a build I made of mp4box for linux if you want to try it...just say what puppy format you want it in as i have it as a slax module

mike

User avatar
GustavoYz
Posts: 883
Joined: Wed 07 Jul 2010, 05:11
Location: .ar

#12 Post by GustavoYz »

tempestuous wrote:No, that's completely wrong in this instance.
If the MP4 files (or any other type of media file) were true binary splits - in other words cut down into manageable filesizes with no regard to the actual media content, then yes, that would work.

But as nubc has described it, these MP4 files appear to have been segmented according to their media content. So the only proper way to rejoin them is with an application that will concatenate the files within a standards-compliant MP4 file container.
Best thing to do if so, is just grab any video editor and join it manually.
Nothing pro about my approach: I join some mp4s with cat and then ffmpeg it to something else and it will fix the final file to be a "standards-compliant" mp4 or any other format. That worked for me (somebody with 0 interest in editing video). But yep, all the mp4 I have are simply splits.

Just found this, may help.

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#13 Post by nic007 »

Combining snippets of files won't work if it's porn. LOL, only joking. I've had problems before joining file parts which have different bitrates, etc. Best to convert all to the same bitrate, aspect ratio and then combine.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#14 Post by mikeb »

Perhaps it would help if we had a couple of samples ...would be possible to see if there is a hidden codec problem with them.

The mp4box suggestion is a good one as the purpose of it is to produce 'standard' mp4 results to try and deal with the painful collection of not quite mp4 material out there. In my case I needed it to make some windows produced mp4/h264 work in flash (vfw based sources) which was pretty particular about the format.

mike

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#15 Post by mikeb »

I get "No audio decoder for this file. Save (A+V) will generate bad AVI.
Well first thing that suggests there is no libfaac present...check help->Built in Support and look for FAAC being ticked...if not add it from the ppm.

I did check your samples...they did join and produce a mp4 with no crashes but my crusty old vlc did crash trying to play beyond the first segment...ie the first join. Tried various combinations and the same. (avi, mp3 audio, non safe mode)
I then tried to contacticate with mp4box... it crashed trying to join them...even if I ran the second one through it and then tried to join (using -cat)

The segments play just fine but something does seem amiss ...perhaps they were indeed simply binary split originally.... .

I have done this before so will test out something else to determine where the problem lies..software or movie.

Another idea is to play the folder...like a playlist....

You may add libfaac and all will be well.... so one to test first.
If there is some compatability problem then re-endoing through mencoder, ffmpeg or avidemux might be the way around but its a slow alternative.

mike

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#16 Post by mikeb »

Just as a check I joined 2 random but same dimension mp4's from you tube using avidemux as described and it did so and played without a hitch... I will find a multipart item to test next.

mike

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#17 Post by nubc »

I used MP4Box to join the 10 parts, and things went well. However, playback of the joined file did not do well. The first part played fine, not surprisingly. After the first part completed at 10m30s, the sound dropped out, no sound for the rest of the movie. The video of the film seems okay, transitions are smooth, but there is no sound after the first part. Close, but no cigar.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#18 Post by mikeb »

Yes further tests... just the same...in my case it tended to lose video and crash the lde vlc I was using...but regardless something goes wrong at the joins.

This happens with films chopped into segments...randomly chosen but matching shorts are fine...

Ok 2 posibilities
.1. they are divided up in a crude way that messes up joining.

2. its deliberately done to prevent joining.

I am beginning to think cat plus a ffmpeg join might not be such a bad idea if tools like mp4box fail to work...will play further.

Did you check for libfaac...avidemux is a handy tool for 'normal' files :)

mike

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#19 Post by mikeb »

Ok guess its 1....
cat part1.mp4 part2.mp4 part3.mp4 part4.mp4 > movie_full.mp4
this actually works perfectly...the files must be chopped up with a binary split...flash and other players can handle mp4 done like this and its why normal video methods fail since the subsequent parts lack any headers which video handlers normally need.

Solved with a capital S :)

mike

ps
One funny thing...the ffmpeg method page linked earlier gave a method of which the first two lines was for ffmpeg 5 years ago and the third line for this years version....I love helpful info like this :D ...total time waster...dont geeks check their stuff?

User avatar
nubc
Posts: 2062
Joined: Tue 23 Jan 2007, 18:41
Location: USA

#20 Post by nubc »

cat part1.mp4 part2.mp4 part3.mp4 part4.mp4 > movie_full.mp4
Is this the actual syntax of the command, or simply the sketchy logic of the operation. If not, then at what point do I get to rename the joined file?

Post Reply