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 21st June 2014, 21:03   #1  |  Link
DragonQ
Registered User
 
Join Date: Mar 2007
Posts: 934
Remux MKV to MP4 with correct timestamps?

I'm trying to use a video editor that doesn't support MKV and it really struggles with TS files too (Sony Vegas Pro). It seems MP4 is the best input format for it, and it works for some files, but I'm not having any joy remuxing some 1080i/25 TV recordings (AVC/AC3 in an MKV) into working MP4s with correct timestamps.

I'm using ffmpeg to remux and have tried a few different things (straight from MKV to MP4, from MKV to TS to MP4, MKV to elementary stream to MP4) but the resulting MP4 just doesn't play properly in MPC-HC, let alone within Vegas Pro (the frames jump around out-of-order). For example, using this input line:

Code:
ffmpeg -i "D:\input.mkv" -vcodec copy -acodec copy "D:\output.mp4"
I get loads of warnings during the remuxing like this:

Code:
Non-monotonous DTS in output stream 0:0; previous: 3119681, current: 3119040; changing to 3119682. This may result in incorrect timestamps in the output file.
Is it even possible to get a working MP4 from an MKV like this? Maybe there's another remuxer I could try or there's some ffmpeg options that will help?


Thanks for any advice.
__________________
TV Setup: LG OLED55B7V; Onkyo TX-NR515; ODroid N2+; CoreElec 9.2.7
DragonQ is offline   Reply With Quote
Old 21st June 2014, 22:01   #2  |  Link
Simon88
Registered User
 
Join Date: Jan 2012
Posts: 91
extract the video stream & audio stream & ttext (if applicable). Also extract timecodes if you notice sync issues (non-standard frame-rates). Then remux using mp4box (latest GPAC version).
Simon88 is offline   Reply With Quote
Old 21st June 2014, 22:07   #3  |  Link
DragonQ
Registered User
 
Join Date: Mar 2007
Posts: 934
How do I extract timecodes? Also, I've tried MP4Box (via YAMB), it also produces a dodgy MP4 file like ffmpeg does.

