Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concatenating two mp4 files with different audio/video track numbering? #473

Closed
2 of 3 tasks
nick-s-b opened this issue Apr 4, 2016 · 4 comments
Closed
2 of 3 tasks

Comments

@nick-s-b
Copy link

nick-s-b commented Apr 4, 2016

Thanks for reporting your issue. Please make sure these boxes are checked before submitting your issue - thank you!

Detailed guidelines: http://gpac.io/2013/07/16/how-to-file-a-bug-properly/

Hi all!

I have two files that I grabbed off YT using the youtube-dl and I'm trying to join them. I've tried the following:

mp4box -cat file1.mp4 -cat file2.mp4 out.mp4

but that produced a file that played properly for the duration of file1.mp4 only and the screen was black for the second part.

I believe the issue is that Track #1 of file1.mp4 is video and track #2 is audio. However. for the file2.mp4, track #1 is audio and track #2 is video. I believe that mp4box is therefore not joining them properly.

Is it possible to merge them properly by somehow telling the mp4box which streams should go together?

Here's the info about files:

$ mp4box -info file1.mp4
* Movie Info *
    Timescale 600 - Duration 00:14:05.786
    2 track(s)
    Fragmented File: no
    File suitable for progressive download (moov before mdat)
    File Brand mp42 - version 0
    Created: GMT Wed Feb 26 13:36:35 2014
    Modified: GMT Wed Feb 26 13:36: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

iTunes Info:

Track # 1 Info - TrackID 1 - TimeScale 30000 - Media Duration 00:14:05.778
Track has 1 edit lists: track duration is 00:14:05.778
Media Info: Language "Undetermined" - Type "vide:avc1" - 25348 samples
Visual Track layout: x=0 y=0 width=320 height=240
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 320 x 240
    AVC Info: 1 SPS - 1 PPS - Profile Baseline @ Level 1.3
    NAL Unit length bits: 32
    Pixel Aspect Ratio 1:1 - Indicated track size 320 x 240
Self-synchronized

Track # 2 Info - TrackID 2 - TimeScale 44100 - Media Duration 00:14:05.786
Media Info: Language "Undetermined" - Type "soun:mp4a" - 36425 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio AAC LC - 3 Channel(s) - SampleRate 44100
Synchronized on stream 1
$ mp4box -info file2.mp4
* Movie Info *
    Timescale 600 - Duration 00:13:24.640
    2 track(s)
    Fragmented File: no
    File suitable for progressive download (moov before mdat)
    File Brand mp42 - version 0
    Created: GMT Sat Sep 11 08:34:20 2010
    Modified: GMT Sat Sep 11 08:34:20 2010

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

iTunes Info:

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

Track # 2 Info - TrackID 2 - TimeScale 25000 - Media Duration 00:13:24.640
Media Info: Language "Undetermined" - Type "vide:avc1" - 20116 samples
Visual Track layout: x=0 y=0 width=480 height=360
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 480 x 360
    AVC Info: 1 SPS - 1 PPS - Profile Baseline @ Level 2.1
    NAL Unit length bits: 16
    Pixel Aspect Ratio 1:1 - Indicated track size 480 x 360
Synchronized on stream 1
@combucha
Copy link

combucha commented Apr 6, 2016

Width x Height of both videos must be the same. There are also further coefficients for succesful joining, but for now try download and join files with the same resolution.

@rbouqueau
Copy link
Member

Any news?

@combucha
Copy link

I bet nick-s-b will end with black screen avc3 files.
Joined files have different timescales, so even if encoded with the same YT codec params, they will have different SPS. Which player support avc3 mode? MPC-xx, VLC fails playing them (only audio correct).

@nick-s-b
Copy link
Author

It appears that the error is due to different screen resolutions of two of the videos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants