首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >更新ffmpeg过滤器而不中断rtmp流

更新ffmpeg过滤器而不中断rtmp流
EN

Stack Overflow用户
提问于 2021-09-17 08:25:05
回答 1查看 90关注 0票数 2

我正在使用ffmpeg读取一个rtmp流,添加一个过滤器,如模糊框,并创建一个不同的rtmp流。

例如,该命令如下所示:

代码语言:javascript
运行
复制
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进程,而程序的不同部分则计算模糊框所在的位置。

感谢您的帮助和时间!

EN

回答 1

Stack Overflow用户

发布于 2021-09-24 23:29:03

考虑使用管道来拆分处理。查看此处- https://ffmpeg.org/ffmpeg-protocols.html#pipe

代码语言:javascript
运行
复制
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流。因此,第一步是将传入和传出的流分开-

代码语言:javascript
运行
复制
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时--在这个例子中,音频将被忽略。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69220124

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档