Log in

View Full Version : Trouble concatenating mp4 files with mencoder


x2305andy2305x
30th June 2011, 15:22
Hi,

I have a bunch of mp4 x264 encoded files and i would like to concatenate them into a single mp4 file. I've tried the MP4Box solution, but appears to damage the output file. For instance i can't do a qt_faststart on a file produced by MP4Box (that's why i say damage, although the file does play even in a more sensitive MoviePlayer, not only in mplayer)

So then i thought i'd try the mencoder approach:

mencoder -oac copy -ovc copy -idx -o output.mp4 video1.mp4 video2mp4...

MEncoder SVN-r33453-4.5.2 (C) 2000-2011 MPlayer Team

WARNING: OUTPUT FILE FORMAT IS _AVI_. See -of help.
success: format: 0 data: 0x0 - 0x31bf9f
libavformat file format detected.
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (aac), -aid 0, -alang und
VIDEO: [H264] 1280x720 24bpp 25.000 fps 2598.2 kbps (317.2 kbyte/s)
[V] filefmt:44 fourcc:0x34363248 size:1280x720 fps:25.000 ftime:=0.0400
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, s16le, 3.1 kbit/0.22% (ratio: 391->176400)
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
videocodec: framecopy (1280x720 24bpp fourcc=34363248)
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Pos: 10.0s 250f (99%) 0.00fps Trem: 0min 4mb A-V:0.022 [2608:1411]
success: format: 0 data: 0x0 - 0x30b8e4
libavformat file format detected.
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (aac), -aid 0, -alang und
VIDEO: [H264] 1280x720 24bpp 25.000 fps 2544.4 kbps (310.6 kbyte/s)
[V] filefmt:44 fourcc:0x34363248 size:1280x720 fps:25.000 ftime:=0.0400
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, s16le, 3.1 kbit/0.22% (ratio: 391->176400)
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
videocodec: framecopy (1280x720 24bpp fourcc=34363248)
videocodec: framecopy (1280x720 24bpp fourcc=34363248)

All video files must have identical fps, resolution, and codec for -ovc copy.

Exiting...

Hell of a headache because all of the little mp4s are produced with the same ffmpeg mp4 encoding command that ensures they have the same resolution, fps and x264. I even force them to the same pix_fmt so i'm not sure what mencoder is blabbing at here. Do i need to make sure even kb/s is the same? Probably by using CRF?

Can any of you that have successfully done this give me a pointer?

Thanks in advance.

x2305andy2305x
8th July 2011, 12:16
Bumping this a bit. Still haven't been able to make it work.
I've noticed that mencoder does concat two mp4 files with the same bitrate (aside from codec, res and fps) but in my case it's not an option to encode the little mp4s CBR. How come ffmpeg or x264 don't support concatting out of the box?

Selur
9th July 2011, 10:13
x264 is a encoder why should it support concatenating of files?

WARNING: OUTPUT FILE FORMAT IS _AVI_. See -of help.
You did read this, did you? (-> you need to add '-of lavf -lavfopts format=mp4' for mp4 output,...)

Reimar
9th July 2011, 19:52
The SPS and other stuff in the global header need to be the same.
x264 probably writes the bitrate in there.
Hacking the files so they have identical headers, or removing that check in mencoder may or may not work.