Output image sequence duplicate first image

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

Output image sequence duplicate first image

FFmpeg-users mailing list
Hi you lovely people,

I am trying to output a sequence of jpeg images from a video file. The command does indeed output a sequence of images, but the first and second are always duplicates, while the rest run in sequence until the maximum is reached or the file runs out.
I am not sure what I have done wrong. I thought I have asked for -r 10/60 so 10 a minute regardless of frame rate.

Any ideas how to stop the duplicate being created?
Thanks in advance

Here is my full terminal…

/usr/src/app # ffmpeg -y -i /data/vod-storage-dev/source/testfile.mxf -r 20/60 -s 283x159 -frames:v 10 -pix_fmt yuvj420p -c:v mjpeg  /data/vod-storage-dev/temp_out/1cq8tq69tkumv1es0zxeb0ty4qa_%03d.jpeg
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 6.4.0 (Alpine 6.4.0)
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-postproc --enable-small --enable-version3 --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib --extra-libs=-ldl --prefix=/opt/ffmpeg
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Guessed Channel Layout for Input Stream #0.1 : mono
Guessed Channel Layout for Input Stream #0.2 : mono
Guessed Channel Layout for Input Stream #0.3 : mono
Guessed Channel Layout for Input Stream #0.4 : mono
Guessed Channel Layout for Input Stream #0.5 : mono
Guessed Channel Layout for Input Stream #0.6 : mono
Guessed Channel Layout for Input Stream #0.7 : mono
Guessed Channel Layout for Input Stream #0.8 : mono
Input #0, mxf, from '/data/vod-storage-dev/source/testfile.mxf':
  Metadata:
    operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
    uid             : adab4424-2f25-4dc7-92ff-29bd000c0000
    generation_uid  : adab4424-2f25-4dc7-92ff-29bd000c0001
    company_name    : FFmpeg
    product_name    : OP1a Muxer
    product_version : 58.12.100
    product_uid     : adab4424-2f25-4dc7-92ff-29bd000c0002
    material_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2400
    timecode        : 00:00:00:00
  Duration: 00:00:38.44, start: 0.000000, bitrate: 59978 kb/s
    Stream #0:0: Video: mpeg2video, yuv422p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], 50000 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
    Stream #0:1: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
    Stream #0:2: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
    Stream #0:3: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
    Stream #0:4: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
    Stream #0:5: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
    Stream #0:6: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
    Stream #0:7: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
    Stream #0:8: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0x5573b7c37180] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '/data/vod-storage-dev/temp_out/1cq8tq69tkumv1es0zxeb0ty4qa_%03d.jpeg':
  Metadata:
    operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
    uid             : adab4424-2f25-4dc7-92ff-29bd000c0000
    generation_uid  : adab4424-2f25-4dc7-92ff-29bd000c0001
    company_name    : FFmpeg
    product_name    : OP1a Muxer
    product_version : 58.12.100
    product_uid     : adab4424-2f25-4dc7-92ff-29bd000c0002
    material_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2400
    timecode        : 00:00:00:00
    encoder         : Lavf58.29.100
    Stream #0:0: Video: mjpeg, yuvj420p(pc), 283x159 [SAR 848:849 DAR 16:9], q=2-31, 200 kb/s, 0.33 fps, 0.33 tbn, 0.33 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
      encoder         : Lavc58.54.100 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame=   10 fps=3.0 q=1.6 Lsize=N/A time=00:00:30.00 bitrate=N/A dup=0 drop=583 speed= 8.9x    
video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
_______________________________________________
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 image sequence duplicate first image

kumowoon1025
Hi,

> /usr/src/app # ffmpeg -y -i /data/vod-storage-dev/source/testfile.mxf -r 20/60 -s 283x159 -frames:v 10 -pix_fmt yuvj420p -c:v mjpeg  /data/vod-storage-dev/temp_out/1cq8tq69tkumv1es0zxeb0ty4qa_%03d.jpeg
...
>    Stream #0:0: Video: mpeg2video, yuv422p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], 50000 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
>    Metadata:
>      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
...
>    Stream #0:0: Video: mjpeg, yuvj420p(pc), 283x159 [SAR 848:849 DAR 16:9], q=2-31, 200 kb/s, 0.33 fps, 0.33 tbn, 0.33 tbc
>    Metadata:
>      file_package_umid: 0x060A2B340101010501010D001324CF5D529471346A24CF5D00529471346A2401
>      encoder         : Lavc58.54.100 mjpeg
>    Side data:
>      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
> frame=   10 fps=3.0 q=1.6 Lsize=N/A time=00:00:30.00 bitrate=N/A dup=0 drop=583 speed= 8.9x    
> video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