EDIT: OK I see I can use timecodes_v2 (don't see this option in MKV Extract GUI 2). Are there any GUIs that will let me make an MP4 using the timecode files?

EDIT: Every time I download a Windows binary of MP4Box GPAC I get the error "installer integrity check has failed".
__________________
TV Setup: LG OLED55B7V; Onkyo TX-NR515; ODroid N2+; CoreElec 9.2.7

Last edited by DragonQ; 21st June 2014 at 22:42.
DragonQ is offline   Reply With Quote
Old 21st June 2014, 22:54   #4  |  Link
Simon88
Registered User
 
Join Date: Jan 2012
Posts: 91
I only use the official, latest GPAC mp4box.exe extracted from the installer. They do have a much older stable release. I don't like using GUIs, the command line has so much more options... Maybe gMKVExtractGUI will work... don't know, haven't tried it before...

An easier method may just be using LATEST!!!!! ffmpeg... it is updated daily... and mux it into a MP4 then using the GPAC mp4box and remux it into a "better/fixed" MP4...

The method I presented earlier is rather complex, even I get so confused that I use a custom batch script....
Simon88 is offline   Reply With Quote
Old 21st June 2014, 22:56   #5  |  Link
DragonQ
Registered User
 
Join Date: Mar 2007
Posts: 934
OK well I can't find any information about how to use mp4box to mux using timecodes. Any help?

Simply remuxing the MKV into an MP4 using ffmpeg and then remuxing that MP4 into another MP4 using mp4box doesn't help. Looks like I need the timecodes...
__________________
TV Setup: LG OLED55B7V; Onkyo TX-NR515; ODroid N2+; CoreElec 9.2.7

Last edited by DragonQ; 21st June 2014 at 23:01.
DragonQ is offline   Reply With Quote
Old 21st June 2014, 23:08   #6  |  Link
Simon88
Registered User
 
Join Date: Jan 2012
Posts: 91
latest ffmpeg, when convert from mkv to mp4 is suppose to preserve the timecodes... is the mkv file container broken or too old? you may need to "upgrade" the mkv container on your video file to the latest version, then convert using latest ffmpeg... it's trial and error sometimes, when dealing with uncooperative files
Simon88 is offline   Reply With Quote
Old 21st June 2014, 23:09   #7  |  Link
DragonQ
Registered User
 
Join Date: Mar 2007
Posts: 934
I have the latest ffmpeg (updated yesterday before trying this stuff) and latest MKV Merge. I only made the MKV a few days ago.

ITV HD probably has a dodgy stream though. I know that MediaPortal reports continuity errors constantly when watching ITV HD (not for other channels) even though the video plays fine (50 fps, no dropped frames).
__________________
TV Setup: LG OLED55B7V; Onkyo TX-NR515; ODroid N2+; CoreElec 9.2.7

Last edited by DragonQ; 21st June 2014 at 23:12.
DragonQ is offline   Reply With Quote
Old 21st June 2014, 23:16   #8  |  Link
Simon88
Registered User
 
Join Date: Jan 2012
Posts: 91
I see... then you need something like TS-Doctor to fix the captured transport stream file first, before processing with ffmpeg or mkvtoolnix..
Simon88 is offline   Reply With Quote
Old 21st June 2014, 23:18   #9  |  Link
DragonQ
Registered User
 
Join Date: Mar 2007
Posts: 934
Done that already, I always use TS-Doctor before muxing to MKV.
__________________
TV Setup: LG OLED55B7V; Onkyo TX-NR515; ODroid N2+; CoreElec 9.2.7
DragonQ is offline   Reply With Quote
Old 21st June 2014, 23:19   #10  |  Link
Simon88
Registered User
 
Join Date: Jan 2012
Posts: 91
OK.. then use mp4fpsmod to insert the timecodes back into the MP4 file, after extraction from MKV. Then your all set...
Simon88 is offline   Reply With Quote
Old 21st June 2014, 23:23   #11  |  Link
Simon88
Registered User
 
Join Date: Jan 2012
Posts: 91
The one I listed is just free & a bit buggy, you may wish to search the net for a more easier to use & a bit more polished timecode insertion utility... It was the 1st one I found that was open sourced and cheap...
Simon88 is offline   Reply With Quote
Old 22nd June 2014, 00:29   #12  |  Link
DragonQ
Registered User
 
Join Date: Mar 2007
Posts: 934
OK using mp4fpsmod I can get a working MP4 with correct timestamps, woo! Unfortunately, Vegas Pro won't bloody open it, despite opening some other MP4 files with AVC fine.
__________________
TV Setup: LG OLED55B7V; Onkyo TX-NR515; ODroid N2+; CoreElec 9.2.7
DragonQ is offline   Reply With Quote
Old 22nd June 2014, 01:02   #13  |  Link
Simon88
Registered User
 
Join Date: Jan 2012
Posts: 91
perhaps Vegas Pro does not like the container codec ID used by gpac mp4box, so you just re-mux again using ffmpeg or libav and try using Vegas Pro... and remux back using mp4box if needed... A pain, but may work...
Simon88 is offline   Reply With Quote
Old 22nd June 2014, 01:09   #14  |  Link
DragonQ
Registered User
 
Join Date: Mar 2007
Posts: 934
If I remove the audio before muxing (don't need it anyway), Vegas Pro opens the file. However, in the preview window the timestamps are all messed up again, even though the MP4 plays fine in MPC-HC. It also says it's 125 fps despite clearly playing at 50 fps in the preview window.

Sigh.
__________________
TV Setup: LG OLED55B7V; Onkyo TX-NR515; ODroid N2+; CoreElec 9.2.7
DragonQ is offline   Reply With Quote
Old 22nd June 2014, 01:34   #15  |  Link
Simon88
Registered User
 
Join Date: Jan 2012
Posts: 91
Use "Fix bitstream timing information", I believe Mosu added that option not too long ago...
Simon88 is offline   Reply With Quote
Old 22nd June 2014, 02:45   #16  |  Link
huokok
Registered User
 
Join Date: Feb 2014
Posts: 14
Barely know anything about Sony Vegas, does it accept Avisynth as input?
If you can use mpc-hc to palyback accurately, then there should be a suitable source to open the mkv you made and serve to Sony Vegas.
huokok is offline   Reply With Quote
Old 22nd June 2014, 06:06   #17  |  Link
sef
Registered User
 
Join Date: Nov 2013
Location: Russia
Posts: 61
Hi all.. I solved this issue with Sony Vegas Pro, using AVFS and Pismo File Mount..

Last edited by sef; 22nd June 2014 at 06:52.
sef is offline   Reply With Quote
Old 22nd June 2014, 09:04   #18  |  Link
Ghitulescu
Registered User
 
Ghitulescu's Avatar
 
Join Date: Mar 2009
Location: Germany
Posts: 5,769
I still do not understand the reason of converting MKV to MP4 ...

Vegas Pro accepts individual streams (assets), so a demux should be he only thing you need. Then place them on the timeline (slugs) as needed.

I know no device that records in MKV, but if there is an issue with the MKV, then the problem has to be searched on that device. Again TC/IVTC and NDF/DF are issues not present in raw/captured videos, only in edited ones.
__________________
Born in the USB (not USA)
Ghitulescu is offline   Reply With Quote
Old 22nd June 2014, 09:51   #19  |  Link
DragonQ
Registered User
 
Join Date: Mar 2007
Posts: 934
Quote:
Originally Posted by Simon88 View Post
Use "Fix bitstream timing information", I believe Mosu added that option not too long ago...
I'm confused. How will that help me? I'd still need to demux the "fixed" MKV.

Quote:
Originally Posted by sef View Post
Hi all.. I solved this issue with Sony Vegas Pro, using AVFS and Pismo File Mount..
I guess I'll look into this, thanks.

Quote:
Originally Posted by Ghitulescu View Post
I still do not understand the reason of converting MKV to MP4 ...

Vegas Pro accepts individual streams (assets), so a demux should be he only thing you need. Then place them on the timeline (slugs) as needed.
The timestamps are screwed up when I simply import the H264 stream without a container, just like when using the MP4 file.
__________________
TV Setup: LG OLED55B7V; Onkyo TX-NR515; ODroid N2+; CoreElec 9.2.7
DragonQ is offline   Reply With Quote
Old 22nd June 2014, 14:53   #20  |  Link
Simon88
Registered User
 
Join Date: Jan 2012
Posts: 91
Quote:
Originally Posted by DragonQ View Post
I'm confused. How will that help me? I'd still need to demux the "fixed" MKV.
The problem is you may handling variable bitrate files and if you take a look at the video w/ MediaInfo you will see alot of strange values... However those values will be carried over when you re-mux to MP4.... "Fix bitstream timing information" adjusts such info to match the container...
Simon88 is offline   Reply With Quote
Reply


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 01:30.


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