3

Trying to extract subtitles to txt file

ffmpeg.exe -i video.mkv -c copy -map 0:s:0 subs.txt

but get the following error

Unable to find a suitable output format for 'subs.txt' 
subs.txt: Invalid argument

full console output:

ffmpeg version N-81872-gbe1d324 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.4.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 32.100 / 55. 32.100
  libavcodec     57. 60.101 / 57. 60.101
  libavformat    57. 51.102 / 57. 51.102
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 63.100 /  6. 63.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  2.100 /  2.  2.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, matroska,webm, from 'video.mkv':
  Metadata:
    CREATION_TIME   : 2018-10-28T02:41:51Z
    ENCODER         : Lavf57.7.2
  Duration: 00:11:45.39, start: 0.000000, bitrate: 2774 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 180k tbc (default)
    Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      title           : Stereo
    Stream #0:2(eng): Subtitle: ass
[NULL @ 00000000038c9540] Unable to find a suitable output format for 'subs.txt'
subs.txt: Invalid argument

It only works when I specify ass extension for output file like this:

ffmpeg.exe -i video.mkv -c copy -map 0:s:0 subs.ass

it extraxts properly and creates subs.ass file with subtitles
How ffmpeg interprets extension of output file? Why do I have to specify exact extension for output file?

similar question, but different error here: ffmpeg unable to find a suitable output format for 'subs.srt'

2

1 Answer 1

5

ffmpeg does not know what kind of output you want when supply a .txt file extension in the output path. Unless overridden by the -f option, it will try to figure out the necessary format from the file ending, so .ass will invoke the proper SSA format, .srt the SubRip format etc. The same goes for .mp4, .mov, etc.

To see what formats are supported, run ffmpeg -formats. There is no perfect mapping between format names and file extensions—sometimes there might be more than one extension triggering a format—, but in most cases they are the same. For example, the format mp4 is called with a file ending .mp4, and the format matroska is called with .mkv.

As for your subtitles, you can force ffmpeg to use a given format with -f <format>. For example:

ffmpeg -i <input> -map 0:s:0 -c copy -f srt output.txt

That assumes your input has SRT subtitles. If it doesn't, -c copy will not work. Leave out the -c copy part, for example, if you plan on outputting with -f ass.

2
  • @JakeGould Thanks for the edit, but the capitalization was absolutely intended. I like to distinguish between “FFmpeg” (the software project) and “ffmpeg” (the command line tool). It sometimes helps disambiguate.
    – slhck
    Jul 14, 2019 at 15:11
  • It is exactly what I have searched for. Command ffmpeg.exe -i video.mkv -map 0:s:0 -f ass subs.txt works as expected for my case
    – Yaros
    Jul 16, 2019 at 15:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .