[FFmpeg-user] Scene detection -- numerical output?
David Liontooth
lionteeth at cogweb.net
Thu Nov 8 20:18:25 CET 2012
On 11/7/12 10:40 PM, Clément Boesch wrote:
> On Wed, Nov 07, 2012 at 08:04:59PM -0800, David Liontooth wrote:
>> The scene detection feature is a great addition:
>>
>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=72868144e5862168a4f829557b7a41f686b8b12d
>>
>> Example:
>>
>> ffmpeg -i video.avi -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 preview.png
>>
>> Set a threshold value between 0 and 1 for detecting a new scene.
>> Increase the value to lower the number of detected scenes; sane
>> values are typically between 0.3 and 0.5.
>>
>> Is it possible to get a numerical output (say, frame numbers)
>> instead of the montage?
>>
> Random suggestions:
> ffmpeg -i input.avi -vf 'select=gt(scene\,.4),showinfo' -f null -
> ffprobe -show_frames -of compact=p=0 -f lavfi 'movie=video.avi,select=gt(scene\,.4)'
Great, thanks! I ran for F=2012-11-08_1000_US_CNN_CNN_News.mp4:
ffprobe -show_frames -of compact=p=0 -f lavfi
"movie=$F,select=gt(scene\,.8)" | gsed -r
's/.*pkt_pts_time=([0-9.]{8,})\|.*/\1/' >> scenes-0.8
This gives me a list of times, like this:
214.347467
649.982667
657.289967
664.897567
664.964300
694.960933
722.088033
732.598533
733.432700
733.933200
739.472067
740.339600
754.954200
769.935833
799.899100
829.962467
1192.191000
1193.358833
To get what a human observer would see as a new scene in a news program,
we might pick the first of adjacent timestamps; we'll try to compare the
output to some coded data.
David
>
> You'll get various information about the frames, such as timestamps.
>
> If you absolutely need the frame number you can try to:
> - take the first example and add another showinfo at the beginning of the
> filtergraph; check if for a given frames it reaches the second showinfo
> (if so you can use the "n" value from the first showinfo)
> - take the second example, and replace the select with select=scene+1 (to
> call the scene detection but make sure all the frames are transmitted)
> and then look yourself at the last lavfi.scene_score meta information
> in what is printed to see if the score is a good enough one
>
> I'm sure you can find various other simpler combinations.
>
>
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
More information about the ffmpeg-user
mailing list