How to remove one track from video file using ffmpeg?

后端 未结 3 2015
囚心锁ツ
囚心锁ツ 2020-12-07 23:05

How to remove only one track (not all) from video file container (.vob or .mkv) using ffmpeg?

I know I can just copy video (-c:v copy -an) and specific

3条回答
  •  执笔经年
    2020-12-07 23:17

    You are looking for -map.

    I have changed to using avconv, but it should be about the same.

    Let's say you have a file called "input.vob" with one video and two audio tracks; and you want to have "output.vob" with the video and the last audio.

    You would do:

    avconv -i input.vob -map 0:0 -c:v copy -map 0:2 -c:a copy output.vob
    

    You should notice that:

    1. I did not copy -map 0:1
    2. I did not need to do -an, because there are audio tracks. However, if there are no audio tracks at all, you may need to use such an attribute.
    3. Sometimes the streams are not numbered in the way i've described, for example audio can come before video.
    4. If there are subtitle streams there, you need to figure out how to deal with them as well.

    You cannot work on files "in place", you need to save into a different file.

    P.S. You may want to ask such questions on video.stackexchange.com next time.

提交回复
热议问题