Opened 18 months ago

Closed 18 months ago

Last modified 18 months ago

#9990 closed defect (invalid)

FilterGraph + Map creates too many output streams, causes wrong output

Reported by: U. Artie Eoff Owned by:
Priority: important Component: ffmpeg
Version: git-master Keywords: regression
Cc: U. Artie Eoff Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

ffmpeg creates too many output streams and also dishonors vframes. MD5 output is wrong and YUV output is wrong. Also seeing lots of "dropping frame" messages. All input frames get decoded regardless of vframes setting.

This is a regression somewhere in the following commit window: https://github.com/ffmpeg/ffmpeg/compare/1af499cde0958264d4cc03f0ff6371c5ae8edbf4...7aa5ea237f84429a563c386f00fb035f48834273

Prior to this commit window, the YUV and MD5 are correct.

How to reproduce:

% ffmpeg -v verbose -i AUD_MW_E.264 -lavfi 'null' -c:v rawvideo \
 -pix_fmt yuv420p -fps_mode passthrough -autoscale 0 -vframes 4 \
 -y -f tee -map 0:v 'out.yuv|[f=md5]pipe:1'

ffmpeg version N-108846-g9bed814e1d44 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11 (GCC)
  configuration: --prefix=/home/uaeoff/Work/workspace/media/install --disable-static --enable-shared --enable-libdrm --enable-vaapi --enable-libmfx --disable-amf --disable-audiotoolbox --disable-cuda --disable-cuda-sdk --disable-cuvid --disable-d3d11va --disable-dxva2 --disable-libnpp --disable-mmal --disable-nvdec --disable-nvenc --disable-omx --disable-omx-rpi --disable-rkmpp --disable-v4l2-m2m --disable-vdpau --disable-videotoolbox --enable-gpl --enable-libx264 --enable-libx265
  libavutil      57. 39.101 / 57. 39.101
  libavcodec     59. 51.100 / 59. 51.100
  libavformat    59. 34.101 / 59. 34.101
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 49.101 /  8. 49.101
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
  libpostproc    56.  7.100 / 56.  7.100
[h264 @ 0x23dd080] Reinit context to 176x144, pix_fmt: yuv420p
Input #0, h264, from '/home/uaeoff/Work/workspace/media/src/otc-media/assets/bat/avc/AUD_MW_E.264':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: h264 (Constrained Baseline), 1 reference frame, yuv420p(progressive), 176x144, 25 fps, 25 tbr, 1200k tbn
Stream mapping:
  Stream #0:0 (h264) -> null:default (graph 0)
  null:default (graph 0) -> Stream #0:0 (rawvideo)
  Stream #0:0 -> #0:1 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[h264 @ 0x23f9b40] Reinit context to 176x144, pix_fmt: yuv420p
[graph 0 input from stream 0:0 @ 0x2633bc0] w:176 h:144 pixfmt:yuv420p tb:1/1200000 fr:25/1 sar:0/1
[graph 1 input from stream 0:0 @ 0x2640a40] w:176 h:144 pixfmt:yuv420p tb:1/1200000 fr:25/1 sar:0/1
[tee @ 0x24209c0] filename:'out.yuv' format:rawvideo
[tee @ 0x24209c0]     stream:0 codec:rawvideo type:video bsfs: null
[tee @ 0x24209c0]     stream:1 codec:rawvideo type:video bsfs: null
[tee @ 0x24209c0] filename:'pipe:1' format:md5
[tee @ 0x24209c0]     stream:0 codec:rawvideo type:video bsfs: null
[tee @ 0x24209c0]     stream:1 codec:rawvideo type:video bsfs: null
Output #0, tee, to 'out.yuv|[f=md5]pipe:1':
  Metadata:
    encoder         : Lavf59.34.101
  Stream #0:0: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuv420p(progressive), 176x144 (0x0), q=2-31, 7603 kb/s, 25 fps, 25 tbn (default)
    Metadata:
      encoder         : Lavc59.51.100 rawvideo
  Stream #0:1: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuv420p(progressive), 176x144 (0x0), q=2-31, 7603 kb/s, 25 fps, 25 tbn
    Metadata:
      encoder         : Lavc59.51.100 rawvideo
*** dropping frame 4 from stream 0 at ts 4  0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
*** dropping frame 4 from stream 0 at ts 5
*** dropping frame 4 from stream 0 at ts 6
*** dropping frame 4 from stream 0 at ts 7
*** dropping frame 4 from stream 0 at ts 8
*** dropping frame 4 from stream 0 at ts 9
*** dropping frame 4 from stream 0 at ts 10
*** dropping frame 4 from stream 0 at ts 11
*** dropping frame 4 from stream 0 at ts 12
*** dropping frame 4 from stream 0 at ts 13
*** dropping frame 4 from stream 0 at ts 14
*** dropping frame 4 from stream 0 at ts 15
*** dropping frame 4 from stream 0 at ts 16
*** dropping frame 4 from stream 0 at ts 17
*** dropping frame 4 from stream 0 at ts 18
*** dropping frame 4 from stream 0 at ts 19
*** dropping frame 4 from stream 0 at ts 20
*** dropping frame 4 from stream 0 at ts 21
*** dropping frame 4 from stream 0 at ts 22
*** dropping frame 4 from stream 0 at ts 23
*** dropping frame 4 from stream 0 at ts 24
*** dropping frame 4 from stream 0 at ts 25
*** dropping frame 4 from stream 0 at ts 26
*** dropping frame 4 from stream 0 at ts 27
*** dropping frame 4 from stream 0 at ts 28
*** dropping frame 4 from stream 0 at ts 29
*** dropping frame 4 from stream 0 at ts 30
*** dropping frame 4 from stream 0 at ts 31
*** dropping frame 4 from stream 0 at ts 32
*** dropping frame 4 from stream 0 at ts 33
*** dropping frame 4 from stream 0 at ts 34
*** dropping frame 4 from stream 0 at ts 35
*** dropping frame 4 from stream 0 at ts 36
*** dropping frame 4 from stream 0 at ts 37
*** dropping frame 4 from stream 0 at ts 38
*** dropping frame 4 from stream 0 at ts 39
*** dropping frame 4 from stream 0 at ts 40
*** dropping frame 4 from stream 0 at ts 41
*** dropping frame 4 from stream 0 at ts 42
*** dropping frame 4 from stream 0 at ts 43
*** dropping frame 4 from stream 0 at ts 44
*** dropping frame 4 from stream 0 at ts 45
*** dropping frame 4 from stream 0 at ts 46
*** dropping frame 4 from stream 0 at ts 47
*** dropping frame 4 from stream 0 at ts 48
*** dropping frame 4 from stream 0 at ts 49
*** dropping frame 4 from stream 0 at ts 50
*** dropping frame 4 from stream 0 at ts 51
*** dropping frame 4 from stream 0 at ts 52
*** dropping frame 4 from stream 0 at ts 53
*** dropping frame 4 from stream 0 at ts 54
*** dropping frame 4 from stream 0 at ts 55
*** dropping frame 4 from stream 0 at ts 56
*** dropping frame 4 from stream 0 at ts 57
*** dropping frame 4 from stream 0 at ts 58
*** dropping frame 4 from stream 0 at ts 59
*** dropping frame 4 from stream 0 at ts 60
*** dropping frame 4 from stream 0 at ts 61
*** dropping frame 4 from stream 0 at ts 62
*** dropping frame 4 from stream 0 at ts 63
*** dropping frame 4 from stream 0 at ts 64
*** dropping frame 4 from stream 0 at ts 65
*** dropping frame 4 from stream 0 at ts 66
*** dropping frame 4 from stream 0 at ts 67
*** dropping frame 4 from stream 0 at ts 68
*** dropping frame 4 from stream 0 at ts 69
*** dropping frame 4 from stream 0 at ts 70
*** dropping frame 4 from stream 0 at ts 71
*** dropping frame 4 from stream 0 at ts 72
*** dropping frame 4 from stream 0 at ts 73
*** dropping frame 4 from stream 0 at ts 74
*** dropping frame 4 from stream 0 at ts 75
*** dropping frame 4 from stream 0 at ts 76
*** dropping frame 4 from stream 0 at ts 77
*** dropping frame 4 from stream 0 at ts 78
*** dropping frame 4 from stream 0 at ts 79
*** dropping frame 4 from stream 0 at ts 80
*** dropping frame 4 from stream 0 at ts 81
*** dropping frame 4 from stream 0 at ts 82
*** dropping frame 4 from stream 0 at ts 83
*** dropping frame 4 from stream 0 at ts 84
*** dropping frame 4 from stream 0 at ts 85
*** dropping frame 4 from stream 0 at ts 86
*** dropping frame 4 from stream 0 at ts 87
*** dropping frame 4 from stream 0 at ts 88
EOF in input file 0
Terminating demuxer thread 0
*** dropping frame 4 from stream 0 at ts 89
*** dropping frame 4 from stream 0 at ts 90
*** dropping frame 4 from stream 0 at ts 91
*** dropping frame 4 from stream 0 at ts 92
*** dropping frame 4 from stream 0 at ts 93
*** dropping frame 4 from stream 0 at ts 94
*** dropping frame 4 from stream 0 at ts 95
*** dropping frame 4 from stream 0 at ts 96
*** dropping frame 4 from stream 0 at ts 97
*** dropping frame 4 from stream 0 at ts 98
*** dropping frame 4 from stream 0 at ts 99
No more output streams to write to, finishing.
All streams finished for output file #0
Terminating muxer thread 0
[AVIOContext @ 0x2c94f80] Statistics: 304128 bytes written, 0 seeks, 2 writeouts
MD5=c575f094f0b5d28dc9bd38f43b3bbb54
[AVIOContext @ 0x2c9f040] Statistics: 37 bytes written, 0 seeks, 1 writeouts
frame=    4 fps=0.0 q=-0.0 Lq=-0.0 size=N/A time=00:00:00.12 bitrate=N/A dup=0 drop=96 speed=14.3x    
video:297kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (/home/uaeoff/Work/workspace/media/src/otc-media/assets/bat/avc/AUD_MW_E.264):
  Input stream #0:0 (video): 100 packets read (54828 bytes); 100 frames decoded; 
  Total: 100 packets (54828 bytes) demuxed
