zjevander
zjevander

Reputation: 368

What are all of the file extensions supported by FFmpeg

How would I go about getting a list of all the file extensions supported by FFmpeg for use in an ExtensionFilter used by FileChooser in JavaFX?

I am familiar with the "-codecs" and "-formats" options from FFmpeg, but these list the format and codec names which do not necessarily coincide with their file extensions.

e.g. (partial output from "ffmpeg -formats")

parsing aac and ac3 from the output of ffmpeg would work fine to create file extensions for those types of files, but matroska has ".mkv" file extension.

Upvotes: 11

Views: 7308

Answers (3)

milahu
milahu

Reputation: 3609

in python, this is trivial with pyav

python -c 'import av; print("\n".join([ formats + ":" + ",".join(extensions) for formats, extensions in (map(lambda format: (format, list(av.format.ContainerFormat(format).extensions)), av.formats_available))]))'

binka:binka
adp:adp,dtk
ilbc:lbc
sol:
fwse:fwse
s24be:
xvag:xvag
avif:avif
redspark:rsd
msf:msf
...

note: formats can have multiple names:

mov,mp4,m4a,3gp,3g2,mj2:mp4,mov,3gp,psp,isma,3g2,ismv,f4v,avif,m4b,mj2,m4a,ism

see also formats_available and ContainerFormat in av/format.pyx

JavaFX

in java, you will need to find a way to call libavformat.so

see also Where to get full list of libav* formats?

Upvotes: 0

mortalis
mortalis

Reputation: 2151

Based on the Gyan's answer, here's a python script I used to get all possible extension from ffmpeg, fot its muxers and demuxers:

import subprocess, re

ffmpeg = 'c:/ffmpeg/bin/ffmpeg.exe'

LINE_PATTERN = r' +\S+ +(\S+)'
EXT_PATTERN = r'Common extensions: (.+)\.'

# Get demuxers
output = subprocess.getoutput([ffmpeg, '-hide_banner', '-demuxers'])
lines = output.split('\n')[4:]

demuxers = {}
for line in lines:
  demuxer = re.findall(LINE_PATTERN, line)[0]
  
  info = subprocess.getoutput([ffmpeg, '-hide_banner', '-h', f'demuxer={demuxer}'])
  exts = re.findall(EXT_PATTERN, info)
  if exts:
    demuxers[demuxer] = exts[0].split(',')


# Get muxers
output = subprocess.getoutput([ffmpeg, '-hide_banner', '-muxers'])
lines = output.split('\n')[4:]

muxers = {}
for line in lines:
  muxer = re.findall(LINE_PATTERN, line)[0]

  info = subprocess.getoutput([ffmpeg, '-hide_banner', '-h', f'muxer={muxer}'])
  exts = re.findall(EXT_PATTERN, info)
  if exts:
    muxers[muxer] = exts[0].split(',')


# Write extensions
file_name = 'ffmpeg_extensions.txt'
f = open(file_name, 'w')

exts = set()
for ext in demuxers.values():
  [exts.add(x.strip()) for x in ext]
for ext in muxers.values():
  [exts.add(x.strip()) for x in ext]
for ext in sorted(exts):
  f.write(ext + '\n')

f.close()

print('Extensions written to file: ' + file_name)

Upvotes: 1

Gyan
Gyan

Reputation: 93329

There's no list directly available. You'll have to run

for input formats, ffmpeg -demuxers
for output formats, ffmpeg -muxers

Then for each entry, run

for input formats, ffmpeg -h demuxer=entry
for output formats, ffmpeg -h muxer=entry

Each format readout will show something like,

Muxer matroska [Matroska]:
    Common extensions: mkv.
    Mime type: video/x-matroska.
    Default video codec: h264.
...

or

Demuxer avi [AVI (Audio Video Interleaved)]:
    Common extensions: avi.
...

Then you can collect all extensions from the Common extensions entries.

Upvotes: 13

Related Questions