Extracting frames from mp4in ffmpeg to jpg format produces error when using -vsync 0 option
Asked Answered
R

1

3

I'm trying to extract all frames from a mp4 video with ffmpeg. I use the following command:

ffmpeg -i "/Users/raimundbuehler/recordings/2022_01_24/000/exports/001/world.mp4" -vsync 0  "/Users/raimundbuehler/data/converted_frames/frame%06d.jpg"

It works fine when using -vsync 2 (variable frame rate), but not when using -vsync 0 (passthrough). Using vsync 2 however drops a few frames, which i don't want to happen. It also works, when extracting to png format, but i need jpg.

It seems to work for the first 40 frames, but produces the error on frame 41. This is the output:

ffmpeg version N-104855-g466441a0d2-tessus  https://evermeet.cx/ffmpeg/  Copyright (c) 2000-2021 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
  libavutil      57. 11.100 / 57. 11.100
  libavcodec     59. 14.100 / 59. 14.100
  libavformat    59. 10.100 / 59. 10.100
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8. 19.100 /  8. 19.100
  libswscale      6.  1.101 /  6.  1.101
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Passing a number to -vsync is deprecated, use a string argument as described in the manual.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/raimundbuehler/recordings/2022_01_24/000/exports/001/world.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:55.20, start: 0.000000, bitrate: 10379 kb/s
  Stream #0:0[0x1](und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 10376 kb/s, 23.60 fps, 23.58 tbr, 65535 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02efc0000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02efd7000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02efe4000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02eff1000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02effe000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02f00b000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02f018000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02f025000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02f032000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02f03f000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02f04c000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02f059000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0x7ff02ef5b000] [swscaler @ 0x7ff02f066000] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '/Users/raimundbuehler/data/converted_frames/frame%06d.jpeg':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf59.10.100
  Stream #0:0(und): Video: mjpeg, yuvj420p(pc, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 23.58 fps, 23.58 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.14.100 mjpeg
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
[mjpeg @ 0x7ff029413f40] Invalid pts (41) <= last (41)trate=N/A speed=2.02x    
Video encoding failed
Conversion failed!

Help would be greatly appreciated!

Rois answered 27/1, 2022 at 15:11 Comment(0)
P
2

The mjpeg decoder doesn't like frames with duplicate pts.

You can simply retime them to avoid that.

ffmpeg -i "/Users/raimundbuehler/recordings/2022_01_24/000/exports/001/world.mp4" -vf setpts=N/FR/TB -vsync 0 "/Users/raimundbuehler/data/converted_frames/frame%06d.jpg"

Plight answered 28/1, 2022 at 4:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.