ffmpeg livestream from static image and audio

走远了吗. 提交于 2019-12-12 04:49:32

问题


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-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 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 size= 2261kB time=00:02:24.19 bitrate= 128.4kbits/s speed= 16x

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] 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.

Please help to fix it.


回答1:


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://"


来源:https://stackoverflow.com/questions/44128029/ffmpeg-livestream-from-static-image-and-audio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!