如何使用ffmpeg命令生成RTMP测试流? [英] How to generate an RTMP test stream using ffmpeg command?

查看:412
本文介绍了如何使用ffmpeg命令生成RTMP测试流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过生成带有时间戳的RTMP测试视频来测试我的流媒体基础架构.看起来像是屏幕 .图像没关系.我只在工作流动态生成和时间戳之后.我打算为此目的使用 ffmpeg 工具.该命令可能类似于

I would like to test my streaming infrastructure by generating an RTMP test video with a timestamp. This could look like that screen. The image doesn't matter. I'm after the working stream generated on-the-fly and timestamp only. I intend to use the ffmpeg tool for that purpose. The command could look something like

$ ffmpeg -i image.png \
    -vf drawtext="fontfile=/Library/Fonts/Arial.ttf: \
        timecode='00\:00\:00\:00': r=1: fontcolor=white: \
        fontsize=24: box=1: boxcolor=black@0.5: \
        boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2" \
    -f flv rtmp://localhost/live/test

我确实在本地运行基于NGINX及其RTMP模块的流服务器.

但是,以上命令给了我以下错误:

However, the above command gives me the following error:

Input #0, png_pipe, from 'image.png':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: png, rgb24(pc), 768x576 [SAR 7874:7874 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> flv1 (flv))
Press [q] to stop, [?] for help
[Parsed_drawtext_0 @ 0x7fb78450ece0] Using non-standard frame rate 1/1
Output #0, flv, to 'rtmp://localhost/live/test':
  Metadata:
    encoder         : Lavf57.71.100
    Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 768x576 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.89.100 flv
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
[flv @ 0x7fb785812a00] Failed to update header with correct duration.
[flv @ 0x7fb785812a00] Failed to update header with correct filesize.
frame=    1 fps=0.0 q=8.6 Lsize=      50kB time=00:00:00.00 bitrate=406016.0kbits/s speed=0.019x
video:49kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.451271%

流服务器正常运行.问题出在命令上.有人可以帮助我吗?

The streaming server operates as expected. The problem is with the command. Would anyone be able to help me?

推荐答案

ffmpeg具有testsrc您可以用作测试源输入流:

ffmpeg has testsrc you can use as a test source input stream:

ffmpeg -r 30 -f lavfi -i testsrc -vf scale=1280:960 -vcodec libx264 -profile:v baseline -pix_fmt yuv420p -f flv rtmp://localhost/live/test

-r,缩放比例,配置文件等仅是示例,可以省略/播放.重点是使用-i testsrc

-r, scaling, profile, etc are just an example and can be ommited/played with. The point is using -i testsrc

这篇关于如何使用ffmpeg命令生成RTMP测试流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