Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable subtitles decoding in ffmpeg

I'm trying to convert some video file containing video, audio and subtitles streams into another format using FFMpeg. However, ffmpeg complains about the subtitles format - it cannot decode the stream. Since I don't need this subtitles stream, I'd like to know how can I disable subtitles stream decoding during conversion?

like image 369
v_2e Avatar asked Aug 26 '12 16:08

v_2e


People also ask

What is FFmpeg video format?

FFMPEG stands for Fast Forward Moving Picture Experts Group. It is a free and open source software project that offers many tools for video and audio processing. It's designed to run on a command line interface, and has many different libraries and programs to manipulate and handle video files.

What is FFmpeg command?

FFmpeg is an extremely powerful and versatile command-line tool for converting audio and video files. It is free and available for Windows, Mac and Linux machines.


3 Answers

I've finally found an answer.

There is such option as -sn which disables subtitles decoding from input stream. Also there are analogous options for audio and video decoding: -an and -vn respectively.

It also turned out that there is another way to achieve this. One may use the -map option to select which streams are to be decoded. So omitting the subtitles stream among the -map options does the job.

For example, if one has a movie file with 3 streams:

  • Stream 0: video
  • Stream 1: audio
  • Stream 2: subtitles

the converting command for FFmpeg may look as follows:

ffmpeg -i <input file> -sn -vcodec <video codec> -acodec <audio codec>  <output file>

or

ffmpeg -i <input file> -vcodec <video codec> -acodec <audio codec> -map 0:0 -map 0:1  <output file>

The former command line deselects the subtitles stream (probably all of them, if there are several) while the latter one selects only the necessary streams to decode.

like image 101
v_2e Avatar answered Oct 11 '22 15:10

v_2e


To remove subtitle stream without re-encoding video and audio shortest command would be:

ffmpeg -i input.mkv -sn -c copy output.mkv

like image 13
StefTN Avatar answered Oct 11 '22 15:10

StefTN


Use negative mapping to omit subtitles and keep everything else:

ffmpeg -i input.mkv -map 0 -map -0:s -c copy output.mkv
  • -map 0 selects all streams. This is recommended because the default stream selection behavior only chooses 1 stream per stream type.
  • -map -0:s is a negative mapping that deselects all subtitle streams.
  • -c copy enables stream copy mode which only re-muxes and avoids re-encoding.
like image 5
llogan Avatar answered Oct 11 '22 15:10

llogan