Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > New and alternative a/v containers
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 6th January 2016, 22:55   #1  |  Link
nopper
Registered User
 
Join Date: Jan 2008
Posts: 4
Concatenation Conundrum - Apple Media Handler mp4

My attempt to concatenate some web clips (mp4 format, Apple Media Handler) appears to be initially successful - whether using ffmpeg, mkvmerge, or other tools.

The clips do concatenate and the a/v is in sync.

However, if the raw elementary h.264/aac streams are demuxed (for example, with mp4box) from the concatenated file - and then remuxed, the a/v sync is lost in the newly remuxed file (after the first concatenation point, and more noticeably after the third concatenation point).

My question is why is the a/v sync lost through a demux/remux step?

I suppose that I could just not demux/remux, but one of my device players deals better with a mp4box muxed mp4.
nopper is offline   Reply With Quote
Old 6th January 2016, 23:02   #2  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
The sync can be lost because:
- different fps not accounted for
- video and audio of a given clip are of different lenths. E.g. video is 60 seconds, audio is 59 seconds. If you try to demux and append the single streams you will create a 1 second desync.
sneaker_ger is offline   Reply With Quote
Old 8th January 2016, 03:37   #3  |  Link
nopper
Registered User
 
Join Date: Jan 2008
Posts: 4
Quote:
Originally Posted by sneaker_ger View Post
- video and audio of a given clip are of different lenths. E.g. video is 60 seconds, audio is 59 seconds. If you try to demux and append the single streams you will create a 1 second desync.
You nailed it. In one segment, the video duration is 00:08:13.727 while the audio duration is 00:08:13.692. All of the other segments have similar disparities.

So, what keeps the initial concatenation in sync? Only if I demux the initial concatenation and then remux the raw streams is the sync lost. What is lost in that process that is present in the initial concatenation?

I notice that if I use ffmpeg (with the initial concatenated file as the input) to transcode only the video but stream copy the audio, then the raw streams can be remuxed with full sync.

Is there another way around this issue without transcoding?
nopper is offline   Reply With Quote
Old 8th January 2016, 17:52   #4  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by nopper View Post
So, what keeps the initial concatenation in sync? Only if I demux the initial concatenation and then remux the raw streams is the sync lost. What is lost in that process that is present in the initial concatenation?
Mkv and mp4 have ways to account for irregularities like variable framerate and audio gaps in the streams. If you demux vital sync information can get lost.

Quote:
Originally Posted by nopper View Post
Is there another way around this issue without transcoding?
I don't understand. You already know how:
Quote:
Originally Posted by nopper View Post
My attempt to concatenate some web clips (mp4 format, Apple Media Handler) appears to be initially successful - whether using ffmpeg, mkvmerge, or other tools.
sneaker_ger is offline   Reply With Quote
Old 11th January 2016, 14:21   #5  |  Link
foxyshadis
Angel of Night
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
You have to extract the timecodes and remux with them. (Shifting and concatenating all the timecodes to match your merged tracks, of course.) Unfortunately, while this is relatively straightforward for video, it's not something anyone's made for audio -- and whichever track is shorter needs the timestamps.

Can you just concatenate with ffmpeg, then remux that with mp4box? Seems like that would be enough.
foxyshadis is offline   Reply With Quote
Reply

Tags
concatenation


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 16:54.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.