Treating video frame-based instead of time-based

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Treating video frame-based instead of time-based

Wolfgang Hugemann
Is ist possible to treat video frame-based instead of time-based,
analogously to a frameserver such as AVIsynth?

Concretely:
* Could I (easily) extract every nth frame from a video (in order to
dump the result as JPEGs)?
* Could I subtract each frame from its predecessor (in order to detect
minimal motion)?

At the moment, I mostly perform such tasks in AVIsynth, using the AVS
file as input for ffmpeg. Which has the shortcoming that I can only use
AVI containers as input for AVIsynth (or use the ffmpegsource to read
the original video container into AVIsynth).

So: Can I somehow get rid of AVIsynth in the mid?

Wolfgang Hugemann
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Treating video frame-based instead of time-based

Carl Eugen Hoyos-2
2019-01-21 9:31 GMT+01:00, Wolfgang Hugemann <[hidden email]>:
> Is ist possible to treat video frame-based instead of time-based,
> analogously to a frameserver such as AVIsynth?

I may misunderstand but FFmpeg treats all video as frame-based.

> Concretely:
> * Could I (easily) extract every nth frame from a video (in order to
> dump the result as JPEGs)?

See the select or the fps filter or use a low output frame rate (which
forces frame drops).

> * Could I subtract each frame from its predecessor (in order to detect
> minimal motion)?

I suspect there is a filter, maybe blend?

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Treating video frame-based instead of time-based

Gyan
In reply to this post by Wolfgang Hugemann


On 21-01-2019 02:01 PM, Wolfgang Hugemann wrote:
> Concretely:
> * Could I (easily) extract every nth frame from a video (in order to
> dump the result as JPEGs)?
> * Could I subtract each frame from its predecessor (in order to detect
> minimal motion)?

As Carl mentioned, the select filter with an appropriate expression will
do this e.g.  select='not(mod(n-1,5))' to select every 5th frame. Frame
count begins with 0.

There is a freezedetect filter in git master that can detect if a frame
has changed minimally with respect to the previous frame. Docs at
https://ffmpeg.org/ffmpeg-filters.html#freezedetect

Gyan
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Treating video frame-based instead of time-based

Wolfgang Hugemann
In reply to this post by Carl Eugen Hoyos-2
> I may misunderstand but FFmpeg treats all video as frame-based.

Sorry, I posed the question wrong. I meant that I would like to use a
frame-count-based scale instead of a time-based scale, in the way that a
genuine frame server like AVIsynth does.

>> * Could I (easily) extract every nth frame from a video (in order to
>> dump the result as JPEGs)?
> See the select or the fps filter or use a low output frame rate (which
> forces frame drops).

I fear that this would provoke rounding errors, especially with NTSC's
29,97 fps. To the contrast, AVIsynth's "SelectEvery(5)" is bullet-proof:
It takes every 5th frame (in presentation order), no matter what.

...

I take from your answer that this approach is just impossible with
FFmpeg at the moment.

Wolfgang Hugemann
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Treating video frame-based instead of time-based

Wolfgang Hugemann
In reply to this post by Gyan
> As Carl mentioned, the select filter with an appropriate expression will
> do this e.g.  select='not(mod(n-1,5))' to select every 5th frame. Frame
> count begins with 0.

The select filter keeps the framerate, such that the above code will
show every 5th frame for a 5 frame time interval. However this approach
may help to control rounding errors when using the fps filter.

Wolfgang Hugemann
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Treating video frame-based instead of time-based

Gyan


On 22-01-2019 02:19 PM, Wolfgang Hugemann wrote:
>> As Carl mentioned, the select filter with an appropriate expression will
>> do this e.g.  select='not(mod(n-1,5))' to select every 5th frame. Frame
>> count begins with 0.
> The select filter keeps the framerate, such that the above code will
> show every 5th frame for a 5 frame time interval. However this approach
> may help to control rounding errors when using the fps filter.

You mentioned that you wished to extract these selected frames as
images. As long as you use -vsync 0, there will be no frame duplication,
and the result is the extraction of every 5th frame. If you want to keep
the selected frames in a video and compact them, then setpts + fps
should be used afterwards to generate a regular CFR video.

Oh, and the correct expression is    select='not(mod(n+1,5))'

Gyan
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Treating video frame-based instead of time-based

Carl Eugen Hoyos-2
In reply to this post by Wolfgang Hugemann


Am 22.01.2019 um 09:49 schrieb Wolfgang Hugemann <[hidden email]>:

>> I may misunderstand but FFmpeg treats all video as frame-based.
>
> Sorry, I posed the question wrong. I meant that I would like to use a
> frame-count-based scale instead of a time-based scale, in the way that a
> genuine frame server like AVIsynth does.
>
>>> * Could I (easily) extract every nth frame from a video (in order to
>>> dump the result as JPEGs)?
>> See the select or the fps filter or use a low output frame rate (which
>> forces frame drops).
>
> I fear that this would provoke rounding errors,

Of course not.


> especially with NTSC's
> 29,97 fps. To the contrast, AVIsynth's "SelectEvery(5)" is bullet-proof:
> It takes every 5th frame (in presentation order), no matter what.
>
> ...
>
> I take from your answer that this approach is just impossible with
> FFmpeg at the moment.

LOL

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Treating video frame-based instead of time-based

Wolfgang Hugemann
In reply to this post by Gyan
> You mentioned that you wished to extract these selected frames as
> images. As long as you use -vsync 0, there will be no frame duplication,
> and the result is the extraction of every 5th frame.

Sorry, you are right. And thanks for "-vsync 0", which is decisive, also
when dumping the frames as JPEGs.

Your suggested code does the trick.

Wolfgang Hugemann
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Treating video frame-based instead of time-based

Wolfgang Hugemann
In reply to this post by Carl Eugen Hoyos-2
> LOL

I did not want to provoke anyone. Sorry that you took it wrong.

Wolfgang Hugemann
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Treating video frame-based instead of time-based

Carl Eugen Hoyos-2


Am 22.01.2019 um 10:39 schrieb Wolfgang Hugemann <[hidden email]>:

>> LOL
>
> I did not want to provoke anyone. Sorry that you took it wrong.

You misunderstand:
I found it ridiculous that you claim there is no solution for an issue that offers three working solutions.

For future questions: if you had provided the command line you tested together with the complete, uncut console output you would have gotten your actual issue solved quicker.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".