[FFmpeg-user] ffmpeg reported fps different than actual file's

James Girotti james.girotti at gmail.com
Thu Aug 3 00:31:39 EEST 2017


On Tue, Aug 1, 2017 at 3:22 PM, tasos <tasoss at trigonongroup.com> wrote:

> Hello and thanks for replying.
> This is what ffprobe gives me(i should have mentioned it earlier)
>
>     Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(tv,
>> bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 5593 kb/s, 50 fps, 25 tbr,
>> 50 tbn, 50 tbc
>>
>
>
Is this the ffprobe output from the file or your DVB capture device? I
politely request you provide full command lines and output in the future.


>
> On 8/2/2017 1:01 AM, Simon Brown wrote:
>
>> On 1 August 2017 at 22:59, tasos <tasoss at trigonongroup.com> wrote:
>>
>> Hello.
>>> I get a video file with
>>>
>>> ffmpeg -y       -i /dev/dvb/adapter0/dvr0 -c:v copy -c:a copy   foo.avi
>>> This file is displayed  on vlc  as a 50fps video file.
>>>
>>> Input #0, mpegts, from '/dev/dvb/adapter0/dvr0':
>>>
>>>>    Duration: N/A, start: 7972.129344, bitrate: N/A
>>>>    Program 1
>>>>      Stream #0:0[0x6e]: Video: h264 (High) ([27][0][0][0] / 0x001B),
>>>> yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25
>>>> tbr, 90k tbn, 50 tbc
>>>>      Stream #0:1[0x78]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz,
>>>> stereo, s16p, 128 kb/s
>>>>      Stream #0:2[0x82]: Audio: mp3 ([3][0][0][0] / 0x0003), 0 channels,
>>>> s16p
>>>
>>>
Can you dump directly from the device to file without using ffmpeg? I.E.:

dd if=/dev/dvb/adapter0/dvr0 of=./foo.ts bs=1M count=100

Then analyze that file with ffprobe and VLC to see what the reported
frame-rate is.

If you can't dump directly from the device node to file, then try keeping
the same container/format (I add "-t 30" so that we only get 30 seconds of
video):

ffmpeg -i /dev/dvb/adapter0/dvr0 -t 30 -c copy -f mpegts ./foo.ts

Example FFPROBE output from a random interlaced video on my computer:

ffprobe -v error -select_streams v:0 -show_entries
stream=r_frame_rate,avg_frame_rate -of default=nw=1 ./JG-FOO.ts

r_frame_rate=60000/1001
avg_frame_rate=30000/1001

VLC reports a frame-rate of 30000/1001 for JG-FOO.ts


>>> My guess is that VLC is misreporting it, and it's 50 fields per second,
>>>
>> interlaced, and so FFMpeg is reporting it as 25 frames per second
>> correctly.
>>
>
Let's do an experiment; my hypothesis is that when it is muxed to AVI the
frame-rate is changed for some reason. Are half-frames/fields counted as
full-fields/frames???

Take JG-FOO.ts from above and mux to AVI:

ffmpeg -v info -ss 5:00 -i ./JG-FOO.ts -c copy -t 10 ./JG-FOO.avi
Input #0, mpegts, from 'JG-FOO.ts':
  Duration: 01:05:01.45, start: 1.400000, bitrate: 16261 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002),
yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions,
29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x101]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
5.1(side), fltp, 384 kb/s
Output #0, avi, to './JG-FOO.avi':
  Metadata:
    ISFT            : Lavf57.56.101
    Stream #0:0: Video: mpeg2video (Main) (mpg2 / 0x3267706D), yuv420p(tv,
top first), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 59.94 tbr,
59.94 tbn, 59.94 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), 384
kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[avi @ 0xbf2690] Non-monotonous DTS in output stream 0:0; previous: 127,
current: 127; changing to 128. This may result in incorrect timestamps in
the output file.
[avi @ 0xbf2690] Non-monotonous DTS in output stream 0:0; previous: 277,
current: 277; changing to 278. This may result in incorrect timestamps in
the output file.
[avi @ 0xbf2690] Non-monotonous DTS in output stream 0:0; previous: 427,
current: 427; changing to 428. This may result in incorrect timestamps in
the output file.
frame=  242 fps=0.0 q=-1.0 Lsize=    7660kB time=00:00:10.01
bitrate=6268.5kbits/s speed= 406x
video:7154kB audio:481kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.316611%

Now take a look at the frame-rates:

ffprobe -v error -select_streams v:0 -show_entries
stream=r_frame_rate,avg_frame_rate -of default=nw=1 ./JG-FOO.avi

r_frame_rate=60000/1001
avg_frame_rate=60000/1001

So my results show the frame rates have been doubled. Also, it shows
60000/1001 FPS using VLC. I think that's basically what you're seeing also

