ffmpeg rtmp 封装发送函数_如何使用ffmpeg命令生成RTMP测试流?

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

I do run locally a streaming server based on NGINX and its RTMP module.

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 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, scaling, profile, etc are just an example and can be ommited/played with. The point is using -i testsrc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值