从静态图像和音频的ffmpeg直播 [英] ffmpeg livestream from static image and audio

查看:267
本文介绍了从静态图像和音频的ffmpeg直播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用静态图像和音频文件通过ffmpeg进行直播.像这样的ffmpeg命令

I'm trying to livestream by ffmpeg using static image and audio file. The ffmpeg command like this

ffmpeg -re -loop 1 -f image2 -i'/tmp/11.jpg'-f lavfi -i amovie =/tmp/5117.mp3:loop = 999 -video_size 600x480 -c:v libx264 -x264-参数keyint = 60 -bufsize 500k -c:a aac -ar 44100 -b:a 128k -r 30 -g 60 -pix_fmt yuv420p -f flv"rtmp://"

ffmpeg -re -loop 1 -f image2 -i '/tmp/11.jpg' -f lavfi -i amovie=/tmp/5117.mp3:loop=999 -video_size 600x480 -c:v libx264 -x264-params keyint=60 -bufsize 500k -c:a aac -ar 44100 -b:a 128k -r 30 -g 60 -pix_fmt yuv420p -f flv "rtmp://"

/tmp/11.jpg由另一个进程生成,并且每秒更新两次. ffmpeg命令看起来不正确,首先,它显示这样的状态

/tmp/11.jpg was generated by another process and keep updated twice per second. The ffmpeg command doesn't look right, first, it show status like this

frame = 85 fps = 9.4 q = 29.0大小= 2261kB时间= 00:02:24.19比特率​​= 128.4kbits/s速度= 16x

frame= 85 fps=9.4 q=29.0 size= 2261kB time=00:02:24.19 bitrate= 128.4kbits/s speed= 16x

如您所见, 16x 不好,直播的正确值是1x.然后,过一会儿,它会显示很多这样的警告日志

As you see, 16x is not good, 1x is the right value for livestream. Then, after a while, it show many warning log like this

[flv @ 0x322bd60]输出流0:1中的非单调DTS;前一个:335993,当前:297752;更改为335993.这可能会导致输出文件中的时间戳不正确.

[flv @ 0x322bd60] Non-monotonous DTS in output stream 0:1; previous: 335993, current: 297752; changing to 335993. This may result in incorrect timestamps in the output file.

请帮助修复它.

推荐答案

影片过滤器不会重置时间戳,因为时间戳说明了FLV混合器的DTS警告.您可以使用实时过滤器来减慢输出视频的处理速度.

The movie filters don't reset timestamps, which accounts for the DTS warnings by the FLV muxer. You can slow the output video processing by using the realtime filter.

ffmpeg -loop 1 -f image2 -i '/tmp/11.jpg'
  -f lavfi -i amovie=/tmp/5117.mp3:loop=999,asetpts=N/SR/TB
  -vf realtime,scale=600:480,format=yuv420p
  -r 30 -g 60 -c:v libx264 -x264-params keyint=60 -bufsize 500k
  -c:a aac -ar 44100 -b:a 128k -f flv "rtmp://"

这篇关于从静态图像和音频的ffmpeg直播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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