Log in

View Full Version : HowTo split/concatenate MP4 files with MP4Box


Pages : 1 [2]

bond
29th April 2007, 18:46
one stream uses cqm and one doesnt.

as i said before you theoretically can merge them by using different ids, but i dont know if this practically possible (would be interesting to test tough)

snappybane
29th April 2007, 20:04
Oh darn. Thanks for the help and clarification.

One last question, is 'pic_scaling_matrix_present_flag' the one you use to determine whether or not there have been used a CQM?

Anyway, I'm up for the test if one can direct me what to do :).

bond
1st May 2007, 12:14
One last question, is 'pic_scaling_matrix_present_flag' the one you use to determine whether or not there have been used a CQM?yes

Anyway, I'm up for the test if one can direct me what to do :). try to get a hexeditor and change the pic_parameter_set_id and seq_parameter_set_id flags to some unique numbers and try to cat the resulting streams again with mp4box

JohnPeterson
13th March 2010, 19:21
when I join them with -cat, I end up with two 'parallel' (when looking in MPC) video tracks

I seem to get a similar problem with these files:

Version

mp4box -version
MP4Box - GPAC version 0.4.6-DEV (build 1)
Compilation Date: Oct 13 2009 - by Kurtnoise
GPAC Copyright: (c) Jean Le Feuvre 2000-2005
(c) ENST 2005-200X
GPAC Configuration: --use-js=no
Features: GPAC_HAS_JPEG GPAC_HAS_PNG

File links

http://www.dailymotion.com/video/x81m3m_heather-locklear-first-appearance-p_fun
http://www.dailymotion.com/video/x81m5m_heather-locklear-first-appearance-p_fun

File info


mp4box -info Part1.mp4
* Movie Info *
Timescale 90000 - Duration 00:14:00.600
Fragmented File no - 2 track(s)
File Brand mp42 - version 0
Created: GMT Sat Jan 17 04:40:22 2009

File has root IOD
Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
Visual PL: ISO Reserved Profile (0x7f)
Audio PL: High Quality Audio Profile @ Level 2 (0x0f)
No streams included in root OD

iTunes Info:
Encoder Software: edge 1.5.4

Track # 1 Info - TrackID 2 - TimeScale 44100 - Duration 00:14:00.539
Media Info: Language "Undetermined" - Type "soun:mp4a" - 36199 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 44100
Self-synchronized

Track # 2 Info - TrackID 1 - TimeScale 90000 - Duration 00:14:00.600
Media Info: Language "Undetermined" - Type "vide:avc1" - 21015 samples
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 512 x 384 - Profile Baseline @ Level 3
NAL Unit length bits: 32
Pixel Aspect Ratio 1:1 - Indicated track size 512 x 384
Synchronized on stream 2

mp4box -info Part2.mp4
* Movie Info *
Timescale 90000 - Duration 00:14:04.233
Fragmented File no - 2 track(s)
File Brand mp42 - version 0
Created: GMT Sat Jan 17 04:53:13 2009

File has root IOD
Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
Visual PL: ISO Reserved Profile (0x7f)
Audio PL: High Quality Audio Profile @ Level 2 (0x0f)
No streams included in root OD

iTunes Info:
Encoder Software: edge 1.5.4

Track # 1 Info - TrackID 2 - TimeScale 44100 - Duration 00:14:04.207
Media Info: Language "Undetermined" - Type "soun:mp4a" - 36357 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 44100
Self-synchronized

Track # 2 Info - TrackID 1 - TimeScale 90000 - Duration 00:14:04.233
Media Info: Language "Undetermined" - Type "vide:avc1" - 25327 samples
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 512 x 384 - Profile Baseline @ Level 3
NAL Unit length bits: 32
Pixel Aspect Ratio 1:1 - Indicated track size 512 x 384
Synchronized on stream 2


Concatenate

mp4box -add Part1.mp4#1:fps=25.000 -add Part1.mp4#2 -add Part2.mp4#1:fps=30.000 -add Part2.mp4#2 -new Joined.mp4