Output file #0 (out.yuv|[f=md5]pipe:1):
  Output stream #0:0 (video): 4 frames encoded; 4 packets muxed (152064 bytes); 
  Output stream #0:1 (video): 4 frames encoded; 4 packets muxed (152064 bytes); 
  Total: 8 packets (304128 bytes) muxed
[AVIOContext @ 0x23e48c0] Statistics: 54828 bytes read, 0 seeks

Change History (4)

comment:1 by U. Artie Eoff, 18 months ago

Oddly, if I remove -lavfi option OR -map 0:v it works.

comment:2 by U. Artie Eoff, 18 months ago

Summary: Too many output streams causes wrong outputFilterGraph + Map creates too many output streams, causes wrong output

comment:3 by elenril, 18 months ago

Resolution: invalid
Status: newclosed

Two output streams in this case is not a bug, rather the previous behaviour was incorrect and against the documentation. From -filter_complex manual section:

Unlabeled outputs are added to the first output file.

Your commandline contains one explicit map and one unlabeled filtergraph output, which is supposed to result in two output video streams. Previously, the map would be silently ignored. After 0d821edb40d27848304a7354b1c64c2e30e00e7d it is honored as it should be. The commit message actually mentions the behavior change.

All input frames get decoded regardless of vframes setting.

This actually is a bug, but unrelated to the report. I will see about fixing it.

comment:4 by U. Artie Eoff, 18 months ago

Thanks for the explanation... that makes sense. I will omit the explicit map or just label my filtergraph.

Note: See TracTickets for help on using tickets.