From the man pages of ffmpeg
:
-s[:stream_specifier] size (input/output,per-stream)
Set frame size.
As an input option, this is a shortcut for the video_size private option, recognized by some demuxers for which the frame size is either not stored in the file or is configurable -- e.g.
raw video or video grabbers.
As an output option, this inserts the "scale" video filter to the end of the corresponding filtergraph. Please use the "scale" filter directly to insert it at the beginning or some other
place.
The format is wxh (default - same as source).
[...]
-r[:stream_specifier] fps (input/output,per-stream)
Set frame rate (Hz value, fraction or abbreviation).
As an input option, ignore any timestamps stored in the file and instead generate timestamps assuming constant frame rate fps. This is not the same as the -framerate option used for some
input formats like image2 or v4l2 (it used to be the same in older versions of FFmpeg). If in doubt use -framerate instead of the input option -r.
As an output option, duplicate or drop input frames to achieve constant output frame rate fps.
So these two options should change the frame size and frame rate of my audio stream, right?
Well look what happens when I fix the frame size to 1024 and change the frame rate:
$ ffmpeg -i in.mp3 -s:a 1024 -r:a 15 out.wav
...
size= 2592kB time=00:00:15.04 bitrate=1411.3kbits/s speed= 262x
$ ffmpeg -i in.mp3 -s:a 1024 -r:a 30 out.wav
...
size= 2592kB time=00:00:15.04 bitrate=1411.3kbits/s speed= 277x
The audio duration doesn't change. I would expect the second audio file to be half as long as the first since the sample frequency and frame size is the same. What's going on here? How do I change the frame rate of my audio file?
So these two options should change the frame size and frame rate of my audio stream, right?
-s
and -r
are video options, not audio options.
From the same documentation you quoted (man ffmpeg
):
Video Options
-vframes number (output)
Set the number of video frames to output. This is an obsolete alias
for "-frames:v", which you should use instead.
-r[:stream_specifier] fps (input/output,per-stream)
Set frame rate (Hz value, fraction or abbreviation).
[…]
-s[:stream_specifier] size (input/output,per-stream)
Set frame size.
Referring to fftools/ffmpeg_opt.c
:
/* video options */
{ "vframes", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_frames },
"set the number of video frames to output", "number" },
{ "r", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC |
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_rates) },
"set frame rate (Hz value, fraction or abbreviation)", "rate" },
{ "s", OPT_VIDEO | HAS_ARG | OPT_SUBTITLE | OPT_STRING | OPT_SPEC |
OPT_INPUT | OPT_OUTPUT
These lack OPT_AUDIO
.
How do I change the frame size/rate of my audio file?
I believe you are looking for the asetnsamples, atempo/rubberband, asetpts depending on what you want to do exactly.