If this is accurate, it looks like you have asked it to produce 20 frames in 60 seconds, or 1/3 fps, or 1 frame every 3 seconds regardless of input framerate, whatever. It will drop frames, duplicate frames, do what is needed to keep 1/3 frames per second constant output. You've also specified that you want 10 frames total. at 1/3 fps that runs 30 seconds. I'm not sure why the first and second are always duplicates, it doesn't look like any frames were duplicated. (at 0.33fps if two frames were exactly the same when they weren't duplicated, maybe it was frozen in the source?)

Regards,
Ted
_______________________________________________
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 image sequence duplicate first image

Carl Eugen Hoyos-2
In reply to this post by FFmpeg-users mailing list




> Am 20.04.2020 um 16:28 schrieb adam smith via ffmpeg-user <[hidden email]>:
>
> Any ideas how to stop the duplicate being created?

Use -vsync 0 and remove -r.

Carl Eugen
_______________________________________________
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 image sequence duplicate first image

FFmpeg-users mailing list

> On 20 Apr 2020, at 16:03, Carl Eugen Hoyos <[hidden email]> wrote:
> Use -vsync 0 and remove -r.

Thanks for your help Carl.
Adding the -vsync 0 and removing -r did resolve the issue duplicate image output but did not allow me to specify the frequency of the image grabs.
I will search about for something to allow the frequency to be included.
Thanks


_______________________________________________
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 image sequence duplicate first image

Carl Eugen Hoyos-2


> Am 20.04.2020 um 18:16 schrieb adam smith via ffmpeg-user <[hidden email]>:
>
>
>> On 20 Apr 2020, at 16:03, Carl Eugen Hoyos <[hidden email]> wrote:
>> Use -vsync 0 and remove -r.
>
> Thanks for your help Carl.
> Adding the -vsync 0 and removing -r did resolve the issue duplicate image output but did not allow me to specify the frequency of the image grabs.
> I will search about for something to allow the frequency to be included.

Sorry, I misunderstood:
Use the output option -r or the fps filter to control the frequency of the image grabs. They will show different behaviour wrt the beginning of the grab cycle.

Carl Eugen
_______________________________________________
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 image sequence duplicate first image

FFmpeg-users mailing list
In reply to this post by kumowoon1025


> On 20 Apr 2020, at 15:38, Edward Park <[hidden email]> wrote:
>
> If this is accurate, it looks like you have asked it to produce 20 frames in 60 seconds, or 1/3 fps, or 1 frame every 3 seconds regardless of input framerate, whatever. It will drop frames, duplicate frames, do what is needed to keep 1/3 frames per second constant output. You've also specified that you want 10 frames total. at 1/3 fps that runs 30 seconds. I'm not sure why the first and second are always duplicates, it doesn't look like any frames were duplicated. (at 0.33fps if two frames were exactly the same when they weren't duplicated, maybe it was frozen in the source?)
>
> Regards,
> Ted
>

Thanks Ted,
Thats exactly what I was hoping I had asked it for.
Create 20 image files per 60 seconds of source media up to a maximum total of 10 images.
So if the source was 15 seconds in duration I would get 5 images, anything 30 seconds if longer in duration I would get 10 images output spaced equally apart in time at a frequency of 1/3 fps from the start of the source.
These values are all variables at runtime so I might ask to create at a lower frequency with more or less total images.
Every single time I get a duplicate first image :(



_______________________________________________
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 image sequence duplicate first image

kumowoon1025
In reply to this post by Carl Eugen Hoyos-2
Hi,

> Use the output option -r or the fps filter to control the frequency of the image grabs. They will show different behaviour wrt the beginning of the grab cycle.

The identical frames at the start is surprising for me, why would that happen and not be counted as a duplicate? Does it happen when the frames aren't in the order that they're presented at the beginning?

Regards,
Ted Park
_______________________________________________
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 image sequence duplicate first image

Carl Eugen Hoyos-2
Am Mo., 20. Apr. 2020 um 19:32 Uhr schrieb Edward Park <[hidden email]>:
>
> > Use the output option -r or the fps filter to control the frequency of the image grabs.
> > They will show different behaviour wrt the beginning of the grab cycle.
>
> The identical frames at the start is surprising for me, why would that happen
> and not be counted as a duplicate?

I am also surprised but I wonder if there are not duplicated but the way -r acts
can look nondeterministic (it isn't but can act surprisingly).

> Does it happen when the frames aren't in the order that they're presented at the beginning?

I don't think this is related.

Carl Eugen
_______________________________________________
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 image sequence duplicate first image

Mark Filipak
In reply to this post by FFmpeg-users mailing list
Hi, Adam,

On 04/20/2020 10:28 AM, adam smith via ffmpeg-user wrote:

> Hi you lovely people,
>
> I am trying to output a sequence of jpeg images from a video file. The command does indeed output a sequence of images, but the first and second are always duplicates, while the rest run in sequence until the maximum is reached or the file runs out.
> I am not sure what I have done wrong. I thought I have asked for -r 10/60 so 10 a minute regardless of frame rate.
>
> Any ideas how to stop the duplicate being created?
> Thanks in advance
>
> Here is my full terminal…
>
> /usr/src/app # ffmpeg -y -i /data/vod-storage-dev/source/testfile.mxf -r 20/60 -s 283x159 -frames:v 10 -pix_fmt yuvj420p -c:v mjpeg  /data/vod-storage-dev/temp_out/1cq8tq69tkumv1es0zxeb0ty4qa_%03d.jpeg

May I suggest the following workaround?

Remove the 1st (duplicate) frame with a select filter:

ffmpeg -y -i /data/vod-storage-dev/source/testfile.mxf -vf select='not(eq(n\,0))' -r 20/60 -s
283x159 -frames:v 10 -pix_fmt yuvj420p -c:v mjpeg
/data/vod-storage-dev/temp_out/1cq8tq69tkumv1es0zxeb0ty4qa_%03d.jpeg

Untested.
_______________________________________________
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 image sequence duplicate first image

FFmpeg-users mailing list
In reply to this post by Carl Eugen Hoyos-2


> On 20 Apr 2020, at 22:51, Carl Eugen Hoyos <[hidden email]> wrote:
>
> Am Mo., 20. Apr. 2020 um 19:32 Uhr schrieb Edward Park <[hidden email] <mailto:[hidden email]>>:
>>
>>> Use the output option -r or the fps filter to control the frequency of the image grabs.
>>> They will show different behaviour wrt the beginning of the grab cycle.

Thanks for the information. I will give it a whirl using the fps filter and see what happens.


_______________________________________________
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 image sequence duplicate first image

FFmpeg-users mailing list
In reply to this post by Mark Filipak


> On 20 Apr 2020, at 23:10, Mark Filipak <[hidden email]> wrote:

> May I suggest the following workaround?
>
> Remove the 1st (duplicate) frame with a select filter:
>
> ffmpeg -y -i /data/vod-storage-dev/source/testfile.mxf -vf select='not(eq(n\,0))' -r 20/60 -s 283x159 -frames:v 10 -pix_fmt yuvj420p -c:v mjpeg /data/vod-storage-dev/temp_out/1cq8tq69tkumv1es0zxeb0ty4qa_%03d.jpeg
>
> Untested.

Thanks Mark, I have never used the select filter before, looks interesting; in this use case I think the output images might just duplicate from the next instead (based on nothing to be fair). I will run it and let you know.


_______________________________________________
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 image sequence duplicate first image

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

> On 21 Apr 2020, at 09:27, adam smith via ffmpeg-user <[hidden email]> wrote:
>
>
> Thanks for the information. I will give it a whirl using the fps filter and see what happens.
>

Good news…for me anyway. Carls suggestion appears to be a solution.
The new command is...

ffmpeg -y -i /data/vod-storage-dev/source/testfile.mxf -filter_complex "[0:0]fps=fps=20/60[vout]" -map "[vout]" -s 283x159 -frames:v 10 -pix_fmt yuvj420p -c:v mjpeg /data/temporary/1cq8tq69tkumv1es0zxeb0ty4qa_%03d.jpeg

The images created do not have a duplicated first image anymore :)
Again thanks for your help it is very 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".