Live streaming

Questions involving a Windows version of FFmpeg.
Post Reply
Posts: 1
Joined: Mon Oct 09, 2017 11:10 am

Live streaming

Post by Mher594 » Mon Oct 09, 2017 11:26 am

Hi, I have a program which saves mpeg video and runs FFmpeg.exe to stream the video. My program saves about 30 fps video, FFmpeg.exe stream the video with 30 fps, however FFmpeg sometimes crashes. I think my program saves below 30 fps and FFmpeg reach the end of the video (can it be a problem?).

Below is how I start FFmpeg

%ffmpeg% -re -i %fileloc%%file%.mpg -deinterlace -vcodec h264_nvenc -pix_fmt yuv420p -s hd720 -threads 4 -preset fast -r 30 -g 60 -b:v 2000k -ar 44100 -b:a 4000000 -bufsize 2049k -f flv rtmp:// 2> %fileloc%%file%_Info.txt

Below is last lines in log

[mpeg1video @ 0000003885526240] Warning MVs not available
[mpeg1video @ 0000003885526240] concealing 2880 DC, 2880 AC, 2880 MV errors in B frame
[flv @ 00000038855291a0] Failed to update header with correct duration.
[flv @ 00000038855291a0] Failed to update header with correct filesize.
frame= 542 fps= 29 q=14.0 Lsize= 3756kB time=00:00:18.65 bitrate=1649.2kbits/s dup=0 drop=17 speed=0.987x
video:3745kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.290632%

I want FFmpeg to wait for input instead of closing, is that possible? What parameters should I pass? Thanks.

Posts: 51
Joined: Thu May 12, 2011 5:19 pm

Re: Live streaming

Post by navilor » Mon Nov 13, 2017 1:48 am

It looks like you are having a problem decoding that content. The content may be bad. I never trust any content that comes across my desk. An early FFmpeg ticket agrees with this.

Another post on a different website also shows the same errors you have. ... PEG-1-file

I've also had bad builds happen now and then. Give this a shot and use x264 instead of the h264_nvenc codec.

Code: Select all

ffmpeg -re -i %fileloc%%file%.mpg -pix_fmt yuv420p -vsync 1 -deinterlace -vcodec libx264 -r 30 -threads -g 60 -x264opts no-scenecut -b:v: 2000k -bufsize 2250k -maxrate 2500k -preset veryfast -profile:v baseline -tune film  -acodec aac -b:a 192k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -f flv rtmp://
The following may also work, but I am unfamiliar with h264_nvenc.

Code: Select all

ffmpeg -re -i %fileloc%%file%.mpg -pix_fmt yuv420p -vsync 1 -deinterlace -vcodec h264_nvenc -s 1280x720 -r 30 -g60 -sc_threshold 0 -threads 0 -b:v: 2000k -bufsize 2250k -maxrate 2500k -preset fast -profile:v baseline -tune film -acodec aac -b:a 192k -ac 2 -ar 44100 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -f flv rtmp://
In both cases do not dump the text output or errors to a file so that you can see the errors happen as they go by. Yellow is a warning and red is an error. Fix errors first and worry about warnings later.

If using x264 works but using h264_nvenc does not work make sure to update to the latest Nvidia drivers. I recommend the following procedure for uninstalling your drivers. Make sure that if you use that method that you remove the nvidia folder from your Windows box before you reboot. If not it will attempt to install the old drivers right away. ... s-new-2016

You can also move to a different decoder if GPU acceleration is causing you grief.

I also have a blog post that might help, but it is geared towards file to file conversion. Look to see if you can merely convert the file before attempting to stream it. ... -it-wrong/

Post Reply