[FFmpeg-user] Guessing the output format
Carl Eugen Hoyos
ceffmpeg at gmail.com
Sat Feb 27 22:08:36 EET 2021
Am Sa., 27. Feb. 2021 um 20:04 Uhr schrieb Carl Zwanzig <cpz at tuunq.com>:
>
> On 2/27/2021 12:23 AM, Carl Eugen Hoyos wrote:
>
> >> ffmpeg -f lavfi -i testsrc=duration=5:size=1280x720:rate=30000/1001 testsrc.mpg
>
> > Just for completeness:
> > This does not create a MPEG-2 program stream but an MPEG-1 system stream.
>
> No doubt that's correct, although maybe unexpected by many people.
I don't think the ambiguity can be easily avoided, a
warning will be printed if you try to put something in
an MPEG-1 stream that is usually only found in
MPEG-2 streams (Dolby, DTS, raw DVD audio).
> (this is mostly to document things so it can found in the list archive)
>
> ffmpeg-all doc tells us
>
> -f fmt (input/output)
> Force input or output file format. The format is normally auto detected
> for input files and guessed from the file extension for output files,[...]
>
> but there is nothing that explains which guesses are made (and how)
> on the output format.
One reason is that it is a guess and we may change the heuristic
(although I am generally against changing it).
> Most should be fairly obvious (e.g. .ogg or .wav); the
> confusion comes when you get to all of the MPEG-related formats
> (vob, dvd, mp2, mp4, etc)
The difference between dvd and vob is minimal, "mp2" and "mp4" are
not ambiguous imo.
> all of which -might- be found in a file called .mpg (right
> or wrong, it happens).
Not sure I understand this:
mpg should be a (MPEG-1 or 2) program stream, has - imo - a wrong
extension if it is a transport stream (this happens) and should never
be an MPEG-1 Audio Layer 2 or isom file.
Note that FFmpeg can distinguish between all of these types (except
some rare MUSICAM files) no matter the file extension and that - see
above - the ambiguity between MPEG-1 and 2 is imo unavoidable.
> ffmpeg -muxers will show a list of muxers and what appear to be their
> default file extensions (although .mpg isn't shown, .mpeg is; it's
> reasonable to treat them as same).
No file extensions are shown, these are the names of the muxers
that you can feed the "-f" option with.
> Note also that this identifies the -container-, not necessarily the codec or
> other parameters. For instance- nothing specifically mentions the difference
> between the MPEG-2 PS in .vob vs .dvd.
The difference are the NAV packets that exist only in dvd.
Last time I used software to create DVDs, it would accept
vob files and add the necessary NAV packets.
In addition, hardware DVD players typically play vob files.
> This is similar to the -target option, the doc page doesn't
> mention all of the parameters that are being set (it's only
> in the code).
Imo, -f and -target are very different.
> (It appears that the work starts with av_guess_format() calling
> av_muxer_iterate() which then looks over the list of all muxers
> (in muxer_list.c) and appears to check each one in turn to see
> what it thinks of the file name/extension/mime-type passed.
> When time permits, I may dive more deeply into this.)
The command line utility prints the format it chose because of
the extension to simplify your task / make it unneeded.
Carl Eugen
More information about the ffmpeg-user
mailing list