What file extensions does ffmpeg support?
I'm trying to extract a subtitle from a Blu-ray disc and it is an hdmv_pgs_subtitle
. So I try
ffmpeg -i file.m2ts -map 0:3 -scodec copy rip3/test.sub
and get
Could not write header for output file #0 (incorrect codec parameters ?):
Operation not permitted
Then I do
ffmpeg -i file.m2ts -map 0:3 -scodec copy rip3/test.sup
ffmpeg -i file.m2ts -map 0:3 -scodec copy rip3/test.srt
and a bunch of other different extensions, until I give .mkv
a shot, which works.
How can I find what extensions ffmpeg allows? I haven't found one place that e.g. names .mkv
as an extension
ffmpeg -formats
mentions matroska
, but doesn't say that .mkv
is the extension. So is there a way to find all supported file extensions for ffmpeg?
EDIT: After reading the answer from slhck I found the extensions by doing this command in the sourcefolder.
find . -type f -iname "*.c" -exec egrep -H ".extensions" {} \;
The filename will give some information about what kind of format it is.
First off, you can see all formats (containers) by calling ffmpeg -formats
. That they don't mention extensions is probably for the reason that an extension on its own is often meaningless, and you can override the output format by using the -f
option.
You can see what the common extensions are for a particular (de)muxer. For example:
$ ffmpeg -v 1 -h demuxer=matroska
Demuxer matroska,webm [Matroska / WebM]:
Common extensions: mkv,mk3d,mka,mks
Output formats and their extensions are registered in the encoders. So, you'd find this for Matroska, when looking at the ffmpeg source code:
AVOutputFormat ff_matroska_muxer = {
.name = "matroska",
.long_name = NULL_IF_CONFIG_SMALL("Matroska"),
.mime_type = "video/x-matroska",
.extensions = "mkv",
....
Input formats are usually not parsed by their extension but the actual contained data.
Also see:
- FFmpeg Formats Documentation
- FFmpeg Documentation: Supported File Formats, Codecs, or Features.
The problem is that only two of all the formats ffmpeg can handle support HDMV PGS subtitles:
- MPEG-TS
- MKV (Matroska)
You cannot use an SRT container because it's a different concept. SRT subtitles are based on text, while HDMV PGS subtitles are actual bitmaps.
So, this should work if all you need to do is store the subtitles somewhere:
ffmpeg -i input.mkv -c:s:0 copy -map 0:s:0 output.mks