Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th June 2011, 17:01   #1  |  Link
MuTPu4
Registered User
 
Join Date: Aug 2009
Posts: 6
x264 settings for live streaming to Adobe Flash

Hello,

I am working on realtime encoding of dynamically synthesized SD (352 x 480p @ 25) video streams for Internet broadcast.
I know that there is a problem with H.264 buffering in Adobe Flash Player, there is either zero buffer (NetStream.bufferTime = 0) or >=64 frames buffer (NetStream.bufferTime > 0). Also I know that live encoder settings (like x264's tune=zerolatency) noticeably reduce quality (given the same bandwidth).
So I am trying to create two kinds of settings profiles, one with buffering (NetStream.bufferTime = 0.1), B-frames, lookahead and other H.264 features (hoping for 3-4 seconds latency and stable quality) and one with no buffering and zerolatency features (hoping for <1 seconds latency, lower quality and some minor artifacts) and evaluate these profiles for different real-world Internet connections.
I have followed official x264 pages on MeWiki and numerous posts on relevant forums (Doom9, Doom10, Wowza Media Systems, etc) and have done a lot of experimenting but I am not really satisfied with the result. I am not an expert in video encoding domain and I hope that more experienced readers may point out the obvious shortcomings of my profiles or give some other tips.

Medium latency
Code:
{threads=1,profile=main,preset=faster,intra-refresh,bframes=2,ref=2,level=3,scenecut=40, \
qpmax=28,qpmin=16,weightp=1,keyint=50,keyint_min=25,b-adapt=0,deblock=-1:-2,fullrange=on,bitrate=640}
This is the most acceptable setup. I am not sure about the necessity of some settings here (such as level, qp, scenecut, etc) but all of my recent experiments resulted in worse quality so I have decided to leave them as is. The problem is the quality is not as stable as I want it to be. In a highly-dynamic scene video sometimes stops for several seconds and then plays faster for several seconds. It happens frequently on Internet connection (>1 Mbit, 250ms latency) and not so frequently on LAN (100Mbit, <1ms latency) but it is not accaptable for interactive/live application which allready has 4 seconds latency. The other minor problem is the picture is not so crisp as the original contrasting synthesized animation. I have tried to use lower deblock parameters hoping to overcome this problem but with no great success. Maybe there are some other ways?

Low latency
Code:
{threads=1,profile=main,preset=faster,tune=zerolatency,intra-refresh,weightp=1,keyint=30, \
min-keyint=5,deblock=-1:-2,fullrange=on,bitrate=1000}
This setup is almost useless for now. It has all of the shortcomings of the first setup but with considerably higher magnitudes. Namely a poor image quality, unstable framerate (I had got around continuous stuttering but frequent slowdowns and speedups are taking place as it described above) and most importantly the latency is still very high, around 2 second or even more (on LAN) so there is no practical gain of this setup.

I am sure that my settings are far from perfect but I have doubt about the stability of the other components of the system also. I am synthesizing frames with relatively constant speed slightly higher than target 25 FPS (27-29 FPS actually), some fluctuations may be imposed due to timers inaccuracy and non-RT OS activity. These frames are piped to VLC which transcodes it using x264 and streams it over RTP (using LIVE555 I suppose) to Wowza Media Server which in turn publishes it over RTMP. According to my observations VLC (and maybe LIVE555) lacks industrial grade reliability (being a great software though), so I am not sure if is it their limitations. Wowza on the other hand seems to improve playback smoothness after restreaming (I am varying It's buffers sizes accordings to manual from 15 to 66 frames).

So the question is, is there anything I can do with this architecture to achive my goals or just to improve my results in terms of quality, stability or latency. For example it would be really useful and reasonable to reduce latency of the Low latency profile to <1 seconds or to make Medium latency streaming fully stable and crisp but all of my recent attempts failed so I am asking for help of any kind.

Thanks in advance!

Last edited by Guest; 17th June 2011 at 17:10. Reason: readability
MuTPu4 is offline   Reply With Quote
Old 17th June 2011, 18:07   #2  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,688
Quote:
Originally Posted by MuTPu4 View Post
Low latency
Code:
{threads=1,profile=main,preset=faster,tune=zerolatency,intra-refresh,weightp=1,keyint=30, \
min-keyint=5,deblock=-1:-2,fullrange=on,bitrate=1000}
This setup is almost useless for now. It has all of the shortcomings of the first setup but with considerably higher magnitudes. Namely a poor image quality, unstable framerate (I had got around continuous stuttering but frequent slowdowns and speedups are taking place as it described above) and most importantly the latency is still very high, around 2 second or even more (on LAN) so there is no practical gain of this setup.
How do you expect this to be "low latency"? There isn't even any bandwidth constraint whatsoever.

Furthermore, if there's latency on a LAN, have you checked your client settings? Most clients, Flash included, buffer large amounts by default unless you tell them not to.

Quote:
Originally Posted by MuTPu4 View Post
The problem is the quality is not as stable as I want it to be. In a highly-dynamic scene video sometimes stops for several seconds and then plays faster for several seconds.
This does not sound related to x264 in the slightest. Though it might be caused by the fact that you haven't given x264 any bandwidth limitations!

Quote:
Originally Posted by MuTPu4 View Post
I have tried to use lower deblock parameters hoping to overcome this problem but with no great success.
Lowering deblock parameters will not make the image "more crisp".

Last edited by Dark Shikari; 17th June 2011 at 18:10.
Dark Shikari is offline   Reply With Quote
Old 21st June 2011, 15:29   #3  |  Link
MuTPu4
Registered User
 
Join Date: Aug 2009
Posts: 6
Hello, Dark Shikari.

I am really thankful for your reply. As you can see I am new to video encoding domain. I have done a lot of experimenting with x264 and Flash Player but I am using semi-official guides as a main source of information (like ones on MeWiki) and I have no algorithmic background here so maybe you can elaborate a little more on your advices.

Quote:
Originally Posted by Dark Shikari View Post
How do you expect this to be "low latency"? There isn't even any bandwidth constraint whatsoever.
I am using bitrate setting which implies (unrestricted) ABR mode (according to my reading of this and this). My simplified understanding is that it constraints bit rate at the average (during a session) while instantaneous (and even local) bit rate deviations may be high but it must be acceptable at least for my LAN experiments which effectively has nearly unlimited bandwidth (maybe actual bit rate is also restrained by my qp[max|min] settings). If you are talking about VBV compliant CBR/ABR mode, such hard bit rate limit is really desirable but I could not make it work as I expected. Generally I have tried all of the available 1-pass rate control methods and I have specified the only one that worked for me as I expected.
After reading your message I have done a dozen more tests with different VBV-enabled settings and have got the same negative results. The vbv-maxrate limit has worked (I hope) but the image quality, framerate stability and latency all have become worse with latency sometimes near 10 seconds so it doesn't worth it. I have used this guide but I have no sufficiently comprehensive understanding of the Leaky Bucket Algorithm or of the other under-the-hood machinery so I could accidentally make significant mistakes and I hope experienced readers could point it out. For the same reasons I do not understand the relations between zerolatency tune and the encoder VBV model which you have pointed out (why VBV must be enabled?).

Quote:
Originally Posted by Dark Shikari View Post
Furthermore, if there's latency on a LAN, have you checked your client settings? Most clients, Flash included, buffer large amounts by default unless you tell them not to.
Of course I did, as I pointed out in the beginning of my first post. I have made as many efforts to configure client-side as I had on server-side and encoder. The problem is there is not much I can do with the Adobe Flash Player client. But I have done as much as I could and the existence of two profiles is an artifact of the client-side buffering issues. Adobe Flash Player is one of the most widespread AVC clients and I have some positive feedbacks about disabled buffering (NetStream.bufferTime = 0, Low latency setup) so I hope I can make it work reliably with some help.

Quote:
Originally Posted by Dark Shikari View Post
This does not sound related to x264 in the slightest. Though it might be caused by the fact that you haven't given x264 any bandwidth limitations!
The question itself is not x264-related only, it is somewhat more general including AVC streaming and playback. x264 is just the main component of the pipeline and is the only component which is finely tunable and which I have not configured already. If there is some other known issues with Flash Player, Wowza or overall system architecture I am ready to accept any suggestions.

Quote:
Originally Posted by Dark Shikari View Post
Lowering deblock parameters will not make the image "more crisp".
I have followed this semi-official guide and the link cited there. It is clearly stated there that with higher deblocking parameters picture became more blurry and with lower deblocking parameters picture became more crisp:
Quote:
higher values deblock more effectively, but also destroy more detail and cause the entire image to be softened. The default value of 0 is almost always sufficient to get rid of most blocking (especialy when using a cqm), but leaves the picture noticibly blurier.
...
Alpha Deblocking is the most important parameter in determining the overal sharpness of your encode.
...
If you wan't to give your encodes a more detailed look and don't mind the occasional block try a setting of -2:-1. If you like a clean picture and don't mind a little bluriness try 1:2. A nice trick for anime is to use lower beta deblocking setting because it won't blur out lines as much that way.
Is this incorrect? Anyway lower deblocking settings have not improved clearness a lot so maybe there is some other settings which I can use for synthesized animation (aq-strength, psy-rd)?

I am copying one of my new configurations which was not really successful (NetStream.bufferTime = 0, CBR):
Code:
{threads=1,profile=main,preset=faster,tune=zerolatency,intra-refresh,weightp=1,keyint=30, \
min-keyint=5,deblock=-1:-2,fullrange=on,bitrate=1000,vbv-maxrate=1000,vbv-bufsize=500}
Thank you for your time. I am still looking forward for any help.
MuTPu4 is offline   Reply With Quote
Reply

Tags
flash, latency, live, vlc, x264

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:43.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.