我正在使用ffmpeg读取一个rtmp流,添加一个过滤器,如模糊框,并创建一个不同的rtmp流。
例如,该命令如下所示:
ffmpeg -i <rtmp_source_url> -filter_complex "split=2[a][b];[a]crop=w=300:h=300:x=0:y=0[c];[c]boxblur=luma_radius=10:luma_power=1[blur];[b][blur]overlay=x=0:y=0[output]" -map [output] -acodec aac -vcodec libx264 -tune zerolatency -f flv <rtmp_output_url>
其中rtmp_source_url是摄影机/无人机发送通量的位置,rtmp_output_url是带有模糊长方体的结果视频。
模糊框需要移动,要么是因为目标移动了,要么是因为相机移动了。我希望在不中断输出流的情况下这样做。
我使用fluent-ffmpeg来创建ffmpeg进程,而程序的不同部分则计算模糊框所在的位置。
感谢您的帮助和时间!
发布于 2021-09-24 23:29:03
考虑使用管道来拆分处理。查看此处- https://ffmpeg.org/ffmpeg-protocols.html#pipe
The accepted syntax is:
pipe:[number]
number is the number corresponding to the file descriptor of the pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr). If number is not specified, by default the stdout file descriptor will be used for writing, stdin for reading.
For example to read from stdin with ffmpeg:
cat test.wav | ffmpeg -i pipe:0
# ...this is the same as...
cat test.wav | ffmpeg -i pipe:
For writing to stdout with ffmpeg:
ffmpeg -i test.wav -f avi pipe:1 | cat > test.avi
# ...this is the same as...
ffmpeg -i test.wav -f avi pipe: | cat > test.avi
例如,您读取一个rtmp流,添加一个模糊框等过滤器,然后创建一个不同的rtmp流。因此,第一步是将传入和传出的流分开-
ffmpeg -i <rtmp_source_url> -s 1920x1080 -f rawvideo pipe: | ffmpeg -s 1920x1080 -f rawvideo -y -i pipe: -filter_complex "split=2[a][b];[a]crop=w=300:h=300:x=0:y=0[c];[c]boxblur=luma_radius=10:luma_power=1[blur];[b][blur]overlay=x=0:y=0[output]"
-map [output] -acodec aac -vcodec libx264 -tune zerolatency -f flv <rtmp_output_url>
我不知道你有什么标准来改变模糊框,但现在你可以在第二个ffmpeg中处理传入的帧。此外,我使用1920x1080
作为视频大小-您可以将其替换为实际大小。
对于第一次迭代,不要担心音频,做你的模糊操作。当我们输入rawvideo
时--在这个例子中,音频将被忽略。
https://stackoverflow.com/questions/69220124
复制相似问题