Discussion:
[FFmpeg-user] proper use of -f option
Paul Garner
2011-01-20 15:49:38 UTC
Permalink
Hi,

Have I got this right: ffmpeg will try to guess the desired output
format from the file extension of the output path, failing that you
need to use the -f option to tell ffmpeg what type of file to output?

In my case I'm using a hosted encoding service which allows me to pass
parameters to the ffmpeg cli that does the encoding but for whatever
reason the encoding service gives ffmpeg an output filename to use
that has no extension.

Using '-f mp3' works for mp3 files, but trying to output AAC files I
get errors if I do '-f aac' or '-f m4a'

Outputting AAC file works if I give use the filename 'outputfile.m4a'
and no -f flag, but that's not a possibility on my hosted encoding
service.

So my question is: why don't '-f aac' or '-f m4a' work when they are
both listed as available formats in ffmpeg -formats ? How do I know
what are valid options for -f ?
Justin Ruggles
2011-01-20 16:22:02 UTC
Permalink
Post by Paul Garner
Hi,
Have I got this right: ffmpeg will try to guess the desired output
format from the file extension of the output path, failing that you
need to use the -f option to tell ffmpeg what type of file to output?
In my case I'm using a hosted encoding service which allows me to pass
parameters to the ffmpeg cli that does the encoding but for whatever
reason the encoding service gives ffmpeg an output filename to use
that has no extension.
Using '-f mp3' works for mp3 files, but trying to output AAC files I
get errors if I do '-f aac' or '-f m4a'
Outputting AAC file works if I give use the filename 'outputfile.m4a'
and no -f flag, but that's not a possibility on my hosted encoding
service.
So my question is: why don't '-f aac' or '-f m4a' work when they are
both listed as available formats in ffmpeg -formats ? How do I know
what are valid options for -f ?
They are valid input format names, but not valid output format names
(notice the D but no E next to them in ffmpeg -formats). For output, I
believe you should use -f adts or -f mp4.

-Justin
Paul Garner
2011-01-20 17:32:49 UTC
Permalink
Thanks very much!

I tried both and it looks like '-f mp4' is the right one... after
renaming both to .m4a files only the '-f mp4' one had working metadata
and could be dropped into iTunes successfully.

thanks again
Post by Justin Ruggles
Post by Paul Garner
Hi,
Have I got this right: ffmpeg will try to guess the desired output
format from the file extension of the output path, failing that you
need to use the -f option to tell ffmpeg what type of file to output?
In my case I'm using a hosted encoding service which allows me to pass
parameters to the ffmpeg cli that does the encoding but for whatever
reason the encoding service gives ffmpeg an output filename to use
that has no extension.
Using '-f mp3' works for mp3 files, but trying to output AAC files I
get errors if I do '-f aac' or '-f m4a'
Outputting AAC file works if I give use the filename 'outputfile.m4a'
and no -f flag, but that's not a possibility on my hosted encoding
service.
So my question is: why don't '-f aac' or '-f m4a' work when they are
both listed as available formats in ffmpeg -formats ? ?How do I know
what are valid options for -f ?
They are valid input format names, but not valid output format names
(notice the D but no E next to them in ffmpeg -formats). ?For output, I
believe you should use -f adts or -f mp4.
-Justin
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Leo Izen
2011-01-20 17:42:16 UTC
Permalink
That's because m4a is the apple-created extension for an audio-only mp4. See
http://en.wikipedia.org/wiki/Mp4#.MP4_versus_.M4A_filename_extensions
Post by Paul Garner
Thanks very much!
I tried both and it looks like '-f mp4' is the right one... after
renaming both to .m4a files only the '-f mp4' one had working metadata
and could be dropped into iTunes successfully.
thanks again
Post by Justin Ruggles
Post by Paul Garner
Hi,
Have I got this right: ffmpeg will try to guess the desired output
format from the file extension of the output path, failing that you
need to use the -f option to tell ffmpeg what type of file to output?
In my case I'm using a hosted encoding service which allows me to pass
parameters to the ffmpeg cli that does the encoding but for whatever
reason the encoding service gives ffmpeg an output filename to use
that has no extension.
Using '-f mp3' works for mp3 files, but trying to output AAC files I
get errors if I do '-f aac' or '-f m4a'
Outputting AAC file works if I give use the filename 'outputfile.m4a'
and no -f flag, but that's not a possibility on my hosted encoding
service.
So my question is: why don't '-f aac' or '-f m4a' work when they are
both listed as available formats in ffmpeg -formats ? How do I know
what are valid options for -f ?
They are valid input format names, but not valid output format names
(notice the D but no E next to them in ffmpeg -formats). For output, I
believe you should use -f adts or -f mp4.
-Justin
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Paul Garner
2011-01-20 17:53:52 UTC
Permalink
For bonus points... any idea the correct -f option for ALAC (Apple
Lossless) files?

