How to append 2 video files

1

Is there any way to append one video file to another ?

I've got a very large file (2GB) to which I'm trying to append some tiny files (~4MB). They all are in the same format.

It's easy to concat several files with ffmpeg for instance, but the whole file is written everytime (i.e. 2GB+4MB are written to the disk everytime when only 4MB are added to the inital file). I'm trying to avoid all this extra disk IO by using a command that would only append the 4MB files. Any idea how to do that?

Maxime

Posted 2013-04-28T20:01:46.827

Reputation: 111

May I ask why you're in this situation? Why would you need to always append small files? – slhck – 2013-04-28T21:22:42.797

I'm doing HLS streaming the other way : I'm trying to rebuild the video file from all the video parts. At the beginning it's okay as the file isn't that large, but after joining 400+ parts the final video file is getting very large and the disk can't keep up compared to how fast the new parts show up. – None – 2013-04-28T21:34:16.683

You MIGHT be able to just cat the small file onto the big one (according to http://ffmpeg-users.933282.n4.nabble.com/Concatenating-mp4s-Quickly-td4658396.html this can work for some file formats). To do this you could cat FILE2.mpg >> FILE1.mpg (which will append the contents of FILE2.mpg onto the end of FILE1.mpg). Please don't try this on live files until you are happy it works.

– davidgo – 2013-04-29T08:47:53.400

You're right, reencoding the files in a format that supports the cat method is probably the best way to go. I'm giving it a try and I'll tell you if it's working. – Maxime – 2013-04-29T09:35:26.120

...if the goal is to avoid extra files (or extra I/O), it seems to me that re-encoding or remuxing everything would be counter-productive. Just use one of ffmpeg's many concatenation options.

– evilsoup – 2013-04-29T10:08:28.063

ffmpeg's concatenation is what I'm trying to avoid. As stated in my question, it unfortunately does rewrite the whole file instead of appending to the already existing file - actually, all the tools I've tried so far (ffmpeg, avidemux, mencoder) always asks for an output file which can't be the same as the input, and it therefore writes the whole file again and again... I'm desperately looking for a real "append" feature, and not a "join" feature. – Maxime – 2013-04-29T10:51:09.897

Hmm... I think mkvmerge or MP4box might have what you're looking for... I don't know them well enough to give an actual answer, but those might be worth looking at. – evilsoup – 2013-04-29T10:53:37.927

This article is worth reading, there's a suggestion to use a fifo file and doing the heavy work off server. DIY http streaming

– X Tian – 2013-11-18T13:39:16.053

No answers