Joined file info

mp4box -info Joined.mp4
* Movie Info *
Timescale 600 - Duration 00:14:04.233
Fragmented File no - 4 track(s)
File Brand isom - version 1
Created: GMT Sat Mar 13 18:16:03 2010

File has root IOD
Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
Visual PL: ISO Reserved Profile (0x7f)
Audio PL: AAC Profile @ Level 2 (0x29)
No streams included in root OD

Track # 1 Info - TrackID 1 - TimeScale 90000 - Duration 00:14:00.600
Media Info: Language "Undetermined" - Type "vide:avc1" - 21015 samples
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 512 x 384 - Profile Baseline @ Level 3
NAL Unit length bits: 32
Pixel Aspect Ratio 1:1 - Indicated track size 512 x 384
Self-synchronized

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

Track # 3 Info - TrackID 3 - TimeScale 90000 - Duration 00:14:04.233
Media Info: Language "Undetermined" - Type "vide:avc1" - 25327 samples
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 512 x 384 - Profile Baseline @ Level 3
NAL Unit length bits: 32
Pixel Aspect Ratio 1:1 - Indicated track size 512 x 384
Synchronized on stream 1

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

Problem

In this particular case when I play it in MPC-HC 1.2.908.0 I get a 14:04 length file (4 seconds more than Part1.mp4) and this error message:

The following pin(s)failed to find a connectable filter:

Joined.mp4::Output 3

Media Type 0:
--------------------------
Video: MPEG4 Video (H264) 512x384 30.00fps

AM_MEDIA_TYPE:
majortype: MEDIATYPE_Video {73646976-0000-0010-8000-00AA00389B71}
subtype: Unknown GUID Name {31637661-0000-0010-8000-00AA00389B71}
formattype: FORMAT_MPEG2_VIDEO {E06D80E3-DB46-11CF-B4D1-00805F6CBBEA}
bFixedSizeSamples: 1
bTemporalCompression: 0
lSampleSize: 1
cbFormat: 165

VIDEOINFOHEADER:
rcSource: (0,0)-(0,0)
rcTarget: (0,0)-(0,0)
dwBitRate: 0
dwBitErrorRate: 0
AvgTimePerFrame: 333346

VIDEOINFOHEADER2:
dwInterlaceFlags: 0x00000000
dwCopyProtectFlags: 0x00000000
dwPictAspectRatioX: 512
dwPictAspectRatioY: 384
dwControlFlags: 0x00000000
dwReserved2: 0x00000000

MPEG2VIDEOINFO:
dwStartTimeCode: 0
cbSequenceHeader: 33
dwProfile: 0x00000042
dwLevel: 0x0000001e
dwFlags: 0x00000004

BITMAPINFOHEADER:
biSize: 40
biWidth: 512
biHeight: 384
biPlanes: 1
biBitCount: 24
biCompression: avc1
biSizeImage: 0
biXPelsPerMeter: 0
biYPelsPerMeter: 0
biClrUsed: 0
biClrImportant: 0

