Set subtitle language using ffmpeg

I tried searching for the subtitle language with ffmpeg and found the -slang option. So I tried the following command, but immediately got an error:

ffmpeg -i input.avi -i subs.srt -c:a copy -c:s mov_text -slang eng -c:v libx264 -profile:v high -level:v 4.0 output.mp4 ffmpeg version 1.1 Copyright (c) 2000-2013 the FFmpeg developers built on Jul 18 2013 23:00:53 with Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn) 

libavutil 52.13.100 / 52. 13.100

libavcodec 54.86.100 / 54. 86.100

libavformat 54.59.106 / 54. 59.106

libavdevice 54.3.102 / 54. 3.102

libavfilter 3. 32.100 / 3. 32.100

libswscale 2.1.103 / 2. 1.103

libswresample 0. 17.102 / 0. 17.102

libpostproc 52.2.100 / 52. 2.100

Unrecognized slang option.

Argument splitting error: option not found

After a larger search, I found another way to do this using the -metadata command:

 ffmpeg -i input.mp4 -i subs.srt -c:a copy -c:v copy -c:s mov_text -metadata:s:s:0 language=eng output.mp4 

And it works absolutely fine. But this is not mentioned on the ffmpeg man page, whereas -slang is, which makes me think that the -metadata command may be outdated or in some other way not as good as -slang.

  • What is the difference between using the two above methods (-slang vs -metadata)?
  • Why did my -slang team report an error? Did I use it incorrectly?
+9
ffmpeg subtitle
source share
2 answers

After some research, we figured out the reason why -slang did not work. You are actually using the latest version of ffmpeg, which is good, but if the documentation still describes this parameter, you can find in ChangeLog :

 version 0.9: ... * -metadata can now be used to set metadata on streams and chapters, eg -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 to see if there is an option used in your version of ffmpeg.

  ffmpeg --help >> ffmpeg-doc.txt 

The -slang option -slang missing.

But it also proves that the online ffmpeg documentation is sometimes incorrect regarding code changes.

+5
source share

Option

-metadata: s: 1 language = eng

sets the eng metadata language for stream identifier 1 (which in typical cases is the first audio stream). While option

-metadata: s: s: 0 language = eng

sets the eng metadata language in the first subtitle stream.

From the ffmpeg man page:

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

An optional metadata_specifier may be provided for setting metadata in streams or chapters. See the "-map_metadata" documentation for details.

with [: stream_spec]
metadata for each stream. stream_spec is a stream specifier, as described in the "Stream stream_spec " chapter. In the input metadata qualifier, the first matching stream is copied from. In the output metadata specifier, all matching streams are copied to.

And finally, from the chapter on stream qualifiers we see

Possible forms of stream qualifiers:
stream_index
Associates a stream with this index. For example. "-threads: 1 4" will set the thread counter for the second thread to 4.

stream_type[:stream_index]
stream_type is one of: β€œv” for video, β€œa” for audio, β€œs” for subtitles, β€œd” for data, and β€œt” for attachments. If stream_index is specified, then the stream_index stream number of this type matches. Otherwise, it matches all threads of this type.

+10
source share

All Articles