libavfilter: fps ignored in ffmpeg command line
Hi, The filter fps seems ignored in the ffmpeg command line. This is the scenario: $ ffmpeg -i input.avi -vfilters fps=30 -y output.avi FFmpeg version SVN-r11338, Copyright (c) 2000-2007 Fabrice Bellard, et al. configuration: --disable-static --enable-shared --enable-gpl --enable-swscaler --enable-pthreads --enable-liba52 --enable-avisynth --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libamr_nb --enable-libamr_wb --cpu=prescott --enable-avfilter --extra-cflags=-DX_DISPLAY_MISSING --build-suffix=-SVN libavutil version: 49.6.0 libavcodec version: 51.49.0 libavformat version: 52.3.0 built on Dec 28 2007 12:22:39, gcc: 4.2.2 Input #0, avi, from 'input.avi': Duration: 00:00:20.2, start: 0.000000, bitrate: 30349 kb/s Stream #0.0: Video: dvvideo, yuv420p, 720x576 [PAR 0:1 DAR 0:1], 25.00 tb(r) Stream #0.1: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s Output #0, avi, to 'output.avi': Stream #0.0: Video: mpeg4, yuv420p, 720x576 [PAR 0:1 DAR 0:1], q=2-31, 200 kb/s, 25.00 tb(c) Stream #0.1: Audio: mp2, 48000 Hz, stereo, 64 kb/s Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1 Press [q] to stop encoding frame= 445 fps= 61 q=25.1 Lsize= 966kB time=17.8 bitrate= 444.5kbits/s video:275kB audio:158kB global headers:0kB muxing overhead 123.094707% The input and output AVI have the same 25 fps. Regards, Víctor
Hi Víctor Paesa wrote:
Hi,
The filter fps seems ignored in the ffmpeg command line. This is the scenario:
[...]
Input #0, avi, from 'input.avi': Duration: 00:00:20.2, start: 0.000000, bitrate: 30349 kb/s Stream #0.0: Video: dvvideo, yuv420p, 720x576 [PAR 0:1 DAR 0:1], 25.00 tb(r) Stream #0.1: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s Output #0, avi, to 'output.avi': Stream #0.0: Video: mpeg4, yuv420p, 720x576 [PAR 0:1 DAR 0:1], q=2-31, 200 kb/s, 25.00 tb(c) Stream #0.1: Audio: mp2, 48000 Hz, stereo, 64 kb/s
[...]
The input and output AVI have the same 25 fps.
I'm not really sure if the filter is supposed to change this. The filter infrastructure is designed to get pictures+timestamps as input and give pictures+timestamps as output. I'd say setting the output framerate is beyond filtering. For example, ffmpeg -i input.avi -vfilters fps=1 -r 25 -y output.avi should give a 25 fps output but with a different frame every 1 second. But indeed I get a crash with your command line and vf_fps.c do not seems to handle a rate greater than the input rate. I'll have a look into it... -Vitor
Hi, On Dec 31, 2007 9:04 AM, Vitor Sessak <vitor1001@gmail.com> wrote:
Hi
Víctor Paesa wrote:
Hi,
The filter fps seems ignored in the ffmpeg command line. This is the scenario:
[...]
Input #0, avi, from 'input.avi': Duration: 00:00:20.2, start: 0.000000, bitrate: 30349 kb/s Stream #0.0: Video: dvvideo, yuv420p, 720x576 [PAR 0:1 DAR 0:1], 25.00 tb(r) Stream #0.1: Audio: pcm_s16le, 48000 Hz, stereo, 1536 kb/s Output #0, avi, to 'output.avi': Stream #0.0: Video: mpeg4, yuv420p, 720x576 [PAR 0:1 DAR 0:1], q=2-31, 200 kb/s, 25.00 tb(c) Stream #0.1: Audio: mp2, 48000 Hz, stereo, 64 kb/s
[...]
The input and output AVI have the same 25 fps.
I'm not really sure if the filter is supposed to change this. The filter infrastructure is designed to get pictures+timestamps as input and give pictures+timestamps as output. I'd say setting the output framerate is beyond filtering. For example,
ffmpeg -i input.avi -vfilters fps=1 -r 25 -y output.avi
should give a 25 fps output but with a different frame every 1 second. But indeed I get a crash with your command line and vf_fps.c do not seems to handle a rate greater than the input rate. I'll have a look into it...
I feel the libavfilter framework should support frame rate change as that is listed as part of the wishes/ideas for libavfilter in: http://wiki.multimedia.cx/index.php?title=FFmpeg_Summer_Of_Code_2007 Of course, updating the stated scope, documenting the intention of vf_fps.c, or adding an entry to the TODO list are also valid ways of fixing the issue ;-) Regards, Víctor
Hi Víctor Paesa wrote:
Hi,
On Dec 31, 2007 9:04 AM, Vitor Sessak <vitor1001@gmail.com> wrote:
Víctor Paesa wrote:
Hi,
The filter fps seems ignored in the ffmpeg command line.
[...]
The input and output AVI have the same 25 fps. I'm not really sure if the filter is supposed to change this. The filter infrastructure is designed to get pictures+timestamps as input and give pictures+timestamps as output. I'd say setting the output framerate is beyond filtering. For example,
ffmpeg -i input.avi -vfilters fps=1 -r 25 -y output.avi
should give a 25 fps output but with a different frame every 1 second. But indeed I get a crash with your command line and vf_fps.c do not seems to handle a rate greater than the input rate. I'll have a look into it...
I feel the libavfilter framework should support frame rate change as that is listed as part of the wishes/ideas for libavfilter in: http://wiki.multimedia.cx/index.php?title=FFmpeg_Summer_Of_Code_2007
Actually the filter framework does support frame rate change. If you do ffmpeg -i input.avi -vfilters fps=1 output.avi where input.avi has a rate of 25 fps, you'll have Input -> 25 fps Filtered input -> 1 fps Output -> 25 fps The only problem is that the output rate (set in ffmpeg.c) is equal by default to the unfiltered input rate. The filter does its job, but I agree it would be more reasonable to set the default output rate to the filtered input rate. That would unfortunately have a small problem: imagine for example overlaying a 20 fps and a 30 fps movie together. The filter output will not have a fixed frame rate, so creating and setting a frame_rate field in the AVFilterLink structure will not make a lot of sense. A second problem would be to allow broken filters to set frame_rate to a value not coherent with the interval between timestamps. Bobby, Michael, what is your opinion? -Vitor
Hi, On Dec 31, 2007 12:03 PM, Vitor Sessak <vitor1001@gmail.com> wrote:
Hi
Víctor Paesa wrote:
Hi,
On Dec 31, 2007 9:04 AM, Vitor Sessak <vitor1001@gmail.com> wrote:
Víctor Paesa wrote:
Hi,
The filter fps seems ignored in the ffmpeg command line.
[...]
The input and output AVI have the same 25 fps. I'm not really sure if the filter is supposed to change this. The filter infrastructure is designed to get pictures+timestamps as input and give pictures+timestamps as output. I'd say setting the output framerate is beyond filtering. For example,
ffmpeg -i input.avi -vfilters fps=1 -r 25 -y output.avi
should give a 25 fps output but with a different frame every 1 second. But indeed I get a crash with your command line and vf_fps.c do not seems to handle a rate greater than the input rate. I'll have a look into it...
I feel the libavfilter framework should support frame rate change as that is listed as part of the wishes/ideas for libavfilter in: http://wiki.multimedia.cx/index.php?title=FFmpeg_Summer_Of_Code_2007
Actually the filter framework does support frame rate change. If you do
ffmpeg -i input.avi -vfilters fps=1 output.avi
where input.avi has a rate of 25 fps, you'll have
Input -> 25 fps Filtered input -> 1 fps Output -> 25 fps
The only problem is that the output rate (set in ffmpeg.c) is equal by default to the unfiltered input rate. The filter does its job, but I agree it would be more reasonable to set the default output rate to the filtered input rate. That would unfortunately have a small problem: imagine for example overlaying a 20 fps and a 30 fps movie together. The filter output will not have a fixed frame rate, so creating and setting a frame_rate field in the AVFilterLink structure will not make a lot of sense. A second problem would be to allow broken filters to set frame_rate to a value not coherent with the interval between timestamps.
Yeah, I was thinking of patching vf_overlay.c as attached:
Bobby, Michael, what is your opinion?
Regards, Víctor
Hi Víctor Paesa wrote:
Hi,
On Dec 31, 2007 12:03 PM, Vitor Sessak <vitor1001@gmail.com> wrote:
Víctor Paesa wrote:
On Dec 31, 2007 9:04 AM, Vitor Sessak <vitor1001@gmail.com> wrote:
Víctor Paesa wrote:
Hi,
The filter fps seems ignored in the ffmpeg command line.
[...]
If you do
ffmpeg -i input.avi -vfilters fps=1 output.avi
where input.avi has a rate of 25 fps, you'll have
Input -> 25 fps Filtered input -> 1 fps Output -> 25 fps
The only problem is that the output rate (set in ffmpeg.c) is equal by default to the unfiltered input rate. The filter does its job, but I agree it would be more reasonable to set the default output rate to the filtered input rate. That would unfortunately have a small problem: imagine for example overlaying a 20 fps and a 30 fps movie together. The filter output will not have a fixed frame rate, so creating and setting a frame_rate field in the AVFilterLink structure will not make a lot of sense. A second problem would be to allow broken filters to set frame_rate to a value not coherent with the interval between timestamps.
Yeah, I was thinking of patching vf_overlay.c as attached:
I think that maintaining a constant frame rate could be handled by the filter framework instead of having to be handled by each filter. I've thought a bit more about the subject and have the following idea: 1- add a field named suggested_rate to AVFilterLink that would be the suggested frame rate of the output. 2- initialize this field by default by the input frame rate. 3- vf_fps will set it to its nominal value and vf_overlay will set it either as the highest one, the image rate or the subimage rate 4- in ffmpeg.c, the vf_fps filter will _always_ be inserted in the end of the filter chain (it's fast). It'll be given either the framerate specified by the -r command line parameter or if none specified by the value of suggested_rate in the end of the chain. What do you think? -Vitor
On Mon, 31 Dec 2007 17:51:48 +0100 Vitor Sessak <vitor1001@gmail.com> wrote:
Hi
Víctor Paesa wrote:
Hi,
On Dec 31, 2007 12:03 PM, Vitor Sessak <vitor1001@gmail.com> wrote:
Víctor Paesa wrote:
On Dec 31, 2007 9:04 AM, Vitor Sessak <vitor1001@gmail.com> wrote:
Víctor Paesa wrote:
Hi,
The filter fps seems ignored in the ffmpeg command line.
[...]
If you do
ffmpeg -i input.avi -vfilters fps=1 output.avi
where input.avi has a rate of 25 fps, you'll have
Input -> 25 fps Filtered input -> 1 fps Output -> 25 fps
The only problem is that the output rate (set in ffmpeg.c) is equal by default to the unfiltered input rate. The filter does its job, but I agree it would be more reasonable to set the default output rate to the filtered input rate. That would unfortunately have a small problem: imagine for example overlaying a 20 fps and a 30 fps movie together. The filter output will not have a fixed frame rate, so creating and setting a frame_rate field in the AVFilterLink structure will not make a lot of sense. A second problem would be to allow broken filters to set frame_rate to a value not coherent with the interval between timestamps.
Yeah, I was thinking of patching vf_overlay.c as attached:
I think that maintaining a constant frame rate could be handled by the filter framework instead of having to be handled by each filter.
I've thought a bit more about the subject and have the following idea:
1- add a field named suggested_rate to AVFilterLink that would be the suggested frame rate of the output. 2- initialize this field by default by the input frame rate. 3- vf_fps will set it to its nominal value and vf_overlay will set it either as the highest one, the image rate or the subimage rate 4- in ffmpeg.c, the vf_fps filter will _always_ be inserted in the end of the filter chain (it's fast). It'll be given either the framerate specified by the -r command line parameter or if none specified by the value of suggested_rate in the end of the chain.
What do you think?
What happens for variable framerate inputs? What framerates do the demuxers report for such files? Do (some subset of) the muxers support variable framerate outputs? This would make variable framerate outputs impossible...
-Vitor
-- Bobby Bingham Never trust atoms. Or anything made of atoms. このメールは再利用されたバイトでできている。
Hi Bobby Bingham wrote:
On Mon, 31 Dec 2007 17:51:48 +0100 Vitor Sessak <vitor1001@gmail.com> wrote:
Víctor Paesa wrote:
On Dec 31, 2007 12:03 PM, Vitor Sessak <vitor1001@gmail.com> wrote:
Víctor Paesa wrote:
On Dec 31, 2007 9:04 AM, Vitor Sessak <vitor1001@gmail.com> wrote:
Víctor Paesa wrote: > Hi, > > The filter fps seems ignored in the ffmpeg command line. [...]
If you do
ffmpeg -i input.avi -vfilters fps=1 output.avi
where input.avi has a rate of 25 fps, you'll have
Input -> 25 fps Filtered input -> 1 fps Output -> 25 fps
The only problem is that the output rate (set in ffmpeg.c) is equal by default to the unfiltered input rate. The filter does its job, but I agree it would be more reasonable to set the default output rate to the filtered input rate. That would unfortunately have a small problem: imagine for example overlaying a 20 fps and a 30 fps movie together. The filter output will not have a fixed frame rate, so creating and setting a frame_rate field in the AVFilterLink structure will not make a lot of sense. A second problem would be to allow broken filters to set frame_rate to a value not coherent with the interval between timestamps. Yeah, I was thinking of patching vf_overlay.c as attached: I think that maintaining a constant frame rate could be handled by the filter framework instead of having to be handled by each filter.
I've thought a bit more about the subject and have the following idea:
1- add a field named suggested_rate to AVFilterLink that would be the suggested frame rate of the output. 2- initialize this field by default by the input frame rate. 3- vf_fps will set it to its nominal value and vf_overlay will set it either as the highest one, the image rate or the subimage rate 4- in ffmpeg.c, the vf_fps filter will _always_ be inserted in the end of the filter chain (it's fast). It'll be given either the framerate specified by the -r command line parameter or if none specified by the value of suggested_rate in the end of the chain.
What do you think?
What happens for variable framerate inputs? What framerates do the demuxers report for such files?
Do (some subset of) the muxers support variable framerate outputs? This would make variable framerate outputs impossible...
This is easy to fix. Just skip step 4 (automaticaly adding vf_fps to the filter chain) if the muxer supports variable framerate... -Vitor
On Sun, Jan 01, 2006 at 11:04:56AM -0500, Bobby Bingham wrote:
On Mon, 31 Dec 2007 17:51:48 +0100 Vitor Sessak <vitor1001@gmail.com> wrote:
Hi
Víctor Paesa wrote:
Hi,
On Dec 31, 2007 12:03 PM, Vitor Sessak <vitor1001@gmail.com> wrote:
Víctor Paesa wrote:
On Dec 31, 2007 9:04 AM, Vitor Sessak <vitor1001@gmail.com> wrote:
Víctor Paesa wrote: > Hi, > > The filter fps seems ignored in the ffmpeg command line.
[...]
If you do
ffmpeg -i input.avi -vfilters fps=1 output.avi
where input.avi has a rate of 25 fps, you'll have
Input -> 25 fps Filtered input -> 1 fps Output -> 25 fps
The only problem is that the output rate (set in ffmpeg.c) is equal by default to the unfiltered input rate. The filter does its job, but I agree it would be more reasonable to set the default output rate to the filtered input rate. That would unfortunately have a small problem: imagine for example overlaying a 20 fps and a 30 fps movie together. The filter output will not have a fixed frame rate, so creating and setting a frame_rate field in the AVFilterLink structure will not make a lot of sense. A second problem would be to allow broken filters to set frame_rate to a value not coherent with the interval between timestamps.
Yeah, I was thinking of patching vf_overlay.c as attached:
I think that maintaining a constant frame rate could be handled by the filter framework instead of having to be handled by each filter.
I've thought a bit more about the subject and have the following idea:
1- add a field named suggested_rate to AVFilterLink that would be the suggested frame rate of the output. 2- initialize this field by default by the input frame rate. 3- vf_fps will set it to its nominal value and vf_overlay will set it either as the highest one, the image rate or the subimage rate 4- in ffmpeg.c, the vf_fps filter will _always_ be inserted in the end of the filter chain (it's fast). It'll be given either the framerate specified by the -r command line parameter or if none specified by the value of suggested_rate in the end of the chain.
What do you think?
What happens for variable framerate inputs? What framerates do the demuxers report for such files?
which of the many frame rate fields do you mean? :) AVStream.time_base will always be something in which all timestamps can be repressented accurately AVStream.r_frame_rate is just a guess and will generally only take the first few frames into account. (But a demuxer could override this if it has more reliable information), though its important to keep in mind that this is not a average frame rate but rather the least common multiple of all framerates AVCodecContext.time_base is the equivalent of AVStream.time_base, just this time for the decoder instead of the demuxer
Do (some subset of) the muxers support variable framerate outputs? This would make variable framerate outputs impossible...
no muxer allows changing the time_base, and most will be happy with arbitrary holes in the timestamps, that is they generally dont require 1,2,3,4,5 but will happily work with 1,5000,80000,100000,110000,123456 as timestamps though some like avi will be somewhat inefficient with 1000fps and large holes ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable
participants (4)
-
Bobby Bingham -
Michael Niedermayer -
Vitor Sessak -
Víctor Paesa