gpt4 book ai didi

ffmpeg - ffmpeg -filter_complex 置换的幽灵图像问题

转载 作者:行者123 更新时间:2023-12-04 23:32:51 26 4
gpt4 key购买 nike

我(几乎)能够应用基于 2 个动画高斯噪声视频的置换,但我遇到了重影图像的问题。 A picture is worth a thousand words .
在这里,您有一个复制问题的脚本:

ffmpeg -y -t 2 -f lavfi -i color=c=blue:s=160x120 -c:v libx264 -tune stillimage -pix_fmt rgb24 00_empty.mp4
ffmpeg -y -i 00_empty.mp4 -vf "drawtext=text=string1:y=h/2:x=w-t*w/2:fontcolor=white:fontsize=60" 01_text.mp4
ffmpeg -y -t 2 -f lavfi -i color=c=gray:s=160x120 -c:v libx264 -tune stillimage -pix_fmt rgb24 02_gray.mp4
ffmpeg -y -i 01_text.mp4 -i 02_gray.mp4 -i 02_gray.mp4 -filter_complex "[0][1][2]displace=edge=mirror" 03_displaced_text.mp4
它创建带有滚动文本和灰色虚拟视频的测试视频。然后它基于灰色视频应用位移。如果我理解正确,因为灰色视频是 100% 灰色,它应该保持视频不变(或者可能将所有内容替换固定数量的像素),但是 it creates a "shadow" .我尝试了 3 种不同的像素格式(yuv420p、yuv444p、rgb24),因为我在 stackoverflow 上发现了这个问题:
  • Why are Cb and Cr planes displaced differently from lum by the displace complex filter in ffmpeg?

  • ffmpeg 版本 5.0.1-full_build-www.gyan.dev
    任何想法都会受到欢迎。
    谢谢!

    最佳答案

    解决方法:使用-pix_fmt rgb24并添加 -c:v libx264rgb对所有命令进行修复:

    ffmpeg -hide_banner -y -t 2 -f lavfi -i color=c=blue:s=160x120 -tune stillimage -c:v libx264rgb -pix_fmt rgb24 00_empty.mp4
    ffmpeg -hide_banner -y -i 00_empty.mp4 -vf "drawtext=text=string1:y=h/2:x=w-t*w/2:fontcolor=white:fontsize=60" -c:v libx264rgb -pix_fmt rgb24 01_text.mp4
    ffmpeg -hide_banner -y -t 2 -f lavfi -i color=c=gray:s=160x120 -tune stillimage -c:v libx264rgb -pix_fmt rgb24 02_gray.mp4
    ffmpeg -hide_banner -y -i 01_text.mp4 -i 02_gray.mp4 -i 02_gray.mp4 -filter_complex "[0][1][2]displace=edge=mirror" -c:v libx264rgb -pix_fmt rgb24 03_displaced_text.mp4
    感谢 poisondeathray's answer in a post at forum.videohelp.com :

    the real reason is the 8it RGB to YUV gray conversion for 02_gray.mp4 becomes YUV 126,128,128 (loss of accuracy from the 8bit conversion)https://github.com/FFmpeg/FFmpeg/blob/master/libavfilter/vf_displace.c
    If you supply a true gray YUV 128,128,128 video it works ok too

    关于ffmpeg - ffmpeg -filter_complex 置换的幽灵图像问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72866523/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com