1

I have 2 mp4 videos that fail to concatenate when using:

MP4Box -add 1.mp4 -cat 2.mp4 out.mp4

Is there a way to re-encode 2.mp4 so that the concat call will create a valid output? Possibly with ffmpeg? I can only re-encode one file and I want the concatenation to not do any encoding.

The error I currently get with these 2 files is:

[iso file] Box "minf" has 56 extra bytes Error appending 2.mp4: IsoMedia File is truncated

Scrooch
  • 11
  • 2
  • If you're comfortable using the .MKV file container format, see [my answer here](http://superuser.com/questions/43588/how-can-i-merge-two-mp4-files-without-losing-quality/43736#43736). – Breakthrough May 04 '12 at 19:41
  • thanks for the suggestion, i am stuck with the 1.mp4 though, thats coming from ios devices. i create 2.mp4 so if i get the file format right ahead of time everything should work without reencoding at concat time. – Scrooch May 04 '12 at 20:13
  • you might want to try using [avidemux](http://fixounet.free.fr/avidemux/) instead of MP4box than. Both programs work, but I've had a lot of success with avidemux. – Breakthrough May 04 '12 at 20:17

1 Answers1

0

You can try doing this with ffmpeg:

mkfifo temp0 temp1
ffmpeg -i input0.mp4 -c copy -bsf h264_mp4toannexb -f mpegts -y temp0 2> /dev/null & \
ffmpeg -i input1.mp4 -c copy -bsf h264_mp4toannexb -f mpegts -y temp1 2> /dev/null & \
ffmpeg -f mpegts -i "concat:temp0|temp1" -c copy -absf aac_adtstoasc output.mp4

This doesn't re-encode anything, it places them in a new transport stream container, which makes them more easy to concatenate, and then concatenates them back into an MP4. If output.mp4 already exists, the command will fail. The version above uses named pipes, it you're on a system that doesn't support those you'd have to use intermediate files:

ffmpeg -i input0.mp4 -c copy -bsf h264_mp4toannexb temp0.ts
ffmpeg -i input1.mp4 -c copy -bsf h264_mp4toannexb temp1.ts
ffmpeg -i "concat:temp0.ts|temp1.ts" -c copy -absf aac_adtstoasc output.mp4
evilsoup
  • 13,097
  • 3
  • 59
  • 80
  • That might be crazy enough to work, I'll give it a try when I get back from vacation. Thanks for the suggestion. Sorry I can't up vote, but I don't want to select it as the right answer until I try it. – Scrooch Dec 21 '12 at 17:29