They have .m4a extension like an AAC but '-f mp4' gives an error:
Could not write header for output file #0 (incorrect codec parameters ?)

This page says ALAC audio is 'Usually stored in an MP4 container, as a
private extension since it is not part of the MPEG-4 standard" so
maybe the '-f mp4' handler doesn't like seeing ALAC content?
http://wiki.multimedia.cx/index.php?title=ALAC

I can encode alac fine without the -f option if I give a .m4a file
extension, but that's not an option for me outside of testing.
Post by Justin Ruggles
Post by Paul Garner
Hi,
Have I got this right: ffmpeg will try to guess the desired output
format from the file extension of the output path, failing that you
need to use the -f option to tell ffmpeg what type of file to output?
In my case I'm using a hosted encoding service which allows me to pass
parameters to the ffmpeg cli that does the encoding but for whatever
reason the encoding service gives ffmpeg an output filename to use
that has no extension.
Using '-f mp3' works for mp3 files, but trying to output AAC files I
get errors if I do '-f aac' or '-f m4a'
Outputting AAC file works if I give use the filename 'outputfile.m4a'
and no -f flag, but that's not a possibility on my hosted encoding
service.
So my question is: why don't '-f aac' or '-f m4a' work when they are
both listed as available formats in ffmpeg -formats ? ?How do I know
what are valid options for -f ?
They are valid input format names, but not valid output format names
(notice the D but no E next to them in ffmpeg -formats). ?For output, I
believe you should use -f adts or -f mp4.
-Justin
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Leo Izen
2011-01-20 18:15:34 UTC
Permalink
+1 for me! Use -f ipod -vn. What I to figure that out was I used no -f, and
saw that it by default was writing to ipod. So I tried with -f ipod, and it
worked!

[Leo at chessman Videos]$ ffmpeg -i capture0002.ogv -f ipod -vn -acodec alac
capture-audio.m4a
[ogg @ 0x852760] max_analyze_duration reached
Input #0, ogg, from 'capture0002.ogv':
Duration: 00:05:33.33, start: 0.000000, bitrate: 2302 kb/s
Stream #0.0: Data: skeleton
Stream #0.1: Video: theora, yuv420p, 1680x1040 [PAR 1:1 DAR 21:13], 30
fps, 30 tbr, 30 tbn, 30 tbc
Stream #0.2: Audio: vorbis, 41000 Hz, stereo, s16, 499 kb/s
Output #0, ipod, to 'capture-audio.m4a':
Metadata:
encoder : Lavf52.94.0
Stream #0.0: Audio: alac, 41000 Hz, stereo, s16, 64 kb/s
Stream mapping:
Stream #0.2 -> #0.0
Press [q] to stop encoding
size= 29247kB time=333.27 bitrate= 718.9kbits/s
video:0kB audio:29220kB global headers:0kB muxing overhead 0.091375%
[Leo at chessman Videos]$ ffmpeg -i capture-audio.m4a
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'capture-audio.m4a':
Metadata:
major_brand : M4A
minor_version : 512
compatible_brands: isomiso2
creation_time : 1970-01-01 00:00:00
encoder : Lavf52.94.0
Duration: 00:05:33.21, start: 0.000000, bitrate: 719 kb/s
Stream #0.0(und): Audio: alac, 41000 Hz, 2 channels, s16, 718 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
At least one output file must be specified
[Leo at chessman Videos]$
Post by Paul Garner
For bonus points... any idea the correct -f option for ALAC (Apple
Lossless) files?
Could not write header for output file #0 (incorrect codec parameters ?)
This page says ALAC audio is 'Usually stored in an MP4 container, as a
private extension since it is not part of the MPEG-4 standard" so
maybe the '-f mp4' handler doesn't like seeing ALAC content?
http://wiki.multimedia.cx/index.php?title=ALAC
I can encode alac fine without the -f option if I give a .m4a file
extension, but that's not an option for me outside of testing.
Post by Justin Ruggles
Post by Paul Garner
Hi,
Have I got this right: ffmpeg will try to guess the desired output
format from the file extension of the output path, failing that you
need to use the -f option to tell ffmpeg what type of file to output?
In my case I'm using a hosted encoding service which allows me to pass
parameters to the ffmpeg cli that does the encoding but for whatever
reason the encoding service gives ffmpeg an output filename to use
that has no extension.
Using '-f mp3' works for mp3 files, but trying to output AAC files I
get errors if I do '-f aac' or '-f m4a'
Outputting AAC file works if I give use the filename 'outputfile.m4a'
and no -f flag, but that's not a possibility on my hosted encoding
service.
So my question is: why don't '-f aac' or '-f m4a' work when they are
both listed as available formats in ffmpeg -formats ? How do I know
what are valid options for -f ?
They are valid input format names, but not valid output format names
(notice the D but no E next to them in ffmpeg -formats). For output, I
believe you should use -f adts or -f mp4.
-Justin
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Paul Garner
2011-01-20 18:40:13 UTC
Permalink
You beautiful winner! Even the metadata works...

