Log in

View Full Version : how to trim off excessive audio from mkv during muxing?


lansing
2nd December 2013, 07:34
I have a video length of 3:30 and an audio length about 3:30.500, I wanted to mux them into a mkv so that the excessive audio will be cut off when the video ends. I tried to do it with mkvtoolnix, but it didn't have the splitting option to split based on video length. How do I do this?

sekininsha
7th December 2013, 07:34
you can cut those 500 ms with an audio editor

M+AUDIO
7th December 2013, 10:16
Hello,

Also possible with FFmpeg:
ffmpeg.exe -i "inputvideo" -i "inputaudio" -shortest -map 0 -map 1 -c:v copy -c:a copy -y "output.mkv"
pause

"-shortest" switch will cut your output when shorter stream ends. ;-)

edit: it is also possible according to included mkvmerge's doc, especially this part: 2. Splitting after a duration.

sneaker_ger
7th December 2013, 13:51
edit: it is also possible according to included mkvmerge's doc, especially this part: 2. Splitting after a duration.

That doesn't really work reliably if you want to cut remaining audio streams when the video has already ended. Doing it in more than one step works, though. (First only cut audio, then mux with video.)

lansing
9th December 2013, 02:49
Hello,

Also possible with FFmpeg:
ffmpeg.exe -i "inputvideo" -i "inputaudio" -shortest -map 0 -map 1 -c:v copy -c:a copy -y "output.mkv"
pause

"-shortest" switch will cut your output when shorter stream ends. ;-)


I tried the above code, it didn't work. After the video ended, the audio still kept playing.

setarip_old
9th December 2013, 18:29
@lansing

Hi!

If I remember correctly, You can accomplish this using "MKVCleaver"...

M+AUDIO
9th December 2013, 23:18
I tried the above code, it didn't work. After the video ended, the audio still kept playing.

That's odd, Dunno why:confused:
It always works for me. If you like to re encode the audio only, FFmpeg provides an audio filter called "atrim" for you. here is the link (http://ffmpeg.org/ffmpeg-filters.html#atrim).

@ sneaker_ger
Hello,
I didn't tested that before, thanks for the info.