[FFmpeg-user] Use cropdetect only every xth frame

Gerion Entrup gerion.entrup at t-online.de
Wed Oct 9 02:56:30 CEST 2013


Am Mittwoch, 9. Oktober 2013, 00:02:52 schrieb Carl Eugen Hoyos:
> Gerion Entrup <gerion.entrup <at> t-online.de> writes:
> > is it possible to say the cropdetect filter, that it
> > should analyse the picture only every 10th frame (or
> > something similar)?
> 
> The select filter should allow you to do this.
I think, this is not in the way I want it, because ffmpeg decodes every frame 
and then drop it (or is this wrong?).

Here a few test results:    
File is in RAM:
> $ pv test.mp4 > /dev/null
> 104MiB 0:00:00 [2,77GiB/s] 
[=================================================================================>] 
100%
Every 10th I-Frame, if I get the concept:
> $ time ffmpeg -i test.mp4 -filter:v 
select='if(eq(pict_type\,I)\,not(mod(st(0\,ld(0)+1)\,10)))',cropdetect -
filter:a volumedetect -map 0 -f null /dev/null >/dev/null 2>&1
> 
> real    0m20.554s
> user    1m8.585s
> sys     0m0.509s
Every I-Frame:
> $ time ffmpeg -i test.mp4 -filter:v select='eq(pict_type\,I)',cropdetect -
filter:a volumedetect -map 0 -f null /dev/null >/dev/null 2>&1
> 
> real    0m20.593s
> user    1m8.687s
> sys     0m0.487s
Every Frame:
> $ time ffmpeg -i test.mp4 -filter:v cropdetect -filter:a volumedetect -map 0 -f 
null /dev/null >/dev/null 2>&1
> 
> real    0m20.810s
> user    1m9.323s
> sys     0m0.438s
Only Audioframes:
> $ time ffmpeg -i test.mp4 -filter:v cropdetect -filter:a volumedetect -map 0:a 
-f null /dev/null >/dev/null 2>&1
> 
> real    0m0.388s
> user    0m0.370s
> sys     0m0.013s
Only Video and I-Frames
> $ time ffmpeg -i test.mp4 -filter:v select='eq(pict_type\,I)',cropdetect -map 
0:v -f null /dev/null >/dev/null 2>&1
> 
> real    0m19.962s
> user    1m7.830s
> sys     0m0.440s
Every 5 seconds 1 second via Bash:
> $ time for i in `seq 0 5 $(ffprobe -show_format test.mp4 2>/dev/null | grep 
duration | sed 's,duration=\(.*\)\..*,\1,g')`; do ffmpeg -ss "$i" -i test.mp4 -
t 1 -filter:v cropdetect -map 0:v -f null /dev/null >/dev/null 2>&1; done
> 
> real    0m10.269s
> user    0m26.083s
> sys     0m1.192s
Every 10 seconds 1 second:
> $ time for i in `seq 0 10 $(ffprobe -show_format test.mp4 2>/dev/null | grep 
duration | sed 's,duration=\(.*\)\..*,\1,g')`; do ffmpeg -ss "$i" -i test.mp4 -
t 1 -filter:v cropdetect -map 0:v -f null /dev/null >/dev/null 2>&1; done
> 
> real    0m5.745s
> user    0m13.658s
> sys     0m0.600s

I hope, you get, what I mean.

Gerion



More information about the ffmpeg-user mailing list