Using ffmpeg on how do I copy the video and multiple subtitle streams in an MKV and reencode multiple audio...












1














I have a video file in MKV format. I like the quality of the video, but I dislike having the audio in FLAC format since I decided it takes up too much space.



It is a dual audio file—it’s an anime with Japanese and English audio—and it has several subtitle streams inside as well.



This is the command I use:



ffmpeg -i "01.mkv" -c:v copy -c:a ac3 -c:s copy "test.mkv"


However it only gets the first audio and first subtitle string. I need help with the map option for multiple streams.










share|improve this question
























  • What is the problem with the command you currently have? I suspect you need a -map 0:a? -map 0:s? -map 0:v before your -c:v, but apart from that it looks okay to me.
    – Mokubai
    Dec 2 '17 at 22:51












  • Right now it only gets the first audio and first subtitle string. I will attempt with the map option. I read about it, but I couldn't quite understand how to use it. Would it look like this then? ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"
    – Jason Murray
    Dec 2 '17 at 22:54












  • Look at the answers here if you haven’t already.
    – JakeGould
    Dec 2 '17 at 22:56










  • Yes, give that a shot. I'm still getting to grips with ffmpeg myself, but the map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.
    – Mokubai
    Dec 2 '17 at 23:05










  • Just encoded my test file and it seems to have worked perfectly! Thanks! Now to do the part I have no idea about, which is to write a bash script. But that is for another question. Thanks again!
    – Jason Murray
    Dec 2 '17 at 23:07
















1














I have a video file in MKV format. I like the quality of the video, but I dislike having the audio in FLAC format since I decided it takes up too much space.



It is a dual audio file—it’s an anime with Japanese and English audio—and it has several subtitle streams inside as well.



This is the command I use:



ffmpeg -i "01.mkv" -c:v copy -c:a ac3 -c:s copy "test.mkv"


However it only gets the first audio and first subtitle string. I need help with the map option for multiple streams.










share|improve this question
























  • What is the problem with the command you currently have? I suspect you need a -map 0:a? -map 0:s? -map 0:v before your -c:v, but apart from that it looks okay to me.
    – Mokubai
    Dec 2 '17 at 22:51












  • Right now it only gets the first audio and first subtitle string. I will attempt with the map option. I read about it, but I couldn't quite understand how to use it. Would it look like this then? ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"
    – Jason Murray
    Dec 2 '17 at 22:54












  • Look at the answers here if you haven’t already.
    – JakeGould
    Dec 2 '17 at 22:56










  • Yes, give that a shot. I'm still getting to grips with ffmpeg myself, but the map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.
    – Mokubai
    Dec 2 '17 at 23:05










  • Just encoded my test file and it seems to have worked perfectly! Thanks! Now to do the part I have no idea about, which is to write a bash script. But that is for another question. Thanks again!
    – Jason Murray
    Dec 2 '17 at 23:07














1












1








1


1





I have a video file in MKV format. I like the quality of the video, but I dislike having the audio in FLAC format since I decided it takes up too much space.



It is a dual audio file—it’s an anime with Japanese and English audio—and it has several subtitle streams inside as well.



This is the command I use:



ffmpeg -i "01.mkv" -c:v copy -c:a ac3 -c:s copy "test.mkv"


However it only gets the first audio and first subtitle string. I need help with the map option for multiple streams.










share|improve this question















I have a video file in MKV format. I like the quality of the video, but I dislike having the audio in FLAC format since I decided it takes up too much space.



It is a dual audio file—it’s an anime with Japanese and English audio—and it has several subtitle streams inside as well.



This is the command I use:



ffmpeg -i "01.mkv" -c:v copy -c:a ac3 -c:s copy "test.mkv"


However it only gets the first audio and first subtitle string. I need help with the map option for multiple streams.







audio video ffmpeg






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 6 at 21:13









xpt

3,126115388




3,126115388










asked Dec 2 '17 at 22:29









Jason MurrayJason Murray

5115




5115












  • What is the problem with the command you currently have? I suspect you need a -map 0:a? -map 0:s? -map 0:v before your -c:v, but apart from that it looks okay to me.
    – Mokubai
    Dec 2 '17 at 22:51












  • Right now it only gets the first audio and first subtitle string. I will attempt with the map option. I read about it, but I couldn't quite understand how to use it. Would it look like this then? ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"
    – Jason Murray
    Dec 2 '17 at 22:54












  • Look at the answers here if you haven’t already.
    – JakeGould
    Dec 2 '17 at 22:56










  • Yes, give that a shot. I'm still getting to grips with ffmpeg myself, but the map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.
    – Mokubai
    Dec 2 '17 at 23:05










  • Just encoded my test file and it seems to have worked perfectly! Thanks! Now to do the part I have no idea about, which is to write a bash script. But that is for another question. Thanks again!
    – Jason Murray
    Dec 2 '17 at 23:07


















  • What is the problem with the command you currently have? I suspect you need a -map 0:a? -map 0:s? -map 0:v before your -c:v, but apart from that it looks okay to me.
    – Mokubai
    Dec 2 '17 at 22:51












  • Right now it only gets the first audio and first subtitle string. I will attempt with the map option. I read about it, but I couldn't quite understand how to use it. Would it look like this then? ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"
    – Jason Murray
    Dec 2 '17 at 22:54












  • Look at the answers here if you haven’t already.
    – JakeGould
    Dec 2 '17 at 22:56










  • Yes, give that a shot. I'm still getting to grips with ffmpeg myself, but the map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.
    – Mokubai
    Dec 2 '17 at 23:05










  • Just encoded my test file and it seems to have worked perfectly! Thanks! Now to do the part I have no idea about, which is to write a bash script. But that is for another question. Thanks again!
    – Jason Murray
    Dec 2 '17 at 23:07
















What is the problem with the command you currently have? I suspect you need a -map 0:a? -map 0:s? -map 0:v before your -c:v, but apart from that it looks okay to me.
– Mokubai
Dec 2 '17 at 22:51






What is the problem with the command you currently have? I suspect you need a -map 0:a? -map 0:s? -map 0:v before your -c:v, but apart from that it looks okay to me.
– Mokubai
Dec 2 '17 at 22:51














Right now it only gets the first audio and first subtitle string. I will attempt with the map option. I read about it, but I couldn't quite understand how to use it. Would it look like this then? ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"
– Jason Murray
Dec 2 '17 at 22:54






Right now it only gets the first audio and first subtitle string. I will attempt with the map option. I read about it, but I couldn't quite understand how to use it. Would it look like this then? ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"
– Jason Murray
Dec 2 '17 at 22:54














Look at the answers here if you haven’t already.
– JakeGould
Dec 2 '17 at 22:56




Look at the answers here if you haven’t already.
– JakeGould
Dec 2 '17 at 22:56












Yes, give that a shot. I'm still getting to grips with ffmpeg myself, but the map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.
– Mokubai
Dec 2 '17 at 23:05




Yes, give that a shot. I'm still getting to grips with ffmpeg myself, but the map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.
– Mokubai
Dec 2 '17 at 23:05












Just encoded my test file and it seems to have worked perfectly! Thanks! Now to do the part I have no idea about, which is to write a bash script. But that is for another question. Thanks again!
– Jason Murray
Dec 2 '17 at 23:07




Just encoded my test file and it seems to have worked perfectly! Thanks! Now to do the part I have no idea about, which is to write a bash script. But that is for another question. Thanks again!
– Jason Murray
Dec 2 '17 at 23:07










1 Answer
1






active

oldest

votes


















2














I believe you need to specify the mapping of the audio and subtitle streams to ensure that all of them are copied through rather than the first. To do so you need to add -map 0:a? -map 0:s? -map 0:v before your -c:v



This should make your command



ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"


The map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.






share|improve this answer

















  • 1




    A map expression of the form -map x? tells ffmpeg to select all streams matching x but not throw an error if no matching streams are found. Just -map x will select all matching streams.
    – Gyan
    Dec 3 '17 at 4:34











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1273764%2fusing-ffmpeg-on-how-do-i-copy-the-video-and-multiple-subtitle-streams-in-an-mkv%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














I believe you need to specify the mapping of the audio and subtitle streams to ensure that all of them are copied through rather than the first. To do so you need to add -map 0:a? -map 0:s? -map 0:v before your -c:v



This should make your command



ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"


The map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.






share|improve this answer

















  • 1




    A map expression of the form -map x? tells ffmpeg to select all streams matching x but not throw an error if no matching streams are found. Just -map x will select all matching streams.
    – Gyan
    Dec 3 '17 at 4:34
















2














I believe you need to specify the mapping of the audio and subtitle streams to ensure that all of them are copied through rather than the first. To do so you need to add -map 0:a? -map 0:s? -map 0:v before your -c:v



This should make your command



ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"


The map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.






share|improve this answer

















  • 1




    A map expression of the form -map x? tells ffmpeg to select all streams matching x but not throw an error if no matching streams are found. Just -map x will select all matching streams.
    – Gyan
    Dec 3 '17 at 4:34














2












2








2






I believe you need to specify the mapping of the audio and subtitle streams to ensure that all of them are copied through rather than the first. To do so you need to add -map 0:a? -map 0:s? -map 0:v before your -c:v



This should make your command



ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"


The map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.






share|improve this answer












I believe you need to specify the mapping of the audio and subtitle streams to ensure that all of them are copied through rather than the first. To do so you need to add -map 0:a? -map 0:s? -map 0:v before your -c:v



This should make your command



ffmpeg -i "01.mkv" -map 0:a? -map 0:s? -map 0:v -c:v copy -c:a ac3 -c:s copy "test.mkv"


The map command is used to tell it that you definitely want those things to be pulled through to the output. -map 0:a:1 would specify only to copy audio stream number 1, while -map 0:a? should effectively wildcard it and copy them all.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 2 '17 at 23:09









MokubaiMokubai

56.9k16135153




56.9k16135153








  • 1




    A map expression of the form -map x? tells ffmpeg to select all streams matching x but not throw an error if no matching streams are found. Just -map x will select all matching streams.
    – Gyan
    Dec 3 '17 at 4:34














  • 1




    A map expression of the form -map x? tells ffmpeg to select all streams matching x but not throw an error if no matching streams are found. Just -map x will select all matching streams.
    – Gyan
    Dec 3 '17 at 4:34








1




1




A map expression of the form -map x? tells ffmpeg to select all streams matching x but not throw an error if no matching streams are found. Just -map x will select all matching streams.
– Gyan
Dec 3 '17 at 4:34




A map expression of the form -map x? tells ffmpeg to select all streams matching x but not throw an error if no matching streams are found. Just -map x will select all matching streams.
– Gyan
Dec 3 '17 at 4:34


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1273764%2fusing-ffmpeg-on-how-do-i-copy-the-video-and-multiple-subtitle-streams-in-an-mkv%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to make a Squid Proxy server?

Is this a new Fibonacci Identity?

Touch on Surface Book