Output a sequence of images with known timings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Output a sequence of images with known timings

FFmpeg-users mailing list
Hi,

I am trying to extract an image at set intervals from a video source. Later I will select one of images and will use the interval time and image number to determine the time in the video it came from.

If anybody has a better idea how to do this, feel free to stop me and push me in the right direction.

My issue is that the first image time varies depending on the output fps.
Eg fps=1/1 will output the first image from the 1st second of source; and so on.
Fps=1/5 will output the first image from the 3rd second of the source.
Fps=1/11 will output the first image from the 6th second of the source.
It keeps getting further away from the start while remaining approx halfway to the point I expected.

Any ideas how I force the first image to either be the first frame of the source, or the same value as the frequency?

Maybe I would be better off getting it to seek to each spot; but that would get pretty long pretty quick.

Full Command: ffmpeg -y -i /data/temporary/localised_20201118-961-d41yxx/2minclock.m4v  -filter_complex \"[0:0]fifo[vout];[vout]fps=fps=1/11[vout1]\" -map \"[vout1]\" -s 283x159 -frames:v 60 -pix_fmt yuvj420p -c:v mjpeg  /data/temporary/transcode_20201118-961-1qrmsyq/2minclocktest_%03d.jpeg"}

Console output:
/usr/src/app # ffmpeg -y -i /data/temporary/localised_20201118-961-d41yxx/2minclock.m4v  -filter_complex "[0:0]fifo[vout];[vout]fps=fps=1/11[vout1]" -map "[vout1]" -s 283x159 -frames:v 60 -pix_fmt yuvj420p -c:v mjpeg /data/temporary/tra
nscode_20201118-961-1qrmsyq/2minclocktest_%03d.jpeg
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.0 (Alpine 9.3.0)
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-libsrt --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/temporary/localised_20201118-961-d41yxx/2minclock.m4v':
  Metadata:
    major_brand     : M4V
    minor_version   : 1
    compatible_brands: M4V M4A isommp42
    creation_time   : 2020-11-18T12:36:47.000000Z
    encoder         : Keynote 10.3.5 (7029.5.5)
  Duration: 00:02:01.20, start: 0.000000, bitrate: 1420 kb/s
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 1415 kb/s, 50 fps, 50 tbr, 50 tbn, 100 tbc (default)
    Metadata:
      creation_time   : 2020-11-18T12:36:47.000000Z
      handler_name    : Core Media Video
Stream mapping:
  Stream #0:0 (h264) -> fifo
  fps -> Stream #0:0 (mjpeg)
Press [q] to stop, [?] for help
[swscaler @ 0x55efa99b2d80] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '/data/temporary/transcode_20201118-961-1qrmsyq/2minclocktest_%03d.jpeg':
  Metadata:
    major_brand     : M4V
    minor_version   : 1
    compatible_brands: M4V M4A isommp42
    encoder         : Lavf58.45.100
    Stream #0:0: Video: mjpeg, yuvj420p(pc), 283x159 [SAR 848:849 DAR 16:9], q=2-31, 200 kb/s, 0.09 fps, 0.09 tbn, 0.09 tbc (default)
    Metadata:
      encoder         : Lavc58.91.100 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
frame=   11 fps=2.1 q=1.6 Lsize=N/A time=00:02:01.00 bitrate=N/A speed=22.9x    
video:80kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Thanks very much for any advice.
Adam
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: Output a sequence of images with known timings

Moritz Barsnick
On Wed, Nov 18, 2020 at 17:45:53 +0000, adam smith via ffmpeg-user wrote:

> My issue is that the first image time varies depending on the output fps.
> Eg fps=1/1 will output the first image from the 1st second of source; and so on.
> Fps=1/5 will output the first image from the 3rd second of the source.
> Fps=1/11 will output the first image from the 6th second of the source.
> It keeps getting further away from the start while remaining approx halfway to the point I expected.

That seems to be the expected behavior from the fps filter's averaging.

> Any ideas how I force the first image to either be the first frame of the source, or the same value as the frequency?

Do take a look at the documentation of the select filter. It even has
an example on how to extract certain frames, e.g. by number:

https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect

    Select one frame every 100:
        select='not(mod(n\,100))'

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: Output a sequence of images with known timings

FFmpeg-users mailing list


> On 19 Nov 2020, at 10:42, Moritz Barsnick <[hidden email]> wrote:
>
> Do take a look at the documentation of the select filter. It even has
> an example on how to extract certain frames, e.g. by number:
>
> https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect <https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect>
>
>    Select one frame every 100:
>        select='not(mod(n\,100))'
>
> Cheers,
> Moritz


Thanks Moritz, that’s really helpful I will take a look.

Much appreciated.

Adam
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: Output a sequence of images with known timings

FFmpeg-users mailing list
In reply to this post by Moritz Barsnick


> On 19 Nov 2020, at 10:42, Moritz Barsnick <[hidden email]> wrote:
>
> Do take a look at the documentation of the select filter. It even has
> an example on how to extract certain frames, e.g. by number:
>
> https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect <https://ffmpeg.org/ffmpeg-filters.html#select_002c-aselect>
>
>    Select one frame every 100:
>        select='not(mod(n\,100))’


I have been playing with this filter to select frames but it to keep the frame rate of the source and hold the selected image.

For example If I was creating an mp4, it would have the first image held for ten seconds, then the image from 10 seconds held for ten seconds, then the image from 20 seconds etc. which is very useful for a video output to be fair ;)

When jpeg is selected, if the source was 25fps, I get a jpeg 250 of each selected frame.

When I used the tile filter in the following command it was able to show me all of the images I want combined into a single tile…
ffmpeg -y -i /data/temporary/localised_20201119-219-cniqnj/2minclock.m4v -vf select='not(mod(n\,1000))',scale=160:120,tile -frames:v 1 -pix_fmt yuvj420p -c:v mjpeg /data/temporary/transcode_20201119-219-kbzyx4/2minclockte
st_%03d.jpeg




Update:
I have tested with a large range of intervals and so far this looks to be working fine…
ffmpeg -y -i /data/temporary/localised_20201119-219-cniqnj/2minclock.m4v -vf select='isnan(prev_selected_t)+gte(t-prev_selected_t\,10)',fps=1/10 -s 283x159 -pix_fmt yuvj420p -c:v mjpeg /data/temporary/transcode_20201119-2
19-kbzyx4/2minclocktest_%03d.jpeg


adding the fps filter after the select and setting it to the same value has so far given me the results I wanted.
Eg
Image 1 from very start
Image 2 from 10 second
Image 3 from 20 second
Etc.

Thanks very much for your help Moritz
Adam
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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