duration wrong in last output file when splitting due to frame without timestamp in source MP4 #1847

Closed
bluelovers opened this Issue Jan 5, 2017 · 7 comments

Projects

None yet

3 participants

@bluelovers

when i split a mp4 by timecode (after timecode, or parts timecodes)

then file with end that one will has duration error on meta info and on windows explorer info too


source file -> 44:02

split timecodes -> 00:20:22-00:44:02 -> file meta will show 00:44:02
or after timecode -> 00:20:22 -> file-002 meta will show 00:44:02 ( file-001 is true duration )

play it on player will show 23:39 on playbar
but meta info still is 00:44:02

@mbunkus
Owner
mbunkus commented Jan 5, 2017

Did you activate the "link files" checkbox?

@mbunkus
Owner
mbunkus commented Jan 5, 2017

OK, then I need access to the source file if you want me to look into it. Please upload it somewhere, e.g. to my FTP server. Thanks.

@mbunkus mbunkus added the app:mkvmerge label Jan 5, 2017
@bluelovers

sftp://upload@ftp.bunkus.org:2222/upload/issues_1847

@mbunkus
Owner
mbunkus commented Jan 6, 2017

Thanks. I'll look into it.

@ndjamena

I don't know if this is related, but I've been cutting the adverts out of my TV recordings. After remuxing the ts files to mkvs I add chapters where the adverts start and end, then use powershell to extract those chapters and use the timecodes to build a command line for MKVMerge using splitparts, append '+'.

The original files were one hour long, the new ones without the ads are 45 minutes, however the tags show each of the tracks to still be 1 hour long. I have to remux the output files to get the correct tags, otherwise MediaInfo gives me weird numbers for my frame rates.

@mbunkus
Owner
mbunkus commented Jan 18, 2017

The underlying cause with the file you've uploaded is a discrepancy between the number of frames for which the MP4 file's track headers contain timestamps and the number of frames written by mkvmerge after putting all the data through its h.264 parser. There's exactly one frame more that's written. As there's no timestamp for that frame available, mkvmerge uses 0, meaning that the very last frame in the very last file produced has a timestamp of 0.

mkvmerge calculates a file's duration as the difference between the maximum timestamp+duration for all frames and the minimum of the timestamps of all frames in a file. As the last file contains both the frame with 44:02 (or whatever it is) and that mis-timestamped frame with timestamp 0, the duration will be 44:02.

The bug is that mkvmerge doesn't derive a new timestamp for that extra frame. I'll fix that.

@mbunkus mbunkus changed the title from mkvmerge file meta error to duration wrong in last output file when splitting due to frame without timestamp in source MP4 Jan 18, 2017
@mbunkus mbunkus closed this in 945da6c Jan 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment