Opened 3 months ago

Last modified 4 weeks ago

#11146 new defect

"concat" demuxer with resizing filters generated output of incomplete video

Reported by: degradox Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: concat
Cc: MasterQuestionable Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

% ffmpeg -y -f concat -safe 0 -i list.txt -map_metadata -1 -map 0:a -map 0:v -vf 'scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2' -c:a aac -b:a 128k -c:v libx264 -b:v 2554k -avoid_negative_ts make_zero -nostdin filter.mp4

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Attachments (1)

log.txt (484.6 KB ) - added by degradox 3 months ago.

Download all attachments as: .zip

Change History (24)

by degradox, 3 months ago

Attachment: log.txt added

comment:2 by MasterQuestionable, 2 months ago

Cc: MasterQuestionable added
Component: undeterminedavformat
Keywords: concat added
Version: unspecifiedgit-master

͏    Upload independent files independently.
͏    Notably, post content of "list.txt".

comment:3 by degradox, 2 months ago

list.txt:

file '1.ts'
file '2.ts'

in reply to:  2 comment:4 by degradox, 2 months ago

Replying to MasterQuestionable:

͏    Upload independent files independently.

Is there any reliable file hosting to upload big files? Do you want me to upload each file independently to MEGA?

comment:5 by MasterQuestionable, 2 months ago

͏    Post there the file listing so to reference.
͏    Few would download hundred MiB merely to get that...

͏    Also, what error did you have?
͏    And how is the output broken exactly?

Last edited 2 months ago by MasterQuestionable (previous) (diff)

comment:6 by degradox, 2 months ago

The way "filter.mp4" is broken, is that there's missing the video of the second file, shows instead a fixed image of the first file. The audio plays fine.
I've attached the log to this tracker for you to see.

comment:7 by degradox, 2 months ago

Summary: concat demuxer and resize filter generate broken output fileconcat demuxer and resize filter generate output file with video of the second part missing

comment:8 by MasterQuestionable, 2 months ago

Summary: concat demuxer and resize filter generate output file with video of the second part missing"concat" demuxer with resizing filters generated output of incomplete video

͏    So your big ZIP contains only "1.ts", "2.ts", "list.txt"?

