FFmpeg - Different (pre)settings. (1 Viewer)

j1nx

Portal Pro
July 16, 2005
233
10
I believe a couple of people have difficulties with live streaming and the ffmpeg settings chosen for the live streaming. Some people find them to high for there bandwidth, some people want more etc etc.

Until Cheezey implements either a manual option to choice your bandwith or true multi-bit rate, I think it is wise that we keep our tweaks, tips and questions about this settings centralized. (this or some sticky topic)

The following settings are distributed with the latest 5.1.0 version of iPiMP

CONFIX>XML
Code:
<appconfig>
  <transcoders>
    <transcoder name="LiveTV" usetranscoding="1" filename="&quot;D:/Program Files/iPiMP/Utilities/ffmpeg\ffmpeg.exe&quot;" args="-i - -threads 0 -re -vcodec libx264 -fpre &quot;D:/Program Files/iPiMP/Utilities/ffmpeg/ffpresets/libx264-iPiMP.ffpreset&quot; -b 256k -s 480x272 -aspect 480:272 -acodec libfaac -ac 2 -ab 64k -ar 48000 -ac 2 -async 2 -f ism http://192.168.254.9:88/SmoothStream.isml/Streams(SmoothStream)?dvr_window_length=15" inputmethod="2" outputmethod="4" />
    <transcoder name="Recording" usetranscoding="1" filename="&quot;D:/Program Files/iPiMP/Utilities/ffmpeg\ffmpeg.exe&quot;" args="-ss 420 -i &quot;{0}&quot; -threads 0 -re -vcodec libx264 -fpre &quot;D:/Program Files/iPiMP/Utilities/ffmpeg/ffpresets/libx264-iPiMP.ffpreset&quot; -b 256k -s 480x272 -aspect 480:272 -acodec libfaac -ac 2 -ab 64k -ar 48000 -ac 2 -async 2 -f ism http://192.168.254.9:88/SmoothStream.isml/Streams(SmoothStream)?dvr_window_length=15" inputmethod="0" outputmethod="4" />
    <transcoder name="TVSeries" usetranscoding="1" filename="&quot;D:/Program Files/iPiMP/Utilities/ffmpeg\ffmpeg.exe&quot;" args="-i &quot;{0}&quot; -threads 0 -re -vcodec libx264 -fpre &quot;D:/Program Files/iPiMP/Utilities/ffmpeg/ffpresets/libx264-iPiMP.ffpreset&quot; -b 256k -s 480x272 -aspect 480:272 -acodec libfaac -ac 2 -ab 64k -ar 48000 -ac 2 -async 2 -f ism http://192.168.254.9:88/SmoothStream.isml/Streams(SmoothStream)?dvr_window_length=15" inputmethod="0" outputmethod="4" />
    <transcoder name="Radio" usetranscoding="1" filename="&quot;D:/Program Files/iPiMP/Utilities/ffmpeg\ffmpeg.exe&quot;" args="-i - -threads 0 -re -acodec libfaac -ac 2 -ab 64k -ar 48000 -ac 2 -async 2 -f ism http://192.168.254.9:88/SmoothStream.isml/Streams(SmoothStream)?dvr_window_length=15" inputmethod="2" outputmethod="4" />
  </transcoders>
</appconfig>

libx264-iPiMP.ffpreset
Code:
coder=0
flags=+loop
cmp=+chroma
partitions=+parti4x4+parti8x8+partp8x8
me_method=umh
subq=5
me_range=16
g=100
keyint_min=50
sc_threshold=0
i_qfactor=0.71
qmin=10
qmax=51
refs=1
trellis=2
deblockalpha=0
deblockbeta=0
crf=24
level=30


To kick of with my question and problems;

My mepo machine only has a P4 2.4 GHz, so is not capable of live streaming. with the above settings, CPU spikes to 100% and encoding time of 1 second of video is close to 1 second if not higher. It means it needs buffering now and then.

What can I do to tweak the settings, lowering the encoding speed under 1 second per second. I don't give anything about the bandwidth. Wifi is fast enough and everything is connected to the outside world by a glass fibre 50/50 connection. I just want to go a bit easy on the CPU.
 

cheezey

Community Plugin Dev
August 26, 2004
1,560
312
56
West Yorks, UK
Home Country
United Kingdom United Kingdom
You could try changing libx264-iPiMP.ffpreset to

Code:
coder=0
bf=0
flags2=-wpred-dct8x8
wpredp=0
sc_threshold=0

this is just libx264-baseline (needed for the iPhone) with sc_threshold=0 added (on advice), this may reduce the work your processor has to do.

The other settings in libx264-iPiMP.ffpreset were collated from other forums discussing iPhone ffmpeg settings a couple of years ago - most are for h264 encoding and I'm not sure what they do :)
 

j1nx

Portal Pro
July 16, 2005
233
10
Thx, cheezey, but ias doesn't really work (no manifest file is created)

Did some reading, following link explains most stuff;
x264 ffmpeg mapping and options guide - Linux Encoding


I removed the "+partp8x8" from the partition settings,
Changed the "me_method" to "hex" variant,
Lowered the "me_range" to 8

Those settings will do the most for speed, making it work on older systems. At the cost of quality off course. You could play around with the settings to find the threshold for every other machine.

So my libx264-iPiMP.ffpreset now looks like;
Code:
coder=0
flags=+loop
cmp=+chroma
partitions=+parti4x4+parti8x8
me_method=hex
subq=5
me_range=8
g=100
keyint_min=50
sc_threshold=0
i_qfactor=0.71
qmin=10
qmax=51
refs=1
trellis=2
deblockalpha=0
deblockbeta=0
crf=24
level=30

EDIT:
There appears to be an inconstancy in the settings;
-coder 0 (FFmpeg)
CABAC is the default entropy encoder used by x264. Though somewhat slower on both the decoding and encoding end, it offers 10-15% improved compression on live-action sources and considerably higher improvements on animated sources, especially at low bitrates. It is also required for the use of trellis quantization. Disabling CABAC may somewhat improve decoding performance, especially at high bitrates. CABAC is not allowed in Baseline Profile. Recommended default: -coder 1 (CABAC enabled)

-trellis <0,1,2> (FFmpeg)

0: disabled

1: enabled only on the final encode of a MB

2: enabled on all mode decisions
The main decision made in quantization is which coefficients to round up and which to round down. Trellis chooses the optimal rounding choices for the maximum rate-distortion score, to maximize PSNR relative to bitrate. This generally increases quality relative to bitrate by about 5% for a somewhat small speed cost. It should generally be enabled. Note that trellis requires CABAC.

In the settings;
Code:
coder=0
trellis=2

Either coder needs to be "1" or trellis needs to be "0".
 

gibber

