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.
Related
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
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.
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"
I downloaded ffmpeg and ran the command found in the documentation to generate palettes:
ffmpeg -i input.mkv -vf palettegen palette.png
The only difference being my input was input.mp4 instead of input.mkv.
No file gets generated. Here's the console output from PowerShell:
ffmpeg version 3.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.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-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-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
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
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 'input.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
creation_time : 2018-11-23T23:27:38.000000Z
Duration: 00:00:09.98, start: 0.000000, bitrate: 2784 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 580x328 [SAR 1:1 DAR 145:82], 2699 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2018-11-23T23:27:38.000000Z
handler_name : VideoHandler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 79 kb/s (default)
Metadata:
creation_time : 2018-11-23T23:27:38.000000Z
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> png (native))
Press [q] to stop, [?] for help
Output #0, image2, to 'palette.png':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
encoder : Lavf57.83.100
Stream #0:0(und): Video: png, rgba, 16x16 [SAR 1:1 DAR 1:1], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)
Metadata:
creation_time : 2018-11-23T23:27:38.000000Z
handler_name : VideoHandler
encoder : Lavc57.107.100 png
[Parsed_palettegen_0 # 00000296510def00] 255(+1) colors generated out of 285516 colors; ratio=0.000893
[Parsed_palettegen_0 # 00000296510def00] Dupped color: FF000001
Any ideas?
So I figured out that I had two versions of ffmpeg installed and the first one inside of Path was quite outdated. So I removed the older one and it worked just fine.
I use this simple script to convert video to images using ffmpeg, but frame rate is fixed, how can I determine it automatically?
FRAME_RATE="30"
SEPARATOR='/'
VIDEO_PATH=$1
VIDEO_BASE_DIR=`dirname $1`
FRAMES_DIR=$VIDEO_BASE_DIR$SEPARATOR"Frames"
rm -rf $FRAMES_DIR
mkdir $FRAMES_DIR
#Convert video to images
./ffmpeg -r $FRAME_RATE -i $VIDEO_PATH $FRAMES_DIR$SEPARATOR"image%d.png"
UPDATE:
By ffprobe I checked that my 1st video frame rate is 30.
Also results are the same (339 frames are produced) even I reduce frame rate, so -r option doesn't work or work in some other way?
These command give the same result:
./ffmpeg -r 10 -i $VIDEO_PATH $FRAMES_DIR$SEPARATOR"image%d"$EXTENSION
./ffmpeg -r 30 -i $VIDEO_PATH $FRAMES_DIR$SEPARATOR"image%d"$EXTENSION
./ffmpeg -i $VIDEO_PATH $FRAMES_DIR$SEPARATOR"image%d"$EXTENSION
Output:
ffmpeg version N-63893-gc69defd Copyright (c) 2000-2014 the FFmpeg developers
built on Jul 16 2014 05:38:01 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
libavutil 52. 89.100 / 52. 89.100
libavcodec 55. 66.101 / 55. 66.101
libavformat 55. 43.100 / 55. 43.100
libavdevice 55. 13.101 / 55. 13.101
libavfilter 4. 8.100 / 4. 8.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/user/myvideo1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-01-16 05:30:03
Duration: 00:00:11.33, start: 0.000000, bitrate: 4659 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480, 4539 kb/s, SAR 65536:65536 DAR 4:3, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2016-01-16 05:30:03
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
creation_time : 2016-01-16 05:30:03
handler_name : SoundHandle
Output #0, image2, to '/home/user/Frames/image%d.png':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf55.43.100
Stream #0:0(eng): Video: png, rgb24, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 30 fps, 90k tbn, 30 tbc (default)
Metadata:
rotate : 90
creation_time : 2016-01-12 05:38:03
handler_name : VideoHandle
encoder : Lavc55.66.101 png
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> png (png))
Press [q] to stop, [?] for help
frame= 339 fps= 68 q=0.0 Lsize=N/A time=00:00:11.30 bitrate=N/A
video:195852kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
ffprobe -v 0 -of compact=p=0 -select_streams 0 \
-show_entries stream=r_frame_rate 'The Master (2012).mp4'
Result:
r_frame_rate=24000/1001
You can use ffprobe and awk to grab fps for you:
ffprobe -show_streams "video" 2>&1 | \
grep fps | \
awk '{split($0,a,"fps")}END{print a[1]}' | \
awk '{print $NF}'
Some time ago I wrote an article about generating ffmpeg previews from videos which is maybe similar to what you're trying to do. I had to count total number of frames in a video:
See https://www.binpress.com/tutorial/how-to-generate-video-previews-with-ffmpeg/138
What about
./ffmpeg -i input_file 2>&1 | sed -n "s/.*, \(.*\) tbr.*/\1/p"
ON windows 10,
ffmpeg -i <input video file>
The last portion will show fps info. Please check the line beginning with "Stream...."
The following video file is encoded in 60 fps .
C:\user\mitchell\ffmpeg -i video0001.mp4
ffmpeg version 2021-09-22-git-447cf53774-essentials_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.3.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
libavutil 57. 6.100 / 57. 6.100
libavcodec 59. 9.100 / 59. 9.100
libavformat 59. 5.100 / 59. 5.100
libavdevice 59. 0.101 / 59. 0.101
libavfilter 8. 9.100 / 8. 9.100
libswscale 6. 1.100 / 6. 1.100
libswresample 4. 0.100 / 4. 0.100
libpostproc 56. 0.100 / 56. 0.100
Input #0, matroska,webm, from 'video0001.mp4':
Metadata:
encoder : GStreamer matroskamux version 1.14.5
creation_time : 2021-09-22T17:52:09.000000Z
Duration: 00:00:25.75, start: 2.470000, bitrate: 4256 kb/s
Stream #0:0(eng): Video: hevc (Main), yuvj420p(pc, progressive), 3840x2160, SAR 1:1 DAR 16:9, 60 fps, 60 tbr, 1k tbn (default)
Metadata:
title : Video