͏    Excerpt:
[[

> ffmpeg -y -nostdin -f concat -safe 0 -i "list.txt" -map_metadata -1 -map 0:a -map 0:v -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(( (ow - iw)/2 )):(( (oh - ih)/2 ))" -c:a aac -b:a 128k -c:v libx264 -b:v 2554k -avoid_negative_ts 2 "filter.mp4"
ffmpeg version n7.0.2 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14.2.1 (GCC) 20240805
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libdvdnav --enable-libdvdread --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
Input #0, concat, from 'list.txt':
  Duration: N/A, start: 0.000000, bitrate: 130 kb/s
  Stream #0:0: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 130 kb/s
  Stream #0:1: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 90k tbn
  Stream #0:2: Data: timed_id3 (ID3  / 0x20334449)
Stream mapping:
  Stream #0:0 -> #0:0 (aac (native) -> aac (native))
  Stream #0:1 -> #0:1 (h264 (native) -> h264 (libx264))
[libx264] using SAR=1/1
[libx264] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX BMI2
[libx264] profile High, level 3.2, 4:2:0, 8-bit
[libx264] 264 - core 164 r3108 31e19f9 - H.264/MPEG-4 AVC codec - Copyleft 2003-2023 - 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=6 lookahead_threads=1 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=abr mbtree=1 bitrate=2554 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'filter.mp4':
  Metadata:
    encoder         : Lavf61.1.100
  Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
      Metadata:
        encoder         : Lavc61.3.100 aac
  Stream #0:1: Video: h264 (avc1 / 0x31637661), yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 2554 kb/s, 60 fps, 15360 tbn
      Metadata:
        encoder         : Lavc61.3.100 libx264
      Side data:
        cpb: bitrate max/min/avg: 0/0/2554000 buffer size: 0 vbv_delay: N/A
...
frame= 1569 fps= 47 q=26.0 size=    8448KiB time=00:00:26.11 bitrate=2649.9kbits/s dup=3 drop=0 speed=0.776x
[af#0:0] Reconfiguring filter graph because audio parameters changed to 44100 Hz, stereo, fltp
[h264] no frame!
frame= 1593 fps= 47 q=26.0 size=    8448KiB time=00:00:26.51 bitrate=2609.9kbits/s dup=3 drop=0 speed=0.776x
[concat] DTS -2066010 < 2613990 out of order
[mpegts] Packet corrupt (stream = 2, dts = 113936940).
[concat] Packet corrupt (stream = 2, dts = 3328050).
[h264] no frame!
[aac] Queue input is backward in time
[aost#0:0/aac] Non-monotonic DTS; previous: 1778619, current: -1100356; changing to 1778620. This may result in incorrect timestamps in the output file.
...
[h264] no frame!
[vist#0:1/h264] [dec:h264] Decoding error: Invalid data found when processing input
    Last message repeated 3 times
frame= 1611 fps= 40 q=26.0 size=    9984KiB time=N/A bitrate=N/A dup=3 drop=0 speed=N/A
frame= 1644 fps= 40 q=26.0 size=   10240KiB time=N/A bitrate=N/A dup=3 drop=0 speed=N/A
[out#0/mp4] video:8518KiB audio:1963KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.693580%
frame= 1654 fps= 41 q=-1.0 Lsize=   10553KiB time=00:00:27.53 bitrate=3140.0kbits/s dup=3 drop=0 speed=0.675x
[aac] Qavg: 1465.794
[libx264] frame I:7     Avg QP:14.67  size: 82031
[libx264] frame P:417   Avg QP:16.23  size: 13985
[libx264] frame B:1230  Avg QP:20.00  size:  1882
[libx264] consecutive B-frames:  0.8%  0.0%  0.0% 99.2%
[libx264] mb I  I16..4: 19.3% 50.1% 30.6%
[libx264] mb P  I16..4:  3.6%  9.4%  1.1%  P16..4: 30.1% 11.7%  7.2%  0.0%  0.0%    skip:36.9%
[libx264] mb B  I16..4:  0.3%  0.3%  0.0%  B16..8: 24.3%  1.4%  0.1%  direct: 1.3%  skip:72.4%  L0:51.0% L1:46.9% BI: 2.1%
[libx264] final ratefactor: 17.19
[libx264] 8x8 transform intra:63.3% inter:81.6%
[libx264] coded y,uvDC,uvAC intra: 37.0% 78.1% 46.1% inter: 5.1% 12.8% 2.0%
[libx264] i16 v,h,dc,p: 22% 26% 18% 33%
[libx264] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 19% 41%  4%  4%  3%  3%  2%  3%
[libx264] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 25% 23%  3%  4%  3%  3%  2%  2%
[libx264] i8c dc,h,v,p: 30% 49%  6% 15%
[libx264] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264] ref P L0: 66.1%  4.4% 20.6%  8.9%
[libx264] ref B L0: 87.7%  9.6%  2.7%
[libx264] ref B L1: 94.8%  5.2%
[libx264] kb/s:2530.95

]]
͏    See also:
͏    https://trac.ffmpeg.org/ticket/11044#comment:3
͏    https://trac.ffmpeg.org/ticket/11126#comment:3
͏    https://trac.ffmpeg.org/ticket/11052#comment:15

͏    Audio related messages seem to create bunch noise.
͏    If it doesn't matter: remove outright.

comment:9 by MasterQuestionable, 2 months ago

͏    See also: https://trac.ffmpeg.org/ticket/11142#comment:3
͏    "concat" likely has similar limitations.

comment:10 by degradox, 2 months ago

@MasterQuestionable Sorry if the files are so big, but I have no clue how to get small samples that still reproduce the issue. If you could help do it would be great, because I've found so many bugs, but all of them are with big files.

comment:11 by MasterQuestionable, 2 months ago

͏    Trace my links: all contained various relevant.

͏    Foremost, try input only the video: "-map v".
͏    Reporting the input characteristics using my `ffprobe` examples shall also help.

͏    If it bothers, you may as well wait until I find time to interpret your files.

comment:12 by Cigaes, 2 months ago

Note that you should not be using the concat demuxer since you are not using -c copy anywhere.

comment:13 by MasterQuestionable, 2 months ago

͏    I believe there's no logical connection..?
͏    Is "concat" locked to support only stream copy..?

in reply to:  12 ; comment:14 by degradox, 2 months ago

Replying to Cigaes:

Note that you should not be using the concat demuxer since you are not using -c copy anywhere.

I'm re-encoding as the wiki says:

Then you can stream copy or re-encode your files:

https://trac.ffmpeg.org/wiki/Concatenate#demuxer

So either the wiki is wrong or you are wrong.

comment:15 by MasterQuestionable, 2 months ago

͏    Who knows... Maybe FFmpeg is wrong?
͏    https://trac.ffmpeg.org/ticket/11080#comment:76

͏    Wish it not, decompose apart right mid-air...

in reply to:  14 ; comment:16 by Cigaes, 2 months ago

Replying to degradox:

Note that you should not be using the concat demuxer
Then you can stream copy or re-encode your files:

can ≠ should

in reply to:  16 comment:17 by MasterQuestionable, 2 months ago

͏    Would you explain the appropriate alternatives..?

comment:18 by degradox, 2 months ago

The wiki must not say "can" if it's not designed to work. It's a technical article. I already know I can do whatever.

in reply to:  18 comment:19 by MasterQuestionable, 2 months ago

͏    People "can" write everything in one-liner if they prefer as for whether it "should" it's another question...

comment:20 by degradox, 2 months ago

So this is the official documentation and thus the only reliable source of information?
https://www.ffmpeg.org/ffmpeg-all.html

Maybe the concat filter should work?

comment:21 by MasterQuestionable, 2 months ago

͏    No source can be perfectly reliable.
͏    Blind trust only end in woes.

͏    Interesting alternative:
͏    https://ffmpeg.org/ffmpeg-filters.html#concat
͏    ; but for procedure reasons won't handle "-c copy".

͏    I wonder if it would be possible to utilize "-map"..?
͏    It appears many "concat" are mere simple join.
͏    So several "-map" piled together may then mean... exactly same things?
͏    E.g. `-i "0" -i "1" -map 1 -map 0` ... seemed working?
[ ^
͏    Likely it works. Mostly.
͏    But I haven't much tested. ]

Last edited 4 weeks ago by MasterQuestionable (previous) (diff)

comment:22 by degradox, 2 months ago

There are 3 "types" of concat:

According to wiki there are 3 types of concatenation:

  • concat demuxer
  • concat protocol
  • concat filter

but according to documentation there's only one concat: 18.9 concat, and basically is for files that have the same type of stuff:

All segments must have the same number of streams of each type, and that will also be the number of streams at output.

Can somebody with enough knowledge sort this out? Most ffmpeg users that rely on documentation are so confused, everything is kinda fuzzy and there no clear examples.

comment:23 by MasterQuestionable, 2 months ago

͏    I would probably only try to ascertain the single best way for all purposes.
͏    The rest... rot in peace.

Note: See TracTickets for help on using tickets.