#10142 closed defect (fixed)

scdet filter not logging some frames score

Reported by: colemarc Owned by:
Priority: minor Component: avfilter
Version: 5.1.2 Keywords: scdet
Cc: colemarc Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by colemarc)

ffmpeg version 5.1.1-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2022 the FFmpeg developers

1000.mkv has exactly 1000 frames.
scdet filter logs scores for only 866 frames.

$ ffmpeg -nostdin -nostats -i 1000.mkv -map 0:v -filter:v "scdet=threshold=0:sc_pass=0,metadata=mode=print:key=lavfi.scd.score,showinfo=checksum=0" -f null - 2>&1 | grep iskey | wc -l
1000

$ ffmpeg -nostdin -nostats -i 1000.mkv -map 0:v -filter:v "scdet=threshold=0:sc_pass=0,metadata=mode=print:key=lavfi.scd.score,showinfo=checksum=0" -f null - 2>&1 | grep scdet | wc -l
866

However the scdet filter forwards all 1000 frames and sets frame metadata for each of them.

$ ffmpeg -nostdin -nostats -i 1000.mkv -map 0:v -filter:v "scdet=threshold=0:sc_pass=0,metadata=mode=print:key=lavfi.scd.score,showinfo=checksum=0" -f null - 2>&1 | grep 'Parsed_metadata_1.*lavfi.scd.score' | wc -l
1000

All the frames missed in the scdet log have lavfi.scd.score=0.000, but a few frames with lavfi.scd.score=0.000 get logged.

1000.mkv

Change History (6)

comment:1 by colemarc, 22 months ago

Description: modified (diff)
Status: newopen

comment:2 by Elon Musk, 22 months ago

The filter outputs score twice in your case, one with metadata filter, and another via info log of filter if score is > of threshold.

So score is 0 in those cases that prints item only once.
So I bet that input have not 1000 frames.

comment:3 by colemarc, 22 months ago

Sorry but the video does indeed have 1000 frames, and scdet logs only 866 of them.
I have attached the video file in the original post.

comment:4 by Elon Musk, 22 months ago

This have been fixed in master version.

Could you confirm?

in reply to:  4 comment:5 by colemarc, 22 months ago

Replying to Elon Musk:

This have been fixed in master version.

Could you confirm?

I can confirm that my particular issue is fixed, but I believe that commit 07485a697552641609df73fd411de1ea964f1ef2 introduced a discrepancy, because now the filter logs when score is greater than or equal to threshold (see line 166), but (if sc_pass==1) it forwards the frame only if the score is strictly greater than threshold (see line 173).
This behaviour is probably unexpected since it does not conform to documentation.

I suggest correcting line 173 as well.

https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/07485a697552641609df73fd411de1ea964f1ef2:/libavfilter/vf_scdet.c#l166
https://ffmpeg.org/ffmpeg-filters.html#scdet-1

comment:6 by Elon Musk, 22 months ago

Resolution: fixed
Status: openclosed

Fixed that too.

Note: See TracTickets for help on using tickets.