1

I have an online class that provides MP4 versions of class lectures, but the lectures are broken into chunks that are each a few minutes long. I'm trying to concatenate the chunks into whole lectures, and several online discussions recommend MP4Box on Ubuntu. I use the following command:

$ MP4Box -cat chunk1.mp4 -cat chunk2.mp4 -new lecture.mp4

I've also tried

$ MP4Box -add chunk1.mp4 -cat chunk2.mp4 lecture.mp4

Both videos play fine on their own. The problem is that when I concatenate the videos, I receive the following warning:

WARNING: Concatenating track ID 1 with different PPS - result file might be broken

The resulting video, played using VLC media player, is inconsistent. For example, if I concatenate only chunks 1 & 2, the audio for both tracks is fine, but the video of chunk 1 is just a gray screen. Once it gets to what used to be chunk 2, everything works great.

I ran MP4Box -info on each chunk, and despite the warning, they appear to have the same PPS. In fact, everything about their configuration appears identical. Those results are included below.

On Windows I used a one-click GUI tool (Any Video Converter Free) for this, and I didn't ever have to mess with the configuration settings. So I'm a total noob to merging video on Linux. Not sure what else to look for or try. All the discussion I can find on troubleshooting concatenation is related to SPS errors, which I'm not seeing.

$ MP4Box -info chunk1.mp4

* Movie Info *
    Timescale 600 - Duration 00:00:55.100
    2 track(s)
    Fragmented File: no
    File suitable for progressive download (moov before mdat)
    File Brand isom - version 1
    Created: GMT Tue Dec 30 16:59:35 2014

File has root IOD (9 bytes)
Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
Visual PL: AVC/H264 Profile (0x15)
Audio PL: AAC Profile @ Level 2 (0x29)
No streams included in root OD

Track # 1 Info - TrackID 1 - TimeScale 30000 - Media Duration 00:00:55.055
Media Info: Language "Undetermined" - Type "vide:avc1" - 1650 samples
Visual Track layout: x=0 y=0 width=852 height=480
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 852 x 480
    AVC Info: 1 SPS - 1 PPS - Profile Main @ Level 3.1
    NAL Unit length bits: 32
    Pixel Aspect Ratio 1:1 - Indicated track size 852 x 480
Self-synchronized

Track # 2 Info - TrackID 2 - TimeScale 44100 - Media Duration 00:00:55.100
Media Info: Language "Undetermined" - Type "soun:mp4a" - 2373 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 44100
Synchronized on stream 1

And for the second file:

$ MP4Box -info chunk2.mp4

* Movie Info *
    Timescale 600 - Duration 00:04:11.981
    2 track(s)
    Fragmented File: no
    File suitable for progressive download (moov before mdat)
    File Brand isom - version 1
    Created: GMT Wed Nov 19 15:19:33 2014

File has root IOD (9 bytes)
Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
Visual PL: AVC/H264 Profile (0x15)
Audio PL: AAC Profile @ Level 2 (0x29)
No streams included in root OD

Track # 1 Info - TrackID 1 - TimeScale 30000 - Media Duration 00:04:11.951
Media Info: Language "Undetermined" - Type "vide:avc1" - 7551 samples
Visual Track layout: x=0 y=0 width=852 height=480
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 852 x 480
    AVC Info: 1 SPS - 1 PPS - Profile Main @ Level 3.1
    NAL Unit length bits: 32
    Pixel Aspect Ratio 1:1 - Indicated track size 852 x 480
Self-synchronized

Track # 2 Info - TrackID 2 - TimeScale 44100 - Media Duration 00:04:11.982
Media Info: Language "Undetermined" - Type "soun:mp4a" - 10852 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 44100
Synchronized on stream 1

1 Answer 1

0

Why

Your online class has purposefully caused you to have these troubles. They will vary (randomize) the type of mpeg4 encoders used from lesson to lesson, vary the video and audio bit rate and change the length of the audio/video so stitching them together causes errors. The problems you are dealing with now are just the tip of the iceburg on the games being played to make what you're trying to do hard. Also the companies that sell video editing hardware often contribute bugs to open source software that can do these sorts of things, so there's that.

Hard way, free

If you're prepared to do battle with that hydra yourself, then first prep every single individual MP4 file to a standard encoding, audio/video bitrate, etc etc. You can use online and free video and audio converters (be careful not to download viruses with this, as content creators often package them with software). You will find one that works for one kind of file, and discover that it only works for most of them, but not all.

Convert each one of the MP4 files to an open video format like x264 so all the files are the same. Then you can use MP4box to convert all of those into one target MP4 file.

I'm a programmer and I've written little hacks that do the job in a one-liner, but every 5 years or so everything changes and you have to go out and do it again. On the plus side, it's a good way to learn about audio and video close to the metal. This is a war between content creators and content consumers. One of the fronts on the war on general purpose computing.

"MP-anything" mp3, mp4, etc etc, is yoke-in-a-box. If you want your videos to be playable in 5 and 10 years from now, convert them away to open source video encodings.

Easy Solution

One solution I know works is purchase "video editing software" for money and they do battle with that hydra for you, then it's a matter of drag and drop your mp4 files, copy and paste.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .