1

I can't work out why I get the invalid stream specifier. Here's what I'm trying to do

Input file

  • Stream 0:0: video stream (I am transcoding this to h.264.)
  • Stream 0:1: 5.1 AC3 (I am transcoding this to 5.1 AAC.)
  • Stream 0:2: AAC stereo track commentary (I want to copy this.)
  • Stream 0:3: subtitle track for the movie (I want to copy this.)
  • Stream 0:4: subtitle track for director commentary (I want to copy this.)

Command:

ffmpeg -i guard.mkv -c:v libx264 -crf 17 -c:0:a:0 aac -cutoff 20000 -ac 6 -b:a 512K -c:0:a:1 copy -c:s copy guard1-1.mkv

I also tried the below command but it ended up encoding as the default Vorbis instead of AAC. I can't work out why either:

ffmpeg -i guard.mkv -c:v libx264 -crf 17 -map 0 -c:a:1 aac -cutoff 20000 -ac 6 -b:a 512K -c:a:2 copy -c:s copy guard1-1.mkv

If someone could suggest the correct command with an explainer of where I went wrong I can improve for next time!

2
  • Hi! WOW! Thank you an absolute bunch for this! I hadn't read any guide that made this as clear as you have done, not for this scenario anyway. I can't thank you enough. I rewrote the command ffmpeg -y -i guard.mkv -map 0:v -map 0:a:0 -map 0:a:1 -map 0:s -c:v libx264 -crf:v:0 17 -c:a:0 aac -cutoff:a:0 20000 -ac:a:0 6 -b:a:0 512k -c:a:1 copy -c:s copy guard1.mkv. it seems to be encoding and tye streams now look corrext and it's not encoding vorbis! I just noticed I'd used -crf:v:0 maybe I should have used -crf:v ? Anyway there was no error
    – vesred0220
    Commented Jan 25 at 8:50
  • Sorry I've just noticed you included the full command to rewrite as well as the breakdown. So I can just -cfr 17 then. Thank you :)
    – vesred0220
    Commented Jan 27 at 13:24

1 Answer 1

0

We may apply stream number specifier for each audio stream, and map everything:

ffmpeg -y -i guard.mkv -c:v libx264 -crf 17 -c:a:0 aac -cutoff:a:0 20000 -ac:0 6 -b:a:0 512k -c:a:1 copy -c:s copy -map 0:v -map 0:a:0 -map 0:a:1 -map 0:s guard1-1.mkv

The default mapping applies only one audio stream, and since we have two, we have to map both: -map 0:a:0 -map 0:a:1, and since we use mapping, we have to map all the streams, so we use -map 0:v -map 0:a:0 -map 0:a:1 -map 0:s.

For specifying which parameter applies which audio stream, we have to use the stream number in each argument, where a:0 applies the first and a:1 applies the second output audio stream.

  • -c:a:0 aac -cutoff:a:0 20000 -ac:0 6 -b:a:0 512k applies the first output audio stream.
  • -c:a:1 copy applies the second output audio stream.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .