Opened 6 years ago

Closed 5 years ago

#1051 closed defect (fixed)

ffmpeg with -f lavfi and movie leads to error messages and videos with 1 fps unless a larger probesize is specified

Reported by: ls Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: rawvideo probesize
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes

Description

The problem does not occur for alle video formats but for example for mts and mpeg2video with high resolutions (full hd). ffmpeg and ffplay can decode the video without problems if not using lavfi+movie. (I can reproduce the problem also with mpegts, even if they were encoded by ffmpeg itself before)

Sample:
http://www.techfak.uni-bielefeld.de/~lschilli/ffmpeg/sync/camera-raw.mp4

$ ffmpeg -f lavfi -i movie=camera-raw.mp4 out.mp4

ffmpeg version N-32994-g8fbf825 Copyright (c) 2000-2012 the FFmpeg developers
  built on Mar 10 2012 10:57:21 with gcc 4.6.1
  configuration: --prefix=/home/ls/ffmpeg --enable-shared --disable-static --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-sram --cpu=core2 --enable-hwaccel=h264_vaapi --enable-hwaccel=mpeg2_vaapi --enable-hwaccel=mpeg4_vaapi --enable-libfaac --enable-x11grab --disable-ffserver --enable-libvpx --enable-libvorbis --enable-libass --enable-libfreetype
  libavutil      51. 42.100 / 51. 42.100
  libavcodec     54. 10.100 / 54. 10.100
  libavformat    54.  2.100 / 54.  2.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 64.101 /  2. 64.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  7.100 /  0.  7.100
  libpostproc    52.  0.100 / 52.  0.100
[movie @ 0x82b020] seek_point:0 format_name:(null) file_name:/home/ls/camera-raw.mp4 stream_index:0
[mpeg2video @ 0x8324c0] warning: first frame is no keyframe
    Last message repeated 1 times
[lavfi @ 0x82a3e0] Estimating duration from bitrate, this may be inaccurate
Input #0, lavfi, from 'movie=/home/ls/camera-raw.mp4':
  Duration: N/A, start: 0.040000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 1 tbr, 25k tbn, 25k tbc
File 'out.mp4' already exists. Overwrite ? [y/N] w:1920 h:1080 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
[libx264 @ 0x82dda0] using SAR=1/1
[libx264 @ 0x82dda0] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 @ 0x82dda0] profile High, level 4.0
[libx264 @ 0x82dda0] 264 - core 120 r0+2 01f7a33 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=1 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf54.2.100
    Stream #0:0: Video: h264 (![0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 1 tbn, 1 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx264)
Press [q] to stop, [?] for help
DTS 4000, next:2120000 st:0 invalid droping
DTS 30000, next:3120000 st:0 invalid droping
DTS 6000, next:4120000 st:0 invalid droping
DTS 32000, next:5120000 st:0 invalid droping
DTS 8000, next:6120000 st:0 invalid droping
DTS 34000, next:7120000 st:0 invalid droping
DTS 10000, next:8120000 st:0 invalid droping
DTS 36000, next:9120000 st:0 invalid droping

ffplay exhibits the same problem:

ffplay -f lavfi movie=camera-raw.mp4

If the video is downscaled below a certain size the problem disappears:

$ ffmpeg -f lavfi -i movie=camera-raw.mp4,scale=1280:720 out.mp4

ffmpeg version N-32994-g8fbf825 Copyright (c) 2000-2012 the FFmpeg developers
  built on Mar 10 2012 10:57:21 with gcc 4.6.1
  configuration: --prefix=/home/ls/ffmpeg --enable-shared --disable-static --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-sram --cpu=core2 --enable-hwaccel=h264_vaapi --enable-hwaccel=mpeg2_vaapi --enable-hwaccel=mpeg4_vaapi --enable-libfaac --enable-x11grab --disable-ffserver --enable-libvpx --enable-libvorbis --enable-libass --enable-libfreetype
  libavutil      51. 42.100 / 51. 42.100
  libavcodec     54. 10.100 / 54. 10.100
  libavformat    54.  2.100 / 54.  2.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 64.101 /  2. 64.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  7.100 /  0.  7.100
  libpostproc    52.  0.100 / 52.  0.100
[movie @ 0x2240060] seek_point:0 format_name:(null) file_name:/home/ls/camera-raw.mp4 stream_index:0
[scale @ 0x2241d40] w:1920 h:1080 fmt:yuv420p -> w:1280 h:720 fmt:yuv420p flags:0x2
[mpeg2video @ 0x2247500] warning: first frame is no keyframe
    Last message repeated 1 times
[lavfi @ 0x223f3e0] Estimating duration from bitrate, this may be inaccurate
Input #0, lavfi, from 'movie=/home/ls/camera-raw.mp4,scale=1280:720':
  Duration: N/A, start: 0.040000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25k tbn, 25k tbc
File 'out.mp4' already exists. Overwrite ? [y/N] w:1280 h:720 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
[libx264 @ 0x229e560] using SAR=1/1
[libx264 @ 0x229e560] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 @ 0x229e560] profile High, level 3.1
[libx264 @ 0x229e560] 264 - core 120 r0+2 01f7a33 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    encoder         : Lavf54.2.100
    Stream #0:0: Video: h264 (![0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx264)
Press [q] to stop, [?] for help
frame=   34 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s    
frame=   50 fps= 47 q=28.0 size=      42kB time=00:00:00.04 bitrate=8605.2kbits/s    
frame=   60 fps= 37 q=28.0 size=      84kB time=00:00:00.44 bitrate=1564.8kbits/s    
frame=   71 fps= 33 q=28.0 size=     120kB time=00:00:00.88 bitrate=1114.1kbits/s 

These calls work fine:

ffmpeg -i camera-raw.mp4 out.mp4
ffplay camera-raw.mp4

Change History (9)

comment:1 Changed 6 years ago by ls

There seems to be a problem with framerate estimation and lavfi.

Working:

$ ffplay -f lavfi movie=camera-raw.mp4,scale=-1:968
[...]
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1721x968 [SAR 15488:15489 DAR 16:9], 25 tbr, 25k tbn, 25k tbc

Only 1 fps:

$ ffplay -f lavfi movie=camera-raw.mp4,scale=-1:969
[...]
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1723x969 [SAR 5168:5169 DAR 16:9], 1 tbr, 25k tbn, 25k tbc

A small change in frame height changes the framerate estimated to 1 fps.

comment:2 Changed 6 years ago by cehoyos

  • Component changed from avdevice to undetermined
  • Reproduced by developer set
  • Status changed from new to open

comment:3 Changed 6 years ago by ls

This bug can be closed. In the current ffmpeg version git-2012-04-17-096231d my samples work fine.

comment:4 Changed 6 years ago by cehoyos

The following two commands still produce very different files for me, the second drops 95% of all frames:
$ ffmpeg -i camera-raw.mp4 -qscale 2 -strict experimental out.mp4
$ ffmpeg -f lavfi -i movie=camera-raw.mp4 -qscale 2 -strict experimental out.mp4

Or is this intended?

comment:5 Changed 6 years ago by ls

Yes you are right, I was testing to shallow.

ffplay -f lavfi movie=camera-raw.mp4

produced the right result for me. The problem with ffmpeg persists.

comment:6 Changed 6 years ago by Cigaes

  • Analyzed by developer set
  • Keywords rawvideo probesize added

The problem is that your frames are large: full-HD. As -f lavfi outputs rawvideo, each packet takes 3110400 bytes: the default probesize value, 5000000, only allows to analyze one frame, which is not enough to determine the framerate.

Adding -probesize 6220801 (two frames, plus 1 because for some reason the comparison is exclusive) or more solves the problem.

Of course, the default value of probesize should be enough to work by default. I am not sure what the best way to solve the problem is, so the bug stays open.

But for now you have a workaround.

comment:7 Changed 6 years ago by ls

Ok I understand. Tested the workaround and it seems fine. Thanks.

comment:8 Changed 6 years ago by michael

  • Summary changed from ffmpeg with -f lavfi and movie leads to error messages and videos with 1 fps to ffmpeg with -f lavfi and movie leads to error messages and videos with 1 fps unless a larger probesize is specified

comment:9 Changed 5 years ago by michael

  • Resolution set to fixed
  • Status changed from open to closed
Note: See TracTickets for help on using tickets.