Answers.Body: <p>A <code>map</code> option will select all streams matched by the specification. The 'best' stream is only selected in the absence of any map options.</p>
  
  <p>So, you'll need a two-stage process to do this:</p>
  
  <pre><code>ffmpeg -i in.mkv -map 0:a:m:language:eng -vn -acodec copy -f nut - | ffmpeg -f nut -i - -c copy output.flac
  </code></pre>
  
  <p>The first ffmpeg process sends all English language audio streams to the 2nd ffmpeg process, which will select only the 'best' among the received streams for output.</p>
  
  <p>If you want to keep metadata, and not worry about the codec of the input file, you can change your output to <code>.mkv</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-12T12:15:58.413Z
Answers.Text: That's the 'file format' set for the piped data. ffmpeg generally detects the format based on the extension of the output file. There's none specified by `-` so we have to set one. `-f matroska` would work as well but nut supports finer timestamps so I prefer that.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-12T12:30:45.660Z
Answers.Text: nut is not really necessary here, just a habit for me. ffmpeg can't auto-supply extension.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-13T08:36:16.830Z
Answers.Text: I've added this to your answer so is more relevant to others. Thanks so much! I'll cleanup old comments
Answers.UserDisplayName: Freedo
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-28T06:43:41.130Z
Answers.Text: Trying to adapt this to subtitles doesn't work. Any idea why? `-map 0:s:m:language:eng -vn -scodec copy -f nut - | ffmpeg -f nut -i - -c:s srt "${file%.mkv}".eng.srt`
Answers.UserDisplayName: Freedo
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-28T07:10:54.543Z
Answers.Text: Share full log.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-12T11:23:30.853Z
Answers.LastActivityDate: 2019-06-13T08:37:22.587Z
Answers.LastEditDate: 2019-06-13T08:37:22.587Z
Answers.UserDisplayName: Gyan
Body: <p>Say you input has 2 english audio tracks, 7.1 and 2.0. </p>
  
  <p>You want to copy the audio track of highest quality (number of channels) to <code>audio.ext</code> </p>
  
  <p>If I use <code>-map 0:m:language:eng</code> it selects all english audio tracks where I thought by default it would only copy the highest channel audio track.</p>
  
  <p>Example:</p>
  
  <pre><code>ffmpeg -i *mkv -map 0:m:language:eng -vn -acodec copy output.flac
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-12T10:51:35.510Z
Comments.Text: What's your full command?
Comments.UserDisplayName: Gyan
Tags: <ffmpeg>
Title: ffmpeg copy highest quality audio track of a specific language
UserDisplayName: Freedo
ThreadText: # ffmpeg copy highest quality audio track of a specific language
  
  (Asked by: username_0 on 2019-06-12)
  
  Say you input has 2 english audio tracks, 7.1 and 2.0.
  
  You want to copy the audio track of highest quality (number of channels) to `audio.ext`
  
  If I use `-map 0:m:language:eng` it selects all english audio tracks where I thought by default it would only copy the highest channel audio track.
  
  Example:
  
  ```
  ffmpeg -i *mkv -map 0:m:language:eng -vn -acodec copy output.flac
  
  ```
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: What's your full command?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-06-12. Score: 2 | Accepted answer
  
  A `map` option will select all streams matched by the specification. The 'best' stream is only selected in the absence of any map options.
  
  So, you'll need a two-stage process to do this:
  
  ```
  ffmpeg -i in.mkv -map 0:a:m:language:eng -vn -acodec copy -f nut - | ffmpeg -f nut -i - -c copy output.flac
  
  ```
  
  The first ffmpeg process sends all English language audio streams to the 2nd ffmpeg process, which will select only the 'best' among the received streams for output.
  
  If you want to keep metadata, and not worry about the codec of the input file, you can change your output to `.mkv`
  
  > **Comments:**
  > **username_1**: That's the 'file format' set for the piped data. ffmpeg generally detects the format based on the extension of the output file. There's none specified by `-` so we have to set one. `-f matroska` would work as well but nut supports finer timestamps so I prefer that.  
  > **username_1**: nut is not really necessary here, just a habit for me. ffmpeg can't auto-supply extension.  
  > **username_0**: I've added this to your answer so is more relevant to others. Thanks so much! I'll cleanup old comments  
  > **username_0**: Trying to adapt this to subtitles doesn't work. Any idea why? `-map 0:s:m:language:eng -vn -scodec copy -f nut - | ffmpeg -f nut -i - -c:s srt "${file%.mkv}".eng.srt`  
  > **username_1**: Share full log.  
  
  ---
  
  