Jump to content

ffmpeg CPU useage jumps.


Recommended Posts

Hi.

 

I have just recently started to play around with live TV streaming, and must say that I am very impressed so far.

 

However I am experiencing some weird behavior from ffmpeg when it comes to CPU useage.

 

I am streaming to my ihpone in 1024 kbit.

 

I am using RS 1.10.0 and most recent ffmpeg (ffmpeg-20120726-git-236ecc3-win32-static), and I have also tried some older builds of ffmpeg.

 

I am using the default settings for streaming. That means ultrafast in the settings.

 

The typical CPU useage is between 2-4%, but then for periods of up to ten seconds, it jumps to 95%+ CPU useage on all cores.

If I change from ultrafast to veryfast, I get a bit higher CPU useage, 3-6%, and there isnøt any of these jumps to 95%+ useage.

 

I have an i7 2700K, and I find it really hard to believe that ffmpeg should need all that power to transcode a 4 Mbit SD channel.

 

Have anyone experienced the same behavior?

Should I simply just use veryfast instead of ultrafast?

I guess that ultrafast was chosen as default for a reason.

 

I have deleted the file iphoneprefs.ini and stopped/started the RS.

 

I have attached a support.zip file.

 

Thanks in advance

 

rco133

support.zip

Link to comment

Hi.

 

Couldn't find an edit button, so I am replying to my own message :-)

 

I have spent quite some time today, experimenting with ffmpeg and live TV streaming.

 

I had the jumping CPU useage problem as described in my previous post, and I also had ffmpeg stopping for apparantly no reason once in a while.

 

I have now been streaming for hours, and I have not seen the ffmpeg CPU useage jump above 7% at any point.

 

All I have done is that I have edited the iphoneprefs.ini file, and replaced the first -threads {threads} with -threads 2

 

This seems to have solved all the issues that I had.

 

As stated earlier my CPU is an i7 2700k, and apparantly ffmpeg does something weird with CPU useage when running on such a CPU.

 

I have no idea if the same thing will happen on another CPU with the same number of cores.

 

But, it sure seems to have fixed the issues I had.

 

Hope that it can help out others.

 

Best regards

 

rco133

Link to comment

If i stream Viasat Nature( 5 mbs)-SD channel, on Iphone with superfast, i have 2-6% cpu usage quad core 6600@3.5ghz.

If i stream HD 15mbs channel premium, i have cpu usage 25-30% on super fast.

On ultrafast 15-20%.... Ultrafast is the best if you have smaller screen on tablet/mobile.

Also, the same usage i have if i stream an HD with http://my ip:8089/ from Desktop.

IF quote "ffmpeg stopping for apparantly no reason once in a while", you need to choose a lower bitrate, and set encoding to ultrafast or something.

Edited by bogdan1980
Link to comment

If i stream Viasat Nature( 5 mbs)-SD channel, on Iphone with superfast, i have 2-6% cpu usage quad core 6600@3.5ghz.

If i stream HD 15mbs channel premium, i have cpu usage 25-30% on super fast.

On ultrafast 15-20%.... Ultrafast is the best if you have smaller screen on tablet/mobile.

Also, the same usage i have if i stream an HD with http://my ip:8089/ from Desktop.

IF quote "ffmpeg stopping for apparantly no reason once in a while", you need to choose a lower bitrate, and set encoding to ultrafast or something.

 

Hi.

 

I have tried pretty much everything, lower bitrates, ultrafast, fast and what else. I still got those CPU jumps to 95%+, and ffmpeg just stopping once in a while.

 

After I have changed the {threads} to just 2 in iphoneprefs, I can stream for hours with ultrafast and CPU never goes above 5-6% with SD stream.

 

rco133

Link to comment

I have tried pretty much everything, lower bitrates, ultrafast, fast and what else. I still got those CPU jumps to 95%+, and ffmpeg just stopping once in a while.

 

After I have changed the {threads} to just 2 in iphoneprefs, I can stream for hours with ultrafast and CPU never goes above 5-6% with SD stream.

I do experiencing the stops as well especially when streaming recordings and videos (avi's mostly), but am not sure one can blame the ffmpeg syntax for it. Cannot even stream 5 minutes of SD material before it stops on lowest possible 256kbit. For unknown reasons streaming LiveTV always goes much better and if that hadn't been the case the stops would have been most likely due to bandwidth variations in the 3G net, but now I'm not so sure.

 

If testing changing the syntax, could you be more explicit on what changes you made?

 

Original

Cmd=-threads {threads} {offset} -i "{infile}" -threads {threads} -f mpegts -vcodec libx264 -bufsize 1024k -b:v 680k -bt 780k {framerate} -map 0:0 -map 0:1 -vf "yadif=0:-1:1, scale={scalex}:{scaley}" -preset {vpreset} -tune film -vprofile baseline -level 30 -acodec libmp3lame -ab 128k -ar 48000 -ac 2 -async 1 -y "{outfile}"

Changed

Cmd=-threads 2 {offset} -i "{infile}" -threads 2 -f mpegts -vcodec libx264 -bufsize 1024k -b:v 680k -bt 780k {framerate} -map 0:0 -map 0:1 -vf "yadif=0:-1:1, scale={scalex}:{scaley}" -preset {vpreset} -tune film -vprofile baseline -level 30 -acodec libmp3lame -ab 128k -ar 48000 -ac 2 -async 1 -y "{outfile}"

Is it correct?
Link to comment

This is what my new 1024 kbit looks like:

 

Cmd=-threads 2 {offset} -i "{infile}" -threads {threads} -f mpegts -vcodec libx264 -bufsize 1024k -b:v 680k -bt 780k {framerate} -map 0:0 -map 0:1 -vf "yadif=0:-1:1, scale={scalex}:{scaley}" -preset {vpreset} -tune film -vprofile baseline -level 30 -acodec libmp3lame -ab 128k -ar 48000 -ac 2 -async 1 -y "{outfile}"

 

The original one just have {threads} instead of 2.

 

I have only tried to change the first {threads}. I am not sure but I think it sets the global number, and probably overrules the one after {infile}.

 

But I have not had any issues after doing that change.

 

The original one runs fine on another dual core laptop I have. To me it looks like something with ffmpeg and many cores.

 

rco133

Link to comment

Hi,

 

I am also experiencing problems with occasional, or pretty much regular stops of ffmpeg when streaming HD or SD material.

In my case overall CPU usage does not exceed 65% even when streaming HD material. It doesn't matter what preset I choose (fast, faster, superfast or ultrafast), the problem remains.

I have tried to change the number of threads in the iphoneprefs.ini as described above to no avail.

It seems to me ffmpeg does not receive a consistent stream of data and simply stops working, but that's just a guess.

 

Any more ideas what I might try to keep ffmpeg from stopping?

 

Regards

 

Rheinländer

 

PS I am running the latest build of ffmpegx64 on a Windows 7 desktop computer.

Link to comment
×
×
  • Create New...