Try setting rate:

ffmpeg -v info -ss 5:00 -i ./JG-FOO.ts -c copy -t 10 -r 30000/1001
./JG-FOO-r30.avi
Input #0, mpegts, from 'JG-FOO.ts':
  Duration: 01:05:01.45, start: 1.400000, bitrate: 16261 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002),
yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions,
29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x101]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
5.1(side), fltp, 384 kb/s
Output #0, avi, to './JG-FOO-r30.avi':
  Metadata:
    ISFT            : Lavf57.56.101
    Stream #0:0: Video: mpeg2video (Main) (mpg2 / 0x3267706D), yuv420p(tv,
top first), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 29.97 fps, 59.94 tbr,
29.97 tbn, 29.97 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), 384
kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[avi @ 0x17986a0] Non-monotonous DTS in output stream 0:0; previous: 64,
current: 64; changing to 65. This may result in incorrect timestamps in the
output file.
[avi @ 0x17986a0] Non-monotonous DTS in output stream 0:0; previous: 139,
current: 139; changing to 140. This may result in incorrect timestamps in
the output file.
[avi @ 0x17986a0] Non-monotonous DTS in output stream 0:0; previous: 214,
current: 214; changing to 215. This may result in incorrect timestamps in
the output file.
frame=  242 fps=0.0 q=-1.0 Lsize=    7653kB time=00:00:10.04
bitrate=6241.9kbits/s speed= 401x
video:7154kB audio:481kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.222683%

And FFPROBE outputs:

ffprobe -v error -select_streams v:0 -show_entries
stream=r_frame_rate,avg_frame_rate -of default=nw=1 ./JG-FOO-r30.avi

r_frame_rate=30000/1001
avg_frame_rate=30000/1001


Using VLC JG-FOO-r30.avi has a frame-rate of 30000/1001. Interestingly, it
appears that both JG-FOO.avi and JG-FOO-r30.avi play at the same real-time
rate in VLC. Need to try a longer sample to really tell, but duration is
listed in VLC as 10 seconds for both.

Seems like there is a 4-year-old bug report about this:
https://trac.ffmpeg.org/ticket/2900

Next, I try muxing to Matroska (MKV). TLDR: both frame-rates are 30000/1001
WITHOUT specifying "-r 30000/1001". So MKV does not show the same behavior.

AVI is old (1992!) and MKV might not be universally supported (yet), maybe
MP4 would work. TLDR (not specifying rate):

ffprobe -v error -select_streams v:0 -show_entries
stream=r_frame_rate,avg_frame_rate -of default=nw=1 ./JG-FOO.mp4

r_frame_rate=60000/1001
avg_frame_rate=21780000/890389

Not sure what's going on with the frame-rate here, could the video be mixed
interlace/non-interlaced? Again, I'm not an expert on container/formats.
Let's look a little closer still:

for f in JG-FOO*; do echo $f; ffprobe -v error -select_streams v:0
-show_entries stream=time_base,codec_time_base,r_frame_rate,avg_frame_rate
-of default=nw=1 $f; done

JG-FOO.avi
codec_time_base=1001/60000
r_frame_rate=60000/1001
avg_frame_rate=60000/1001
time_base=1001/60000

JG-FOO.mkv
codec_time_base=1001/30000
r_frame_rate=30000/1001
avg_frame_rate=30000/1001
time_base=1/1000

JG-FOO.mp4
codec_time_base=890389/21780000
r_frame_rate=60000/1001
avg_frame_rate=21780000/890389
time_base=1/90000

JG-FOO-r30.avi
codec_time_base=1001/30000
r_frame_rate=30000/1001
avg_frame_rate=30000/1001
time_base=1001/30000

JG-FOO.ts
codec_time_base=1001/30000
r_frame_rate=60000/1001
avg_frame_rate=30000/1001
time_base=1/90000

It appears that JG-FOO.avi is 60000/1001 frames-per-second, but the time
base/codec time base is 1001/60000. Frame rate was doubled, but time base
was halved. So it all works out in the end! That's probably why they all
play the same speed in VLC as well.

If I can try to decode the relevant part of your ffprobe output "50 fps, 25
tbr, 50 tbn, 50 tbc":

50 frames per second
25 time base r(?)
50 time base n("time base")
50 time base c(odec time base)

It looks to me like you have the same situation. The frame-rate is doubled,
but you time base is halved. Could you run:

ffprobe -v error -select_streams v:0 -show_entries
stream=time_base,codec_time_base,r_frame_rate,avg_frame_rate -of
default=nw=1 ./foo.avi

Sorry for the long reply it ended up being written as I was doing it, but I
hope that helps you understand better what's happening! I've learned a lot
about ffprobe while doing this (so you helped me too!)

Best Regards,
-JG


More information about the ffmpeg-user mailing list