pbFormat:
0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0020: 00 00 00 00 00 00 00 00 22 16 05 00 00 00 00 00 ........".......
0030: 00 00 00 00 00 00 00 00 00 02 00 00 80 01 00 00 ............€...
0040: 00 00 00 00 00 00 00 00 28 00 00 00 00 02 00 00 ........(.......
0050: 80 01 00 00 01 00 18 00 61 76 63 31 00 00 00 00 €.......avc1....
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0070: 00 00 00 00 21 00 00 00 42 00 00 00 1e 00 00 00 ....!...B.......
0080: 04 00 00 00|00 19 67 42 c0 1e 9e 21 01 00 63 60 ......gBÀ.ž!..c`
0090: 22 00 00 03 00 02 00 00 03 00 79 1e 2c 5d 40 00 ".........y.,]@.
00a0: 04 68 ce 3c 80 .hÎ<€


Media Type 1:
--------------------------
Video: MPEG4 Video (H264) 512x384 30.00fps

AM_MEDIA_TYPE:
majortype: MEDIATYPE_Video {73646976-0000-0010-8000-00AA00389B71}
subtype: Unknown GUID Name {31435641-0000-0010-8000-00AA00389B71}
formattype: FORMAT_MPEG2_VIDEO {E06D80E3-DB46-11CF-B4D1-00805F6CBBEA}
bFixedSizeSamples: 1
bTemporalCompression: 0
lSampleSize: 1
cbFormat: 165

VIDEOINFOHEADER:
rcSource: (0,0)-(0,0)
rcTarget: (0,0)-(0,0)
dwBitRate: 0
dwBitErrorRate: 0
AvgTimePerFrame: 333346

VIDEOINFOHEADER2:
dwInterlaceFlags: 0x00000000
dwCopyProtectFlags: 0x00000000
dwPictAspectRatioX: 512
dwPictAspectRatioY: 384
dwControlFlags: 0x00000000
dwReserved2: 0x00000000

MPEG2VIDEOINFO:
dwStartTimeCode: 0
cbSequenceHeader: 33
dwProfile: 0x00000042
dwLevel: 0x0000001e
dwFlags: 0x00000004

BITMAPINFOHEADER:
biSize: 40
biWidth: 512
biHeight: 384
biPlanes: 1
biBitCount: 24
biCompression: AVC1
biSizeImage: 0
biXPelsPerMeter: 0
biYPelsPerMeter: 0
biClrUsed: 0
biClrImportant: 0

pbFormat:
0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0020: 00 00 00 00 00 00 00 00 22 16 05 00 00 00 00 00 ........".......
0030: 00 00 00 00 00 00 00 00 00 02 00 00 80 01 00 00 ............€...
0040: 00 00 00 00 00 00 00 00 28 00 00 00 00 02 00 00 ........(.......
0050: 80 01 00 00 01 00 18 00 41 56 43 31 00 00 00 00 €.......AVC1....
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0070: 00 00 00 00 21 00 00 00 42 00 00 00 1e 00 00 00 ....!...B.......
0080: 04 00 00 00|00 19 67 42 c0 1e 9e 21 01 00 63 60 ......gBÀ.ž!..c`
0090: 22 00 00 03 00 02 00 00 03 00 79 1e 2c 5d 40 00 ".........y.,]@.
00a0: 04 68 ce 3c 80 .hÎ<€


However with other mp4 files I simply get parallel video and audio streams without and decoding errors. But how do I place the streams after each other, instead of parallel to each other?

Solution?


try to get a hexeditor and change the pic_parameter_set_id and seq_parameter_set_id flags to some unique numbers and try to cat the resulting streams again with mp4box

I don't understand that step. How do I cat the parsed raw streams in mp4box, after editing pic_parameter_set_id and seq_parameter_set_id?

UltraTV
28th June 2010, 22:47
I'm having some issues with concatenation using the following command line:

mp4box -add video1.264 -cat video2.264 -cat video3.264 -add audio1.aac -cat audio2.aac -cat audio3.aac -new muxed.mp4 -fps 24

The video and audio files concatenate correctly and in sync, but there are all sorts of motion artifacts and jerky playback after the first section of video. The video files are from the same main source file, split at commercial breaks for other formats, then need to be recombined for mp4's. All the files are encoded using exactly the same parameters in x264.

x264:
--preset veryslow --tune animation --profile main --bitrate 1000 --level 3.1 --keyint 24 --no-mixed-refs --vbv-bufsize 5000 --vbv-maxrate 6000 --thread-input --sar 1:1

Any thoughts would be greatly appreciated.

Update: I found a workaround. Mux each segment of audio and video individually so there are 6 mp4's: 3 video mp4's and 3 audio mp4's. Concatenate the video and audio separately so you're left with 1 video and 1 audio mp4. Mux the remaining two tracks. Our engineers think it's an issue with the start point in the elementary stream starting with the bytes 00 00 01. In any event it would be nice if mp4box could properly handle these types of situations, but I'm happy to have a workaround at least.