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
Related
I'm trying to concatenate video and audio files, filling space between them with black frames or silence correspondingly.
I use the following command:
ffmpeg -i test/v/1.mkv -i test/v/2.mkv -i test/v/1.mka -i test/v/2.mka -filter_complex 'color=c=black:s=640x480:d=12ms[black0];
color=c=black:s=640x480:d=207725ms[black2];
aevalsrc=0:d=257495ms[silence1];
aevalsrc=0:d=114833ms[silence2];
[black0][0][black2][1][2][silence1][3][silence2]concat=n=8:v=1:a=1[v_out][a_out]' \
-map [v_out] -map [a_out] -c:v libvpx -c:a libopus result.webm
But I get the following error:
Stream specifier '' in filtergraph description matches no streams.
Full ffmpeg output:
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_9 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack
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, matroska,webm, from 'test/v/1.mkv':
Metadata:
encoder : GStreamer matroskamux version 1.8.1.1
creation_time : 2021-02-05T16:54:38.000000Z
Duration: 00:00:52.24, start: 0.637000, bitrate: 1922 kb/s
Stream #0:0(eng): Video: vp8, yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 29.83 tbr, 1k tbn, 1k tbc (default)
Metadata:
title : Video
Input #1, matroska,webm, from 'test/v/2.mkv':
Metadata:
encoder : GStreamer matroskamux version 1.8.1.1
creation_time : 2021-02-05T16:58:58.000000Z
Duration: 00:02:07.19, start: 260.603000, bitrate: 1966 kb/s
Stream #1:0(eng): Video: vp8, yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 29.83 tbr, 1k tbn, 1k tbc (default)
Metadata:
title : Video
Input #2, matroska,webm, from 'test/v/1.mka':
Metadata:
encoder : GStreamer matroskamux version 1.8.1.1
creation_time : 2021-02-05T16:55:58.000000Z
Duration: 00:00:02.44, start: 0.624000, bitrate: 80 kb/s
Stream #2:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Metadata:
title : Audio
Input #3, matroska,webm, from 'test/v/2.mka':
Metadata:
encoder : GStreamer matroskamux version 1.8.1.1
creation_time : 2021-02-05T16:59:01.000000Z
Duration: 00:00:12.40, start: 260.561000, bitrate: 43 kb/s
Stream #3:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Metadata:
title : Audio
Stream specifier '' in filtergraph description color=c=black:s=640x480:d=12ms[black0];
color=c=black:s=640x480:d=207725ms[black2];
aevalsrc=0:d=257495ms[silence1];
aevalsrc=0:d=114833ms[silence3];
[black0][0][black2][1][2][silence1][3][silence3]concat=n=8:v=1:a=1[v_out][a_out] matches no streams.
Video files do not contain audio.
What I'm doing wrong? Help please.
I am trying to run the following command :
-i "2020_11_30_03_37_37.mp4" -i "2020_11_30_03_37_44.jpg" -f lavfi -t 6.016 -i anullsrc -filter_complex "[0:v]crop=544:544:0:208,boxblur=luma_radius=10:chroma_radius=10:luma_power=1,scale=1080:1080[bg];[0:v]scale=612:1080[fg];[bg][fg]overlay=234:0:shortest=1[si];[si]trim=0:1,setpts=(PTS-STARTPTS)*2[video0];[0:a]atrim=0:1,asetpts=PTS-STARTPTS,atempo=0.5[audio0];[si]trim=1:5.016,setpts=(PTS-STARTPTS)*1[video1];[0:a]atrim=1:5.016,asetpts=PTS-STARTPTS,atempo=1[audio1];[video0][audio0][video1][audio1]concat=n=2:v=1:a=1[mv];[1:v]scale=428:-1[sticker1];[mv][sticker1]overlay=x=0:y=0:enable='between(t,0,1)'" "2020_11_30_03_37_50.mp4"
but FFmpeg throwing the following error:
Invalid stream specifier: si.
but I already specified this stream in command. unable to understand what's wrong
here is the log
C:\Users\abhis\AppData\Local\Packages\64815ZMobileApps.VideoDownloaderforYouTubeDownload_61cxy7b35vdsg\TempState>ffmpeg -i "2020_11_30_03_37_37.mp4" -i "2020_11_30_03_37_44.jpg" -f lavfi -t 6.016 -i anullsrc -filter_complex "[0:v]crop=544:544:0:208,boxblur=luma_radius=10:chroma_radius=10:luma_power=1,scale=1080:1080[bg];[0:v]scale=612:1080[fg];[bg][fg]overlay=234:0:shortest=1[si];[si]trim=0:1,setpts=(PTS-STARTPTS)*2[video0];[0:a]atrim=0:1,asetpts=PTS-STARTPTS,atempo=0.5[audio0];[si]trim=1:5.016,setpts=(PTS-STARTPTS)*1[video1];[0:a]atrim=1:5.016,asetpts=PTS-STARTPTS,atempo=1[audio1];[video0][audio0][video1][audio1]concat=n=2:v=1:a=1[mv];[1:v]scale=428:-1[sticker1];[mv][sticker1]overlay=x=0:y=0:enable='between(t,0,1)'" "2020_11_30_03_37_50.mp4"
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.2.1 (GCC) 20200726
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-libsrt --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-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --enable-librav1e --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
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
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 '2020_11_30_03_37_37.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Duration: 00:00:05.02, start: 0.000000, bitrate: 2097 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 544x960, 1997 kb/s, SAR 1:1 DAR 17:30, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandle
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
Metadata:
handler_name : SoundHandle
Input #1, image2, from '2020_11_30_03_37_44.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 2416762 kb/s
Stream #1:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1280x854 [SAR 200:200 DAR 640:427], 25 tbr, 25 tbn, 25 tbc
Input #2, lavfi, from 'anullsrc':
Duration: N/A, start: 0.000000, bitrate: 705 kb/s
Stream #2:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s
[mov,mp4,m4a,3gp,3g2,mj2 # 00000279fa82eb80] Invalid stream specifier: si.
Last message repeated 1 times
Stream specifier 'si' in filtergraph description [0:v]crop=544:544:0:208,boxblur=luma_radius=10:chroma_radius=10:luma_power=1,scale=1080:1080[bg];[0:v]scale=612:1080[fg];[bg][fg]overlay=234:0:shortest=1[si];[si]trim=0:1,setpts=(PTS-STARTPTS)*2[video0];[0:a]atrim=0:1,asetpts=PTS-STARTPTS,atempo=0.5[audio0];[si]trim=1:5.016,setpts=(PTS-STARTPTS)*1[video1];[0:a]atrim=1:5.016,asetpts=PTS-STARTPTS,atempo=1[audio1];[video0][audio0][video1][audio1]concat=n=2:v=1:a=1[mv];[1:v]scale=428:-1[sticker1];[mv][sticker1]overlay=x=0:y=0:enable='between(t,0,1)' matches no streams.
You can't re-use labels (a.k.a. "pads", unintuitively) from filter outputs. So you can't use si more than once.
Add the split filter to make copies:
-i "2020_11_30_03_37_37.mp4" -i "2020_11_30_03_37_44.jpg" -f lavfi -t 6.016 -i anullsrc -filter_complex "[0:v]crop=544:544:0:208,boxblur=luma_radius=10:chroma_radius=10:luma_power=1,scale=1080:1080[bg];[0:v]scale=612:1080[fg];[bg][fg]overlay=234:0:shortest=1,split=outputs=2[si1][si2];[si1]trim=0:1,setpts=(PTS-STARTPTS)*2[video0];[0:a]atrim=0:1,asetpts=PTS-STARTPTS,atempo=0.5[audio0];[si2]trim=1:5.016,setpts=(PTS-STARTPTS)*1[video1];[0:a]atrim=1:5.016,asetpts=PTS-STARTPTS,atempo=1[audio1];[video0][audio0][video1][audio1]concat=n=2:v=1:a=1[mv];[1:v]scale=428:-1[sticker1];[mv][sticker1]overlay=x=0:y=0:enable='between(t,0,1)'" "2020_11_30_03_37_50.mp4"
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.
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
I have a problem with ffmpeg,I try to add a png files over a video i found how to add just I want this png file have some opacity
I tryed this line
ffmpeg -n -i video.mp4 -i logo.png -filter_complex "setsar=sar=1;blend=all_mode='overlay':all_opacity=0.7" -movflags +faststart tmb/video.mp4
with this line ffmpeg return this error
Cannot find a matching stream for unlabeled input pad 1 on filter Parsed_blend_1
and there the complet log
ffmpeg version 2.7.5-0ubuntu0.15.10.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
configuration: --prefix=/usr --extra-version=0ubuntu0.15.10.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --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-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libsoxr --enable-libx264 --enable-libopencv --enable-libx265
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
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: isomiso2avc1mp41
encoder : Lavf54.59.106
Duration: 00:06:17.68, start: 0.023220, bitrate: 1660 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1080x720 [SAR 8:9 DAR 4:3], 1527 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, png_pipe, from 'logo.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 1080x720 [SAR 3780:3780 DAR 3:2], 25 tbr, 25 tbn, 25 tbc
Cannot find a matching stream for unlabeled input pad 1 on filter Parsed_blend_1
I'm a little noob with ffmpeg and I tryed to find a solution with google and don't find.
Without setsar=sar=1 I got the error about two different sar
[Parsed_blend_0 # 0x14bb0e0] First input link top parameters (size 1080x720, SAR 8:9) do not match the corresponding second input link bottom parameters (1080x720, SAR 1:1)
[Parsed_blend_0 # 0x14bb0e0] Failed to configure output pad on Parsed_blend_0
Thanks for your help
Try
ffmpeg -n -i video.mp4 -i logo.png -filter_complex "[0:v]setsar=sar=1[v];[v][1]blend=all_mode='overlay':all_opacity=0.7" -movflags +faststart tmb/video.mp4