This is probably the most newbie question of the century, but here goes.
I'm trying to extract files out of a MKV container and not having much luck. I have previously used gMKVExtractGUI with no issues, but now I've suddenly got two files it just won't work well with.
One MKV contains MPEG2 video and AC3 audio and the other one MPEG4 video and AAC audio. The videos seem to extract without issues, but the audio results in files which won't play in sync with the video. The extracted audio and video are not even of the same length and they contain the word DELAY in the extracted filenames.
So basically I would like to know how do I extract from a MKV container which result in files which play in sync and have the same length?? Preferrably with some type of software that is free and (if possible) does not re-encode or lower the quality of the extracted video / audio.
+ Reply to Thread
Results 1 to 21 of 21
-
-
Try clever FFmpeg-GUI, then you will have more information about the individual stream durations and any delays.
You can also use it to extract, re-encode and mux all or individual streams.
[Attachment 77914 - Click to enlarge]
[Attachment 77915 - Click to enlarge]
What do you want to do with the extracted streams?
Do you want to replace the audio/video tracks?
If so, you also need to consider the frame rates of the videos.
Tell us exactly what you want to do. -
Thanks for replying. I tried it, but it ends up the same way in that software too.
For example this one file I have, it's 23 minutes and 12 seconds long. After I extract the streams in clever FFmpeg-GUI, I end up with an *.aac audio file that is only 23 minutes and 9 seconds long.
When I open the file in clever FFmpeg-GUI, it doesn't display any delays or as much information as the file in your example (see my attached image).
[Attachment 77927 - Click to enlarge]
What I'm trying to do is use the extracted audio when editing a different video in another video editing software, but the audio needs to be the exact same length as the original. -
I think, the audio IS 23 min, 9 sec long.
In the start window from clever Ffmpeg-GUI, after loading this video, is there shown any audio delay?Last edited by ProWo; 26th Mar 2024 at 01:55. Reason: typo
-
What I'm missing in your initial post is what your target is. I have a hunch that you want to mux audio from file A with video from file B.
If so, there are a few things to consider.
1 Check if both videos "main part" are the same in terms of having exactly identical frame-sequences.
2 Be sure the videos run at the same speed. Differences in video framerates will make audio A run out of sync with video B. Where it is important to note that 23.976 video's runtime is identical to it's 29.97 telecined counterpart.
3 Check if the videos start with exactly the same frame.
Short version: if these indeed are all the case, you can simply import both files in MKVToolNix GUI and select "audio A" and "video B" for muxing. All in-source-files' delays will be taken into account and you can directly hit the "mux" button. End-result will be in sync.
A few additional words about the three criteria.
1 This is the first thing to check. Obviously, when dealing with videos not consisting of exact same frame sequences (scenes), A/V cross-muxing will lead to a ridiculous result.
2 When two sources do not run at same pace, first a speed-conversion is necessary. This can be done either for audio or video. Stretching/shrinking audio involves recoding it. Video's runtime can often be altered without re-encoding by changing/rewriting framerate's timestamps.
3 Often, same "main movie parts" don't start at the same framenumber because of differing intros and/or having more or less "black" at the beginning. Setting an (extra) audio-delay value in MTX will deal with this. Note that this value can be positive or negative, depending on what's needed.
I wouldn't care to much if audio and video don't have same running times. More than often I muxed different A/V runtimes (within sane boundaries) and never encountered a playback issue on both pc and HW mediaplayers.
Though I can imagine RAM buffering issues with large delay values. Where - instead of setting such large delay value - adding silence at the start of the stream can avoid such issues. This way has some some potential drawbacks, but it also carries a possible playback benefit: your used audio-device will be provided with more silenced time to "lock-in" on the audio-signal. Some AVRs just need a sec or two with certain audio-codecs before sound can be heard.Last edited by Ennio; 26th Mar 2024 at 06:57.
-
Well, the video is 23 mins and 12 secs so the audio should be the same. Also, the extracted 23 mins and 9 secs file cuts off at the end before the song that is playing has a chance to stop so it's definitely not complete.
I can't see anything about an audio delay within FFmpeg. Is this the correct screen (the start windows)?
[Attachment 77931 - Click to enlarge] -
-
Could you upload this video and post the link here?
I'ld investigate on this strange case. -
I tried step 1 and ended up with the same as I did in FFmpeg, a file that is 23:09 in length. The funny thing is that when I play the file in for example Media Player Classic, it plays until 23:09 and stops, but the audio keeps on playing to the end. Basically the file reaches 23:09 and stops, but I do hear the last 3 seconds coming out of my speaker. But when I open the file in my editing program, it just cuts off at 23:09 and I don't hear the last 3 seconds of the middle of the song.
Unfortunately I couldn't do step 2 and 3, I am not that familiar with mkvtoolnix and how to adjust the streams. I probably will just end up converting the whole MKV file to MPG or something and extract the audio that way. I was hoping to get it without having to re-encode it, but this just seems like too much work. -
After adding the video to your editor, add 3 seconds at the end. Then import the 3 second longer audio.
Another possible option would be to open the audio first, then import the video. -
I think I figured a solution that will work for me. Thanks everyone who has been helping me!
PS: jagabo, I sent you a private message a couple of weeks ago asking for help on an audio file, did you get my message? I decided to write directly to you because you helped me with a similar audio file problem in the past and the results were so good. Whenever you have some time, take a look in your inbox. -
Have you tried loading your video into mkvtoolnix, unchecking all entries except the audio you want, then saving it? It will give you an MKA file that you might be able to process elsewhere. Just a thought.
-
I use MKVCleaver to extract any elements within a MKV file. Video, Audio, Subtitles, Chapters etc works well for me.
SONY 75" Full array 200Hz LED TV, Yamaha A1070 amp, Zidoo UHD3000, BeyonWiz PVR V2 (Enigma2 clone), Chromecast, Windows 11 Professional, QNAP NAS TS851 -
I suggest you explain what you did for the benefit of someone who might have a similar problem in the future.
Sorry. I'm not around much these days so I forgot to address your PM. I suggest you post a sample in the forums here. I'm not real familiar with ffmpeg's aexciter filter so I can't answer off the top of my head. I seem to recall that I used a spectrum analyzer to see where frequencies were dropping, set aexciter to boost frequencies above that, and finally fine tuned all the settings until I got something that sounded good. -
Sure, but nobody will probably like to use my solution as I ended up going a lossy route; I just converted the whole file to MPEG2 and after that I could extract the audio. The destination project that the audio was going to be used with was an MPEG2 file anyway. I just had to get this done kinda quick and it seemed too complicated for me to get it working in ffmpeg.
No worries, that is what I did and I did get some help. -
I'm a bit late to this thread, but for future reference.......
It's possible for the video stream in an MKV to have a delay. You can check it with gMKVExtractGUI.
gMKVExtractGUI writes the audio delay to the file name of the extracted audio, but it's always the delay relative to the video, not necessarily the absolute delay. The idea being that often the video is re-encoded so any video delay would be lost. If there is a video delay and you're keeping the video, the delay written to the extracted audio will be incorrect, unless.....
I generally check MKVs for a video delay and if there is one, I remux the MKV while applying the necessary delay so the video no longer has one, and I also apply the same delay to the audio and subtitles etc so the A/V sync doesn't change. For example, if the video stream has a 46ms delay, I'd apply a -46ms delay to every stream and remux.
Here's an example of a MKV with a video delay of 50ms. The audio has a delay of 71ms so the audio delay relative to the video is 21ms (that's what gMKVExtract would write to the extracted audio's name).
[Attachment 78168 - Click to enlarge]
After applying a -50ms delay to each stream and remuxing.
[Attachment 78169 - Click to enlarge]
If there's still A/V sync problems it'd pay to try extracting the audio with eac3to rather than gMKVExtractGUI, as eac3to will fill any gaps in the audio stream with silence when it extracts. Every other tool I know of just extracts without accounting for any gaps in the stream, should there be gaps.
Eac3to will also remove any audio delay by adding silence to the beginning of the extracted audio.
There's a few GUI's for eac3to but I generally use MeGUI's HD Streams Extractor as it extracts with eac3to.Last edited by hello_hello; 6th Apr 2024 at 11:53.
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
SONY 75" Full array 200Hz LED TV, Yamaha A1070 amp, Zidoo UHD3000, BeyonWiz PVR V2 (Enigma2 clone), Chromecast, Windows 11 Professional, QNAP NAS TS851
Similar Threads
-
Joining several AVI files with progressive audio delay + converting to MKV
By motorola8800 in forum Video ConversionReplies: 3Last Post: 24th Aug 2021, 20:57 -
How to extract video/audio/script from MKV to later use in Premiere?
By afjka in forum Newbie / General discussionsReplies: 2Last Post: 10th Oct 2020, 16:11 -
Extract DVD audio no delay
By escarlate in forum Authoring (DVD)Replies: 11Last Post: 7th Sep 2019, 01:31 -
How to extract audio track of .avi file to include it in a .mkv file?
By nickiman in forum Newbie / General discussionsReplies: 3Last Post: 22nd Jul 2019, 06:15 -
how to extract lossless audio from an MKV file - ffmpeg fails
By batemanj in forum Newbie / General discussionsReplies: 2Last Post: 17th Apr 2019, 07:50