ffmpeg lose frames when extracting them - ffmpeg

When I extract all frames from a video, FFmpeg lose one frame. I tried multiple options, like adding more parameters to the function, but none of them worked.
ffmpeg -i Multicam420-30a.mp4 -framerate 30 frame%08d.jpg
ffmpeg version N-94077-g01d8c72b95 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190621
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 29.100 / 56. 29.100
libavcodec 58. 53.100 / 58. 53.100
libavformat 58. 28.100 / 58. 28.100
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 55.100 / 7. 55.100
libswscale 5. 4.101 / 5. 4.101
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0000023af91f9e80] st: 0 edit list: 1 Missing key frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 # 0000023af91f9e80] st: 0 edit list 1 Cannot find an index entry before timestamp: 0.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Multicam420-30a.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: mp41mp42
creation_time : 2019-08-20T01:30:57.000000Z
Duration: 00:00:01.00, start: 0.000000, bitrate: 11208 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 11007 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2019-08-20T01:30:57.000000Z
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2019-08-20T01:30:57.000000Z
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler # 0000023afb923740] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'frame%08d.jpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: mp41mp42
encoder : Lavf58.28.100
Stream #0:0(eng): Video: mjpeg, yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
Metadata:
creation_time : 2019-08-20T01:30:57.000000Z
encoder : Lavc58.53.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 29 fps= 17 q=24.8 Lsize=N/A time=00:00:00.96 bitrate=N/A speed=0.557x
video:3153kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
As you can see, the original video has 30 frames and last 1 second, and the output frames are 29 and less than a second.

Related

ffmpeg unable to save a frame at specific time

I followed Im getting error "deprecated pixel format used, make sure you did set range correctly using ffmpeg".. can someone check my code below? to save a frame from a video but the saved frame is of timestamp 00:00:00 instead of the given timestamp
$ ffmpeg -i 001\ Introduction.mp4 -ss 00:03:12.00 -vframes 1 side_view.jpg
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.3.0 (Gentoo 9.3.0 p2)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/share/doc/ffmpeg-4.2.2/html --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-march=native -O2 -pipe' --disable-static --enable-avfilter --enable-avresample --disable-stripping --disable-optimizations --disable-libcelt --disable-indev=oss --disable-indev=jack --disable-outdev=oss --enable-version3 --enable-nonfree --enable-bzlib --disable-runtime-cpudetect --disable-debug --disable-gcrypt --disable-gnutls --enable-gmp --enable-gpl --disable-hardcoded-tables --enable-iconv --disable-libtls --enable-libxml2 --disable-lzma --enable-network --enable-opencl --disable-openssl --enable-postproc --disable-libsmbclient --enable-ffplay --enable-sdl2 --enable-vaapi --enable-vdpau --enable-xlib --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-zlib --disable-libcdio --disable-libiec61883 --disable-libdc1394 --disable-libcaca --disable-openal --enable-opengl --enable-libv4l2 --enable-libpulse --enable-libdrm --disable-libjack --disable-libopencore-amrwb --disable-libopencore-amrnb --disable-libcodec2 --disable-libdav1d --enable-libfdk-aac --enable-libopenjpeg --enable-libbluray --disable-libgme --disable-libgsm --disable-libaribb24 --disable-mmal --disable-libmodplug --enable-libopus --disable-libilbc --disable-librtmp --disable-libssh --disable-libspeex --enable-libsrt --enable-librsvg --disable-ffnvcodec --enable-libvorbis --enable-libvpx --disable-libzvbi --disable-appkit --disable-libbs2b --disable-chromaprint --disable-cuda-llvm --disable-libflite --disable-frei0r --disable-libfribidi --enable-fontconfig --disable-ladspa --enable-libass --disable-libtesseract --enable-lv2 --enable-libfreetype --disable-libvidstab --disable-librubberband --disable-libzmq --disable-libzimg --disable-libsoxr --enable-pthreads --disable-libvo-amrwbenc --enable-libmp3lame --disable-libkvazaar --disable-libaom --disable-libopenh264 --disable-libsnappy --enable-libtheora --disable-libtwolame --disable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-neon --disable-vfp --disable-vfpv3 --disable-armv8 --disable-mipsdsp --disable-mipsdspr2 --disable-mipsfpu --disable-altivec --disable-amd3dnow --disable-amd3dnowext --disable-aesni --disable-avx --disable-avx2 --disable-fma3 --disable-fma4 --disable-sse3 --disable-ssse3 --disable-sse4 --disable-sse42 --disable-xop --enable-pic --cpu=host --disable-doc --disable-htmlpages --enable-manpages
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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '001 Introduction.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.12.100
Duration: 00:09:40.10, start: 0.000000, bitrate: 1981 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1835 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Subtitle: mov_text (tx3g / 0x67337874), 1280x108, 0 kb/s (default)
Metadata:
rotate : 0
creation_time : 2020-05-20T08:15:54.000000Z
File 'side_view.jpg' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler # 0x55e27e819520] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'side_view.jpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Stream #0:0(eng): Video: mjpeg, yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.54.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 1 fps=0.1 q=5.2 Lsize=N/A time=00:00:00.03 bitrate=N/A speed=0.00313x
video:44kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
In the above output, notice time=00:00:00.03 despite the given -ss 00:03:12.00.
Update
ffmpeg -i "001 Introduction.mp4" -ss 00:03:12.00 -vframes 1 -report -copyts side_view.jpg
https://gist.github.com/GowthamKudupudi/d3703f990548819a5bcd5e72bd5c0449
FFmpeg resets output timestamps to start from zero, unless the user expressly adds flags to override it. So, nothing wrong or unexpected here.

FFMPEG command not working on MP4 files as expected

I am trying to set the output time offset for mp4 file.
ffmpeg -ss 13.554000 -i input.mp4 -c copy -t 10 -output_ts_offset 13.554000 output.mp4
This code works for WEBM file as expected but not for MP4.
In webm it delays start time of video to the specified timestamp and duration is 23.554 but in mp4 it just cuts the video, start time is set to 0 and duration is 10
Cannot find what is problem.
ffmpeg -ss 12.960000 -i v.mp4 -c copy -t 10 -output_ts_offset 12.960000 output.mp4
ffmpeg version git-2019-12-26-b0d0d7e Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20191125
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig
--enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora
--enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp
--enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis
--enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid
--enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
--enable-libopenmpt --enable-amf
libavutil 56. 37.100 / 56. 37.100
libavcodec 58. 65.100 / 58. 65.100
libavformat 58. 35.101 / 58. 35.101
libavdevice 58. 9.101 / 58. 9.101
libavfilter 7. 69.101 / 7. 69.101
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'v.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01T00:00:00.000000Z
encoder : Lavf53.24.2
Duration: 00:00:29.57, start: 0.000000, bitrate: 1421 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1032 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : SoundHandler
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.35.101
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1032 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 250 fps=0.0 q=-1.0 Lsize= 1687kB time=00:00:09.99 bitrate=1382.7kbits/s speed=2.21e+03x
video:1212kB audio:468kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.408804%```

Empty stream when cutting a video using ffmpeg

When I try cutting a video, it outputs an empty stream (262 byte video with 0s duration). Would appreciate any insight, thanks.
Command used:
ffmpeg -i /path/to/long/video.mp4 -ss 37.69 -t 4.96 -c copy /path/to/short/video.mp4
However, when I the following (more inaccurate) command, it outputs a video. This video also has some problems, as the last frame is repeated several times, making the video one second longer (with a frozen image for one second).
ffmpeg -ss 37.69 -i /path/to/long/video.mp4 -t 4.96 -c copy /path/to/short/video.mp4
ffmpeg version: ffmpeg version 3.4.6-0ubuntu0.18.04.1
The outputs for the two commands are:
First command:
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/proj/vondrick/datasets/HowTo100M/video/Cars_&_Other_Vehicles/Motorcycles/52907/video_nVbIUDjzWY4.mp4':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: iso6avc1mp41
creation_time : 2015-06-26T00:39:04.000000Z
Duration: 00:07:14.40, start: 0.000000, bitrate: 244 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 426x240 [SAR 1:1 DAR 71:40], 2 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
Metadata:
creation_time : 2015-06-26T00:39:04.000000Z
handler_name : VideoHandler
Output #0, mp4, to '/proj/vondrick/datasets/HowTo100M/cropped_video/Cars_&_Other_Vehicles/Motorcycles/52907/nVbIUDjzWY4/video_000000_p.mp4':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: iso6avc1mp41
encoder : Lavf57.83.100
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 426x240 [SAR 1:1 DAR 71:40], q=2-31, 2 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc (default)
Metadata:
creation_time : 2015-06-26T00:39:04.000000Z
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=-1.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Second command:
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/proj/vondrick/datasets/HowTo100M/video/Cars_&_Other_Vehicles/Motorcycles/52907/video_nVbIUDjzWY4.mp4':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: iso6avc1mp41
creation_time : 2015-06-26T00:39:04.000000Z
Duration: 00:07:14.40, start: 0.000000, bitrate: 244 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 426x240 [SAR 1:1 DAR 71:40], 2 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
Metadata:
creation_time : 2015-06-26T00:39:04.000000Z
handler_name : VideoHandler
Output #0, mp4, to '/proj/vondrick/datasets/HowTo100M/cropped_video/Cars_&_Other_Vehicles/Motorcycles/52907/nVbIUDjzWY4/video_000000_3.mp4':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: iso6avc1mp41
encoder : Lavf57.83.100
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 426x240 [SAR 1:1 DAR 71:40], q=2-31, 2 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc (default)
Metadata:
creation_time : 2015-06-26T00:39:04.000000Z
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 159 fps=0.0 q=-1.0 Lsize= 159kB time=00:00:04.95 bitrate= 263.0kbits/s speed=1.89e+03x
video:158kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.909119%
Two issues:
3.4 is old. Update to a recent build before doing anything else. For Linux you can download or compile.
Cuts are not guaranteed to be accurate when using stream copy mode (-c copy) with H.264 and other similar formats because it will need to include all of the other frames necessary to decode the segment. So either cut on keyframes or re-encode by removing -c copy.

Are there differences between the parameters of different versions of ffmpeg?

I want to obtain a different raw video for each frame of an MP4 file.
My instruction works in an old version of ffmpeg but not in the new one.
In the mp4 file there are 137 frames. It is checked. The versions are installed on different machines.
Versions 2.8.15:
$ ffmpeg -i ./video.mp4 -vf fps=30 -vframes 137 -vcodec rawvideo -s '1920x1080' -pix_fmt gray -threads 0 frame%08d.raw
ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: mp41mp42
creation_time : 2019-03-11 16:16:54
Duration: 00:00:04.57, start: 0.000000, bitrate: 14014 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 13816 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2019-03-11 16:16:54
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2019-03-11 16:16:54
Output #0, image2, to 'frame%08d.raw':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: mp41mp42
encoder : Lavf56.40.101
Stream #0:0(eng): Video: rawvideo (Y800 / 0x30303859), gray, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
Metadata:
creation_time : 2019-03-11 16:16:54
encoder : Lavc56.60.100 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
frame= 137 fps= 73 q=-0.0 Lsize=N/A time=00:00:04.56 bitrate=N/A dup=1 drop=0
video:277425kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Version 4.1.4:
$ ffmpeg -i ./video.mp4 -vf fps=30 -vframes 137 -vcodec rawvideo -s '1920x1080' -pix_fmt gray -threads 0 frame%08d.raw
ffmpeg version 4.1.4-1~deb10u1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 # 0x558d1a5bb880] st: 0 edit list: 1 Missing key frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 # 0x558d1a5bb880] st: 0 edit list 1 Cannot find an index entry before timestamp: 0.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: mp41mp42
creation_time : 2019-03-11T16:16:54.000000Z
Duration: 00:00:04.57, start: 0.000000, bitrate: 14014 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 13816 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2019-03-11T16:16:54.000000Z
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2019-03-11T16:16:54.000000Z
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, image2, to 'frame%08d.raw':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: mp41mp42
encoder : Lavf58.20.100
Stream #0:0(eng): Video: rawvideo (Y800 / 0x30303859), gray, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 497664 kb/s, 30 fps, 30 tbn, 30 tbc (default)
Metadata:
creation_time : 2019-03-11T16:16:54.000000Z
encoder : Lavc58.35.100 rawvideo
frame= 136 fps= 25 q=-0.0 Lsize=N/A time=00:00:04.53 bitrate=N/A speed=0.834x
video:275400kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
In the latest version, I expect 137 files but the amount is 136.
The old version did not have support for edit lists. Technically, some frames are not meant for presentation but only as reference, but since you want all frames, use
ffmpeg -ignore_editlist 1 -i ./video.mp4 -vsync 0 -c:v rawvideo -s '1920x1080' -pix_fmt gray frame%08d.raw

FFMPEG - cut video result in longer cut

I'm trying to cut the last 8 seconds of a video I got; the problem is that ffmpeg is picking the last 10 seconds instead and I don't really know why. I checked and there is no offset between "0:00:00" and the effective start of the video, so why should it take more seconds?
this is my code:
ffmpeg.exe -ss 00:01:02 -i "F:\temp\input.mp4" -c copy -t 00:00:08 "D:\temp\1_output.mp4"
this is the output:
ffmpeg version N-90893-gcae6f806a6 Copyright (c) 2000-2018 the FFmpeg
developers built with gcc 7.3.0 (GCC) configuration: --enable-gpl
--enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth libavutil 56. 17.100 / 56. 17.100 libavcodec 58. 19.100 / 58. 19.100 libavformat 58. 13.100 / 58. 13.100 libavdevice 58. 4.100 /
4.100 libavfilter 7. 21.100 / 7. 21.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 Input #0,
mov,mp4,m4a,3gp,3g2,mj2, from 'F:\temp\input.mp4': Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.13.100 Duration: 00:01:10.34, start: 0.000000, bitrate: 14542 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 576x1024, 14346 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 193 kb/s (default)
Metadata:
handler_name : SoundHandler Output #0, mp4, to 'D:\temp\1_output.mp4': Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.13.100
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 576x1024, q=2-31, 14346 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc
(default)
Metadata:
handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 193 kb/s (default)
Metadata:
handler_name : SoundHandler Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help frame= 252
fps=0.0 q=-1.0 Lsize= 3089kB time=00:00:07.99 bitrate=3164.7kbits/s
speed=1e+003x video:2841kB audio:240kB subtitle:0kB other
streams:0kB global headers:0kB muxing overhead: 0.283155%
I don't really understand what i'm doing wrong
Thanks
do not use "-c copy" it sucks up everything.
just try like this and you are good to go...
ffmpeg.exe -i "F:\temp\input.mp4" -ss 00:01:02 -to 00:01:10 "D:\temp\1_output.mp4"

Resources