<p>In the syntax <code>-map 1:a:24</code>, <code>1</code> stands for the input file index. Counting starts from <code>0</code>, so <code>1</code> refers to the 2nd input file but the command only has one input. <code>a</code> stands for stream type, and in this case, it's audio - <code>v</code> is for video, <code>s</code> for subtitles, <code>d</code> for data. <code>24</code> represents the 25th (0-indexed, remember) audio track. If your command has one input file with three video, three audio and three subtitle streams in the following order: <code>V A S A V S V A S</code>, then the 2nd video will be <code>-map 0:v:1</code> You can reference it using absolute index by using <code>-map 0:4</code>. With absolute indexing, there's no stream type specifier.</p>
<p>Assuming the stream numbering in your description is correct, use</p>
<pre><code>ffmpeg -i IN.MKV -map 0:0 -map 0:a:0 -map 0:a:2 -map 0:s:23 -map 0:s:24 -c copy OUT.MKV
</code></pre>
<p>Note that if <code>-c copy</code> is omitted, all streams will be re-encoded - not what you want normally.</p>

CC BY-SA 4.0
2020-08-18T10:14:48.763Z
2020-08-18T10:27:28.533Z
2020-08-18T10:27:28.533Z
Gyan
<p>I have multiple MKV files with video encoded a la HEVC/H.265.  I want to, using the Windows command line, make a new MKV file, stripping out all but specific subtitle tracks and audio tracks, on a file-by-file basis, as I have no need to retain multiple foreign language sound tracks and subtitle tracks.</p>
<p>Let's say I used <a href="https://trac.ffmpeg.org/wiki/FFprobeTips" rel="nofollow noreferrer">ffprobe</a> to find what streams are in a given MKV file. Further, I want to keep the first and third audio tracks, and the 24th and 25th subtitle tracks, from said file. I used <a href="https://stackoverflow.com/questions/63302454/map-metadata-stream-by-filter-in-ffmpeg">https://stackoverflow.com/questions/63302454/map-metadata-stream-by-filter-in-ffmpeg</a> as a reference.</p>
<p>I have tried to do that with</p>
<pre><code>ffmpeg -i INPUTFILE.MKV -map 0:0 -map 1:1 -map 1:3 -map 1:a:24 -map 1:a:25 OUTPUTFILE.MKV
</code></pre>
<p>which fails. How should I write the command?</p>

<ffmpeg><windows><subtitles><mkv><tracks>
Removing streams in HEVC H.265 MKV file?
K7AAY
# Removing streams in HEVC H.265 MKV file?

(Asked by: username_0 on 2020-08-18)

I have multiple MKV files with video encoded a la HEVC/H.265.  I want to, using the Windows command line, make a new MKV file, stripping out all but specific subtitle tracks and audio tracks, on a file-by-file basis, as I have no need to retain multiple foreign language sound tracks and subtitle tracks.
Let's say I used ffprobe to find what streams are in a given MKV file. Further, I want to keep the first and third audio tracks, and the 24th and 25th subtitle tracks, from said file. I used https://stackoverflow.com/questions/63302454/map-metadata-stream-by-filter-in-ffmpeg as a reference.
I have tried to do that with
ffmpeg -i INPUTFILE.MKV -map 0:0 -map 1:1 -map 1:3 -map 1:a:24 -map 1:a:25 OUTPUTFILE.MKV

which fails. How should I write the command?

**Tags:** ffmpeg, windows, subtitles, mkv, tracks


---

## 1 answers

### Answer by username_1 on 2020-08-18. Score: 1

In the syntax -map 1:a:24, 1 stands for the input file index. Counting starts from 0, so 1 refers to the 2nd input file but the command only has one input. a stands for stream type, and in this case, it's audio - v is for video, s for subtitles, d for data. 24 represents the 25th (0-indexed, remember) audio track. If your command has one input file with three video, three audio and three subtitle streams in the following order: V A S A V S V A S, then the 2nd video will be -map 0:v:1 You can reference it using absolute index by using -map 0:4. With absolute indexing, there's no stream type specifier.
Assuming the stream numbering in your description is correct, use
ffmpeg -i IN.MKV -map 0:0 -map 0:a:0 -map 0:a:2 -map 0:s:23 -map 0:s:24 -c copy OUT.MKV

Note that if -c copy is omitted, all streams will be re-encoded - not what you want normally.


---

