Article 5QCW4 ffmpeg - Add audio track to mkv file

ffmpeg - Add audio track to mkv file

by
resuni
from LinuxQuestions.org on (#5QCW4)
I ripped a TV show from BluRay to mkv. There are commentary versions of some episodes, and I thought rather than having a whole separate video file for commentary, I would move the audio track from the commentary version of the video to the normal version to save space. The final step of adding the audio track to the mkv file seems to be where I'm having problems.

I first extract the audio from the commentary version of the episode:

Code:ffmpeg -i input_file.mkv -map 0:1 -map_metadata 0 -c copy output_file.ac3If I use mpv to play output_file.ac3, the file does play. I do hear audio. I add it to the normal version of the episode:

Code:ffmpeg -i input_file.mkv -i extracted_audio.ac3 -map 0 -map 1 -codec copy -map_metadata:s:a 0:s:a output.mkvWhen I play back the video using mpv and switch to the audio track I just added, I hear no audio and an error appears in the Terminal. I know this error is related to the track I added, because it only appears if I switch to it:

Code:[mkv] Too many packets in the demuxer packet queues:
[mkv] video/0: 1262 packets, 157297152 bytes
[mkv] audio/9: 0 packets, 0 bytesUsing ffprobe, I do see a difference in the audio stream between the original commentary file and the output file of my most recent command.

Original file:
Code: Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
title : Stereo
BPS-eng : 192000
DURATION-eng : 00:22:28.032000000
NUMBER_OF_FRAMES-eng: 42126
NUMBER_OF_BYTES-eng: 32352768
SOURCE_ID-eng : 001103
_STATISTICS_WRITING_APP-eng: MakeMKV v1.16.3 linux(x64-release)
_STATISTICS_WRITING_DATE_UTC-eng: 2021-06-15 15:18:22
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_IDoutput.mkv:
Code: Stream #0:9(eng): Audio: ac3, 48000 Hz, 2 channels, fltp
Metadata:
title : Stereo
BPS-eng : 1712597
DURATION-eng : 00:22:28.021333333
NUMBER_OF_FRAMES-eng: 126377
NUMBER_OF_BYTES-eng: 288577256
SOURCE_ID-eng : 001100
_STATISTICS_WRITING_APP-eng: MakeMKV v1.16.3 linux(x64-release)
_STATISTICS_WRITING_DATE_UTC-eng: 2021-06-15 15:24:39
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
DURATION : 00:22:28.032000000The first difference is on the first line. "output.mkv" is missing "192 kb/s (default)". There are also a number of differences in the "Metadata" section. I must not be preserving some important information during this process. Any thoughts?latest?d=yIl2AUoC8zA latest?i=M79Fju7HN7c:jjaEu3Gposw:F7zBnMy latest?i=M79Fju7HN7c:jjaEu3Gposw:V_sGLiP latest?d=qj6IDK7rITs latest?i=M79Fju7HN7c:jjaEu3Gposw:gIN9vFwM79Fju7HN7c
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments