Insert black frames -- How?
I want to insert black frames into a stream on a regular basis. #1, Is that an input device? I think so. Or, #2, is it better/easier to repeat an input frame and blacken the repeated frame? Maybe. I seek guidance. I've read everything I could find. Methinks #1 would be best. But if #2, would a 'pad' filter that covers the entire frame be best/easiest? Thanks Folks! Mark. -- I don't have a dog. And furthermore, my dog doesn't bite. And furthermore, you provoked him.
On 2/8/2021 5:10 PM, Mark Filipak (ffmpeg) wrote:
I want to insert black frames into a stream on a regular basis. #1, Is that an input device? I think so. Or,
I think what you want is based on "-f lavfi color=c=black" although it will depend on whether you want to insert the black frame between existing frames or on top of one of them (whether to just periodically overlay or to create segments). see also https://ffmpeg.org/ffmpeg-filters.html#allrgb_002c-allyuv_002c-color_002c-ha... z!
On 02/08/2021 08:24 PM, Carl Zwanzig wrote:
On 2/8/2021 5:10 PM, Mark Filipak (ffmpeg) wrote:
I want to insert black frames into a stream on a regular basis. #1, Is that an input device? I think so. Or,
I think what you want is based on "-f lavfi color=c=black" although it will depend on whether you want to insert the black frame between existing frames or on top of one of them (whether to just periodically overlay or to create segments).
That's what I was just looking at. As a 1st step to get a source (based on the pink example in the docs), I tried this: C:\AVOut\THE LAST EMPEROR>ffmpeg -f lavfi -graph "color=c=pink [out0]" test.mkv ffmpeg started on 2021-02-08 at 20:21:13 Report written to "ffmpeg-20210208-202113.log" Log level: 32 ffmpeg version N-100851-g9f38fac053 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 9.3-win32 (GCC) 20200320 configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --enable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp libavutil 56. 64.100 / 56. 64.100 libavcodec 58.119.100 / 58.119.100 libavformat 58. 65.101 / 58. 65.101 libavdevice 58. 11.103 / 58. 11.103 libavfilter 7.100.100 / 7.100.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 [NULL @ 0000016b7a3a9000] Requested output format 'lavfi' is not a suitable output format test.mkv: Invalid argument
see also https://ffmpeg.org/ffmpeg-filters.html#allrgb_002c-allyuv_002c-color_002c-ha...
I'll take a look at it. Thanks, Carl!
ffmpeg -f lavfi -i color=c=black:s=1920x1080:r=60000/1001:d=60:sar=1:1 test.mkv ffmpeg started on 2021-02-08 at 20:44:31 Report written to "ffmpeg-20210208-204431.log" Log level: 32 ffmpeg version N-100851-g9f38fac053 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 9.3-win32 (GCC) 20200320 configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --enable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
ffmpeg -f lavfi -i color=c=black:s=hd1080:r=60000/1001:d=60:sar=1:1 test.mkv ffmpeg started on 2021-02-08 at 20:44:48 Report written to "ffmpeg-20210208-204448.log" Log level: 32 ffmpeg version N-100851-g9f38fac053 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 9.3-win32 (GCC) 20200320 configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --enable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
I'm failing on the size. I can't explain why. libavutil 56. 64.100 / 56. 64.100 libavcodec 58.119.100 / 58.119.100 libavformat 58. 65.101 / 58. 65.101 libavdevice 58. 11.103 / 58. 11.103 libavfilter 7.100.100 / 7.100.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 [color @ 0000029f0c0bda80] Unable to parse option value "1" as image size Last message repeated 1 times [color @ 0000029f0c0bda80] Error setting option size to value 1. [Parsed_color_0 @ 0000029f0c0bd980] Error applying options to the filter. [lavfi @ 0000029f0c0b9000] Error initializing filter 'color' with args 'c=black:s=1920x1080:r=60000/1001:d=60:sar=1:1' color=c=black:s=1920x1080:r=60000/1001:d=60:sar=1:1: Invalid argument libavutil 56. 64.100 / 56. 64.100 libavcodec 58.119.100 / 58.119.100 libavformat 58. 65.101 / 58. 65.101 libavdevice 58. 11.103 / 58. 11.103 libavfilter 7.100.100 / 7.100.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 [color @ 00000211a0d7da80] Unable to parse option value "1" as image size Last message repeated 1 times [color @ 00000211a0d7da80] Error setting option size to value 1. [Parsed_color_0 @ 00000211a0d7d980] Error applying options to the filter. [lavfi @ 00000211a0d79000] Error initializing filter 'color' with args 'c=black:s=hd1080:r=60000/1001:d=60:sar=1:1' color=c=black:s=hd1080:r=60000/1001:d=60:sar=1:1: Invalid argument
Ah! The problem was not size (as indicated). It was sar. This works: ffmpeg -f lavfi -i color=c=black:s=1920x1080:r=60000/1001:d=60:sar=1 test.mkv Now I need to figure out how to integrate this source into the rest of my work flow. On 02/08/2021 08:47 PM, Mark Filipak (ffmpeg) wrote:
I'm failing on the size. I can't explain why.
ffmpeg -f lavfi -i color=c=black:s=1920x1080:r=60000/1001:d=60:sar=1:1 test.mkv ffmpeg started on 2021-02-08 at 20:44:31 Report written to "ffmpeg-20210208-204431.log" Log level: 32 ffmpeg version N-100851-g9f38fac053 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 9.3-win32 (GCC) 20200320 configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --enable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp libavutil 56. 64.100 / 56. 64.100 libavcodec 58.119.100 / 58.119.100 libavformat 58. 65.101 / 58. 65.101 libavdevice 58. 11.103 / 58. 11.103 libavfilter 7.100.100 / 7.100.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 [color @ 0000029f0c0bda80] Unable to parse option value "1" as image size Last message repeated 1 times [color @ 0000029f0c0bda80] Error setting option size to value 1. [Parsed_color_0 @ 0000029f0c0bd980] Error applying options to the filter. [lavfi @ 0000029f0c0b9000] Error initializing filter 'color' with args 'c=black:s=1920x1080:r=60000/1001:d=60:sar=1:1'
color=c=black:s=1920x1080:r=60000/1001:d=60:sar=1:1: Invalid argument
ffmpeg -f lavfi -i color=c=black:s=hd1080:r=60000/1001:d=60:sar=1:1 test.mkv ffmpeg started on 2021-02-08 at 20:44:48 Report written to "ffmpeg-20210208-204448.log" Log level: 32 ffmpeg version N-100851-g9f38fac053 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 9.3-win32 (GCC) 20200320 configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --enable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --enable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp libavutil 56. 64.100 / 56. 64.100 libavcodec 58.119.100 / 58.119.100 libavformat 58. 65.101 / 58. 65.101 libavdevice 58. 11.103 / 58. 11.103 libavfilter 7.100.100 / 7.100.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 [color @ 00000211a0d7da80] Unable to parse option value "1" as image size Last message repeated 1 times [color @ 00000211a0d7da80] Error setting option size to value 1. [Parsed_color_0 @ 00000211a0d7d980] Error applying options to the filter. [lavfi @ 00000211a0d79000] Error initializing filter 'color' with args 'c=black:s=hd1080:r=60000/1001:d=60:sar=1:1'
color=c=black:s=hd1080:r=60000/1001:d=60:sar=1:1: Invalid argument
Mark,
I want to insert black frames into a stream on a regular basis. #1, Is that an input device? I think so. Or, #2, is it better/easier to repeat an input frame and blacken the repeated frame? Maybe.
I seek guidance. I've read everything I could find. Methinks #1 would be best. But if #2, would a 'pad' filter that covers the entire frame be best/easiest?
I think the tricky part is how to insert an additional frame in the video. May be you can split the video in two parts and then concat first part, additional frame, second part. You would also have to find a suitable solution for the audio track. Replacing one frame of the video by another image is easy, see chapter 2.40 in my book: http://www.astro-electronic.de/FFmpeg_Book.pdf Michael
On 02/09/2021 03:05 AM, Michael Koch wrote:
Mark,
I want to insert black frames into a stream on a regular basis. #1, Is that an input device? I think so. Or, #2, is it better/easier to repeat an input frame and blacken the repeated frame? Maybe.
I seek guidance. I've read everything I could find. Methinks #1 would be best. But if #2, would a 'pad' filter that covers the entire frame be best/easiest?
I think the tricky part is how to insert an additional frame in the video. May be you can split the video in two parts and then concat first part, additional frame, second part...
So far, the best I've been able to figure out is that the members of a split need to retain their periodic nature through their respective filtergraph branches, then to explicitly force their PTSs via 'setpts' as a function of frame number, 'n', just prior to 'interleave'. In other words, 'select' at the exit from a filtergraph branch, not at the entrance to a branch. It also appears that not all filters handle 'n' predictably -- I'm not sure about this -- as 'interleave' seems to interleave only via PTSs, not frame number. It would be very helpful if 'interleave' could be replaced by a programmable multiplexer that was "input 'n'-aware" and could multiplex and re-PTS its output based on a "input 'x', frame 'n'" script. Such a multiplexer could assemble an output stream from a loose, enqueued set of inputs. If that multiplexer existed, then the filtergraph branches wouldn't need to be periodic, but could output loose frames without PTSs. Ah, well.
... You would also have to find a suitable solution for the audio track. Replacing one frame of the video by another image is easy, see chapter 2.40 in my book: http://www.astro-electronic.de/FFmpeg_Book.pdf
Michael _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
-- I don't have a dog. And furthermore, my dog doesn't bite. And furthermore, you provoked him.
participants (3)
-
Carl Zwanzig -
Mark Filipak (ffmpeg) -
Michael Koch