ffmpeg-python库可以用来在python里调用ffmpeg完成码流获取,转换,转发等操作

ffmpeg-python: Python bindings for FFmpeg — ffmpeg-python documentation

官网就有很多例子

还有个库是pyav

PyAV Documentation — PyAV 8.0.2.dev0 documentation

ffmpeg编译的参数设置:

ffmpeg configure配置选项_一个人像一支队伍-CSDN博客_ffmpeg许可证

编译后找不到库的处理

解决ffmpeg执行报错“ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory”的问题 - Comex - 博客园

综合解决ffmpeg安装及运行问题

安装开发包

简单的摄像头转udp码流的python例子

import ffmpeg
video_format = "mpegts"
server_url = "udp://127.0.0.1:1236"

process = (
    ffmpeg
    .input("/dev/video0")
    .output(
        server_url, 
    #    codec = "copy", # use same codecs of the original video
        listen=1, # enables HTTP server
        f=video_format)
  #  .global_args("-re ") # argument to act as a live stream
    .run()
)