代码之家  ›  专栏  ›  技术社区  ›  yomateo

使用ffmpeg输出到HLS和图像静像

  •  1
  • yomateo  · 技术社区  · 7 年前

    二者都 一个HLS流和几个图像静像。我可以单独做这件事(很明显),但我很难把事情组合起来。能帮我个忙吗?

    以下是我的输出(有效):

    输出HLS流:

    ffmpeg -rtsp_transport tcp -i '$RTSP_URL'
        -c:v copy -b:v 64K -f flv rtmp://localhost/hls/stream_low \
        -c:v copy -b:v 512K -f flv rtmp://localhost/hls/stream_high
    

    输出图像静止:

    ffmpeg -hide_banner -i '$(RTSP_URL)' -y  \
        -vframes 1 -vf "scale=1920:-1" -q:v 10 out/screenshot_1920x1080.jpeg \
        -vframes 1 -vf "scale=640:-1" -q:v 10 out/screenshot_640x360.jpeg \
        -vframes 1 -vf "scale=384:-1" -q:v 10 out/screenshot_384x216.jpeg \
        -vframes 1 -vf "scale=128:-1" -q:v 10 out/screenshot_128x72.jpeg
    

    非常感谢您的帮助(我也发了一份赏金)

    谢谢大家!

    1 回复  |  直到 7 年前
        1
  •  2
  •   Gyan    7 年前

    简单地

    ffmpeg -rtsp_transport tcp -i '$RTSP_URL'
        -c:v copy -b:v 64K -f flv rtmp://localhost/hls/stream_low \
        -c:v copy -b:v 512K -f flv rtmp://localhost/hls/stream_high \
        -vframes 1 -vf "scale=1920:-1" -q:v 10 out/screenshot_1920x1080.jpeg \
        -vframes 1 -vf "scale=640:-1" -q:v 10 out/screenshot_640x360.jpeg \
        -vframes 1 -vf "scale=384:-1" -q:v 10 out/screenshot_384x216.jpeg \
        -vframes 1 -vf "scale=128:-1" -q:v 10 out/screenshot_128x72.jpeg
    

    请注意,正如输出协议所说,您的“HLS”流实际上是一个RTMP流。还有 -c:v copy ,没有视频编码,所以 -b:v