I would like to elaborate on the code of the answer already given by Gyan with my interpretation of the documentation and the trials I have done.
ffmpeg -i in.mp4 -vf "select='trunc(t)-trunc(prev_selected_t)',setpts=0.2*PTS" -an out.mp4
Analyzing this from back to front
Different Clip rates
trunc(x) - trunc(x_{-1})
evaluates to something different than zero on the cross of every integer. If you increase or decrease the number of integers in your sample space you will have more or less resulting frames. Since t
and prev_selected_t
represent seconds of each frame, you can multiply this representation to map those seconds to more or less integers and thereby getting different sample/clip rates.
- 0.2s :
'trunc(5*t)-trunc(5*prev_selected_t)'
- 0.4s :
'trunc(2.5*t)-trunc(2.5*prev_selected_t)'
- 0.6s :
'trunc((5/3)*t)-trunc((5/3)*prev_selected_t)'
- 0.8s :
'trunc(1.25*t)-trunc(1.25*prev_selected_t)'
- 1.5s :
'trunc(0.667*t)-trunc(0.667*prev_selected_t)'
- 5.0s :
'trunc(0.2*t)-trunc(0.2*prev_selected_t)'
- ...
You are not limited to the function trunc()
here you can find other examples using other functions ,as Praveen Tamil has proposed in his answer.
A list and brief explanations of the functions evaluated in the expression definition can be found here
Thanks to Gyan for presenting this filter, helped me discover better ffmpeg.
Hope my brief explanation helps understand for possible further tweaking of the code ;)