is this stuff documented anywhere? that'd be handy
Post by Leo Izen
+1 for me! Use -f ipod -vn. What I to figure that out was I used no -f, and
saw that it by default was writing to ipod. So I tried with -f ipod, and it
worked!
[Leo at chessman Videos]$ ffmpeg -i capture0002.ogv -f ipod -vn -acodec alac
capture-audio.m4a
?Duration: 00:05:33.33, start: 0.000000, bitrate: 2302 kb/s
? ?Stream #0.0: Data: skeleton
? ?Stream #0.1: Video: theora, yuv420p, 1680x1040 [PAR 1:1 DAR 21:13], 30
fps, 30 tbr, 30 tbn, 30 tbc
? ?Stream #0.2: Audio: vorbis, 41000 Hz, stereo, s16, 499 kb/s
? ?encoder ? ? ? ? : Lavf52.94.0
? ?Stream #0.0: Audio: alac, 41000 Hz, stereo, s16, 64 kb/s
?Stream #0.2 -> #0.0
Press [q] to stop encoding
size= ? 29247kB time=333.27 bitrate= 718.9kbits/s
video:0kB audio:29220kB global headers:0kB muxing overhead 0.091375%
[Leo at chessman Videos]$ ffmpeg -i capture-audio.m4a
? ?major_brand ? ? : M4A
? ?minor_version ? : 512
? ?compatible_brands: isomiso2
? ?creation_time ? : 1970-01-01 00:00:00
? ?encoder ? ? ? ? : Lavf52.94.0
?Duration: 00:05:33.21, start: 0.000000, bitrate: 719 kb/s
? ?Stream #0.0(und): Audio: alac, 41000 Hz, 2 channels, s16, 718 kb/s
? ? ?creation_time ? : 1970-01-01 00:00:00
At least one output file must be specified
[Leo at chessman Videos]$
Post by Paul Garner
For bonus points... any idea the correct -f option for ALAC (Apple
Lossless) files?
Could not write header for output file #0 (incorrect codec parameters ?)
This page says ALAC audio is 'Usually stored in an MP4 container, as a
private extension since it is not part of the MPEG-4 standard" so
maybe the '-f mp4' handler doesn't like seeing ALAC content?
http://wiki.multimedia.cx/index.php?title=ALAC
I can encode alac fine without the -f option if I give a .m4a file
extension, but that's not an option for me outside of testing.
Post by Justin Ruggles
Post by Paul Garner
Hi,
Have I got this right: ffmpeg will try to guess the desired output
format from the file extension of the output path, failing that you
need to use the -f option to tell ffmpeg what type of file to output?
In my case I'm using a hosted encoding service which allows me to pass
parameters to the ffmpeg cli that does the encoding but for whatever
reason the encoding service gives ffmpeg an output filename to use
that has no extension.
Using '-f mp3' works for mp3 files, but trying to output AAC files I
get errors if I do '-f aac' or '-f m4a'
Outputting AAC file works if I give use the filename 'outputfile.m4a'
and no -f flag, but that's not a possibility on my hosted encoding
service.
So my question is: why don't '-f aac' or '-f m4a' work when they are
both listed as available formats in ffmpeg -formats ? ?How do I know
what are valid options for -f ?
They are valid input format names, but not valid output format names
(notice the D but no E next to them in ffmpeg -formats). ?For output, I
believe you should use -f adts or -f mp4.
-Justin
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user at mplayerhq.hu
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Loading...