Jump to content

I have FFMPEG working with the 'tee' encoder such that FFMPEG receives video via RTMP, encodes it, then simultaneously writes to file and streams to online.  When the internet connection lags out, the online stream obviously cuts out for a few moments and the "dup" frames build up on FFMPEG.  I don't have a problem with that specifically, but the local file that's being written also exhibits the duplicated frames.  My encoder isn't anywhere near being overloaded, the bottleneck in this case is my upload speed.  I don't care if the streamed version is choppy and bad, but the locally saved copy should be the gold standard without duplicated frames.  There's no local bottleneck that should cause the file to duplicate frames, but FFMPEG is just making the streamed and local copies identical. 

 

Is there a way to have FFMPEG favor the quality of the local file and attempt to stream a copy of the local file while resources are available thus preserving the quality locally and only sacrificing the quality of the stream in low-bandwidth situations?

If I have to explain every detail, I won't talk to you.  If you answer a question with what can be found through 10 seconds of googling, you've contributed nothing, as I assure you I've already considered it.

 

What a world we would be living in if I had to post several paragraphs every time I ask a question.

Link to post
Share on other sites

Ok, I think I got a solution to this: I run ffmpeg with the 'tee' encoder and save to a local file while simultaneously streaming to rtmp://localhost (my local RTMP server) but on a different address from the incoming stream.  I then run a second instance of ffmpeg to receive the new RTMP stream and directly 'copy' the codec to whatever platform I'm streaming to. 

 

Unfortunately, this results in about 20 seconds of lag. 

If I have to explain every detail, I won't talk to you.  If you answer a question with what can be found through 10 seconds of googling, you've contributed nothing, as I assure you I've already considered it.

 

What a world we would be living in if I had to post several paragraphs every time I ask a question.

Link to post
Share on other sites

I have a stream box that has an rtmp server configured to receive streams, so I have a local OBS instance on my gaming computer that does minimal compression and sends it to the stream box for compression and streaming.

 

I have environment variables set in a shell script that I execute, the actual ffmpeg command is

ffmpeg -loglevel $LOGLEVEL -analyzeduration $ANALYZEDUR -probesize $PROBESIZE -i rtmp://localhost/live/test -s "$INRES" -framerate "$FPS" -f tee -map 0 -flags +global_header -vcodec libx264 -g $GOP -keyint_min $GOPMIN -b:v $CBR -minrate $MINRT -maxrate $MAXRT -pix_fmt yuv420p -s $OUTRES -preset $QUALITY -acodec copy -threads $THREADS -strict normal -bufsize $BUFSIZE "[onfail=ignore:f=flv]output-$DATETIME.flv|[f=flv]rtmp://localhost/live/test2

which should wait a few seconds for me to get OBS streaming to rtmp://localhost/live/test; this saves the stream to the hard drive and streams it to rtmp://localhost/live/test2 which is picked up by a second ffmpeg instance

ffmpeg -loglevel $LOGLEVEL -analyzeduration $ANALYZEDUR -probesize $PROBESIZE -i rtmp://localhost/live/test2 -s "$INRES" -framerate "$FPS" -f tee -map 0 -flags +global_header -vcodec copy -acodec copy -strict normal -bufsize $BUFSIZE "[f=flv]$WEBSITENUMBERONE|[f=flv]$OTHERSTREAMSITES"

which has almost no overhead since it's just copying the output of the first ffmpeg instance and streaming it to (streaming sites).  The overall delay is about 30 seconds or so, but if the internet starts forcing dropped frames this seems to ensure the local copy is unscathed. 

If I have to explain every detail, I won't talk to you.  If you answer a question with what can be found through 10 seconds of googling, you've contributed nothing, as I assure you I've already considered it.

 

What a world we would be living in if I had to post several paragraphs every time I ask a question.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×