Set a subtitle language using ffmpeg

After some research, found the reason why -slang didn't work. In fact you use a recent version of ffmpeg and it's a good thing but if the documentation still describe the option, you can find in the ChangeLog:

version 0.9:
...
 * -metadata can now be used to set metadata on streams and chapters, e.g.
      -metadata:s:1 language=eng sets the language of the first stream to 'eng'.
      This made -vlang/-alang/-slang options redundant, so they were removed.

When you find a command line example, check if the option used are in Your version of ffmpeg.

 ffmpeg --help >> ffmpeg-doc.txt

The -slang option isn't in.

But it also proof that the on-line documentation about ffmpeg is sometime incorrect regarding the code change.


The option

-metadata:s:1 language=eng

sets metadata language to eng on the stream id 1 (which is, in typical cases, the first audio stream). Whereas the option

-metadata:s:s:0 language=eng

sets the metadata language to eng on the first subtitle stream.

From ffmpeg manpage:

-metadata[:metadata_specifier] key=value (output,per-metadata)
Set a metadata key/value pair.

An optional metadata_specifier may be given to set metadata on streams or chapters. See "-map_metadata" documentation for details.

s[:stream_spec]
per-stream metadata. stream_spec is a stream specifier as described in the Stream specifiers chapter. In an input metadata specifier, the first matching stream is copied from. In an output metadata specifier, all matching streams are copied to.

And finally from the chapter of stream specifiers, we see

Possible forms of stream specifiers are:
stream_index
Matches the stream with this index. E.g. "-threads:1 4" would set the thread count for the second stream to 4.

stream_type[:stream_index]
stream_type is one of: 'v' for video, 'a' for audio, 's' for subtitle, 'd' for data and 't' for attachments. If stream_index is given, then matches stream number stream_index of this type. Otherwise matches all streams of this type.