[FFmpeg-user] image2pipe to RTMP issues ("faster than realtime")

Travis Skindzier the.energetic at gmail.com
Tue May 18 18:02:57 EEST 2021


My goal is to stream to YouTube Live via RTMP as output, using the following 2 inputs:

1) Icecast audio stream... ffprobe output: Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
2) Headless chrome startScreencast api which is recording a webpage. Based on my knowledge it appears Chrome sends roughly 10 FPS, but without being certain, I assume this frame rate could vary based on page load, etc.

According to YouTube, these are the requirements for 720p @ 30:
- Resolution: 1280x720
- CBR encoding
- Bitrate Range: 1,500-4,000 Kbps
- 2 second keyframe

Issue #1) I’m getting the following error from YouTube currently: "Your encoder is sending data faster than realtime (you must send 1 second of video for each second)”

This error is the primary issue I’m trying to solve, but I have listed several sub-issues that my intuition tell me MAY be wrong as well. My understanding of video/ffmpeg is not in my expertise, so there could be many gross inefficiencies or bad approaches in my command. I would gladly welcome any critiques or suggestions for any other issues that stand out that I’m not seeing.

Issue #2) I remember reading somewhere that I may need to set an explicit framerate on the audio so it’s not “locked” to the video. Is this correct, and how would I do that?

Issue #3) I have seen several examples of RTMP streaming explicitly setting -threads 0. Is this recommended for live/realtime streaming? If so, how do I input them into the command?

Issue #4) I currently see that Chrome sends about 10 fps. My current implementation which I found is interpolating frames via a javascript loop. The solution seems very hacky and poorly written, and I’m wondering if there is a native way to do this in ffmpeg so that chrome can output 10 fps and ffmpeg can duplicate frames up to 30 fps.

Issue #5) Any other glaring issues you see I would love to hear them. I essentially crafted this command as a golden retriever would play with a tennis ball.

Below are my current flags (they are in exact order, but I added line breaks and comment headings for easier reading). Thank you!

// input audio
-thread_queue_size 1024
-i http://x.x.x.x/stream,

// input video
-thread_queue_size 1024
-f image2pipe
-i -

// output
-framerate 30
-pix_fmt yuv420p
-strict -2
-c:v libx264
-x264-params keyint=60
-preset veryfast
-b:v 2500k
-minrate:v 4000k
-maxrate:v 4000k
-bufsize:v 8000k
-f flv

More information about the ffmpeg-user mailing list