MP Donator
  • Premium Supporter
  • October 8, 2009
    35
    3
    Home Country
    Canada Canada
    I have similar problems when trying to stream high def files. Is there any way to enable DXVA (gpu assisted) conversion of the file?

    My MEPO setup does a nice job of playing up to 1080p video, but only when DXVA is enabled..
     

    j1nx

    Portal Pro
    July 16, 2005
    233
    10
    Nah, I think more is going on here. I still have problems encoding the content on a live basis with the "-re" option, but even with all settings adjusted to the lowest settings possible the process is still not fast enough.

    I'm still struggling to find out if it is FFMpeg or the smoothstream module. One of them is not optimal. It is not my bandwidth. I'm testing on WiFi, and to the outside world I have a 50 Mbit up and down glass fiber connection (is only 4 Mbit less)

    In the next coming days I plan to do some tests with other ffmpeg builds and the open source segmenter (httpsegmenter - Project Hosting on Google Code), which is way longer available then the codeshop solutions mp4split. The last ffmpeg build can handle the live http iphone segmented streaming option.
     

    cheezey

    Community Plugin Dev
    August 26, 2004
    1,560
    312
    56
    West Yorks, UK
    Home Country
    United Kingdom United Kingdom
    Getting a windows segmenter working was my first option (about a year ago) and I eventually managed to get one compiled for windows, not with any of the improvements listed on the above site though. The only downside with this option as I see it now it that the segmenting solution supports Apple's HTTP streaming, so us iPhone/iPad users are happy :) But everyone else isn't :( Codeshop's SmoothStreaming gives you Apple, Flash & Silverlight streaming all from the same process.
     

    j1nx

    Portal Pro
    July 16, 2005
    233
    10
    Getting a windows segmenter working was my first option (about a year ago) and I eventually managed to get one compiled for windows, not with any of the improvements listed on the above site though. The only downside with this option as I see it now it that the segmenting solution supports Apple's HTTP streaming, so us iPhone/iPad users are happy :) But everyone else isn't :( Codeshop's SmoothStreaming gives you Apple, Flash & Silverlight streaming all from the same process.

    Yes, I know. The segmenter is far from optimal. But yesterday I already did a quick test.

    Streamed one of my Bones episodes with iPiMP, looked like the whole process is behind, takes a lot of time to start and the encoding/segmenting process can't keep up, so you have the buffering every 10-20 seconds or so.

    Then I downloaded the segmenter from the above site, unpacked it into the same directory as iPimp. Downloaded an automated build of one of the latest ffmpeg windows versions from Automated FFmpeg Builds (I know...., but I don't want to setup a building environment) Copied the ffmpeg.exe from that build into the segmenter directory and editted the included start.bat to stream the same Bones episode. Encoding and streaming almost immediately starts and it is (WAY) faster, even with the settings untweaked whcih means a LOT more quality. Starting the bat and immediately opening the stream at the ipod, makes it running smoothly without hickups, buffering and a lot more quality?

    Still, as I replaced both, the segmenter and the ffmpeg build, I still don't know which one should be looked at. But at least I know, the machine and all should be capable of doing it.


    EDIT: hmmmm, while clicking around on that website about the windows build of segmenter I came across the scope of work - project of that segmenter. http://sm.espend.de/

    Maybe I'm silly, but would it not be a lot simpler to write a mediaportal module, just like the DVBviewer module. Look at this picture; (shows what it does)
    http://sm.espend.de/sites/default/files/resize/streamode-300x188.png

    EDIT2: Nope, let's cut the crap. Why would anyone want to install a full drupal system just to stream some stuff. But I think it is wise to have a look at his framework. Multiple sources going into the system, creating multiple frontends. Web, mobile and even dreambox or popcorn hour frontend.
     

    j1nx

    Portal Pro
    July 16, 2005
    233
    10
    Thanks Cheezey.

    Did some testing, and I guess I am at the exact limit of my hardware with the setup provided by you.

    For the testing, I skipped the live tv for a moment and went for an avi file. This ensures all test are at the same conditions. I also removed the "-re" (encoding at movie framerate)

    1) Smoothstream + ffmpeg_ipimp_orig > With all lowest settings, I'm able to get a 20 fps encoding. The avi is a 25 fps PAL movie, so not enought
    2) Smoothstream + ffmpeg_ipimp_dxva > 21-22 fps, so not a big difference. Thought that dxva was for decoding anyway instead of encoding, but am not an expert.
    3) Smoothstream + ffmpeg_static_latest svn build > 23 fps, slowing going down to 22 fps. Still not enough
    4) segmenter + ffmpeg (any version) > 27 fps, which is enough for the 25 fps PAL movie. second test with the "-re" option added shows 23 fps???, but ran a long term test and I can as good as watch the whole movie without stuttering or buffering (tested for 30 minutes)

    So I guess the smoothstream module from codeshop is a bit of a overkill, but as all my fps target are so close to the at least required 25 fps I guess I'm touching the limit of this old P4 system.

    For other people who want to tweak or have problems. The ffmpeg output, including all the fps statistics are outputted to the apache error.log You can check if there if the encoding process is enough for the framerate of the content (pal=25fps, ntsc=?)

    Thx, so far.
     

    Lolento

    Portal Pro
    September 9, 2006
    150
    7
    47
    Home Country
    United States of America United States of America
    can somebody explain how to decrease the bitrate of the stream?

    also, is there a method for iPimp to differentiate between 3g and wifi connections?
     

    Users who are viewing this thread


    Write your reply...
    Top Bottom