Quantcast Mencoder: Pseudo Min Bitrate with Noise? - digitalFAQ.com Forums [Archives]
Go Back    digitalFAQ.com Forums [Archives] > Video Production Forums > Video Encoding and Conversion

Reply
 
LinkBack Thread Tools
  #1  
05-11-2004, 11:47 AM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
@vmesquita,

Just an idea.
Because setting the MIN bitrate in mencoder/ffmpeg just doesn't work correctly, and causes all kinds of side effects (quantization errors, etc.), I have a suggestion.
Could you encode a "black" source (no video) and add "noise" parameter with very low values, until you get an average bitrate of ~300Kbps
This way, you have a fixed low bitrate noise stream, which guaranteed a minimum bitrate on black scenes.
I, and many others too, have problems with MIN bitrates. For example, on my JVS player, when a movie starts, right after the initial credits where it goes to total black before switching to the start of the movie, that single 1 second pause comes out to 7 or 8 seconds of "stutter", until the MIN bitrate passes a treshold, and from there on the rest of the movie is fine.
But on some rare scenes, and on some movies, where there is a total black scene, this effect could repeat.
I assume that a very low constant level of noise, will not be visible, but will maintain the video stream at a level that will help with the issue.
What do you think

-kwag
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
05-11-2004, 12:02 PM
Prodater64 Prodater64 is offline
Free Member
 
Join Date: Mar 2003
Location: Palma de Mallorca - España
Posts: 2,925
Thanks: 0
Thanked 0 Times in 0 Posts
@ Kwag: Better than this, there is a way to add a kind of "MA" noise?
Reply With Quote
  #3  
05-11-2004, 12:09 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Prodater64
@ Kwag: Better than this, there is a way to add a kind of "MA" noise?
Well, the idea is to maintain a very low noise static bitstream. When there's regular video, the "noise floor" will always be present, but won't affect the picture because the visibility of noise will be under the visible luma/chroma levels.
So this really doesn't apply to motion adaptiveness. It would really apply to "brightness" adaptiveness, and if this could be implemented, then that would be the way to go, because after the brightness drops below the treshold point (equivalent to 300Kbps), noise could be switched ON, and again turned OFF, once the brightness level trips above the treshold point.
Call it "Brightness Adaptive Linear Noise". That would be the correct term

-kwag
Reply With Quote
  #4  
05-11-2004, 12:15 PM
Prodater64 Prodater64 is offline
Free Member
 
Join Date: Mar 2003
Location: Palma de Mallorca - España
Posts: 2,925
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
It would really apply to "brightness" adaptiveness, and if this could be implemented, then that would be the way to go, because after the brightness drops below the treshold point (equivalent to 300Kbps), noise could be switched ON, and again turned OFF, once the brightness level trips above the treshold point.
Call it "Brightness Adaptive Linear Noise". That would be the correct term

-kwag
Is for this that I put MA between quotation marks. I don't knew what expresion to use.
The idea is for to avoid adding noise (and more final size).
Reply With Quote
  #5  
05-11-2004, 12:28 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Prodater64
The idea is for to avoid adding noise (and more final size).
Yes, the idea is to only add noise *only* on very black scenes. Blockbuster does this already, so it can be used right now for this purpose.
But I'm almost sure that a constant noise floor of 300Kbps wont really add that much to the final file size, because the average of a movie is always way above that point.
As a matter of fact, if the noise floor is "weighted" to apply an average bitrate of ~300Kbps in a total black scene, this will be exactly the equivalent of having a fixed MIN bitrate of 300Kbps
Anyway, it's better to use the internal noise filters in libavcodec, because that way it's platform independent, and we can use this technique in any OS supported by mencoder.
With AviSynth filters, we're sticked to Windows only.

-kwag
Reply With Quote
  #6  
05-11-2004, 12:38 PM
Prodater64 Prodater64 is offline
Free Member
 
Join Date: Mar 2003
Location: Palma de Mallorca - España
Posts: 2,925
Thanks: 0
Thanked 0 Times in 0 Posts
Can you say me how to do this whit blockbuster? I mean to obtain ever, a min bitrate of 300, even in a total black scene.
Reply With Quote
  #7  
05-11-2004, 12:46 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Prodater64
Can you say me how to do this whit blockbuster? I mean to obtain ever, a min bitrate of 300.
Ok, you're going to have to encode from a fake .avs script, generating black video.
Then, using *ONLY* BlockBuster in your script (after resolution and resize, of course), encode a small 1 minute or so, with very low values in BlockBuster.
Then drag your encoded .m2v into Vdub, and check the average bitrate.
Keep doing this until you get ~300Kbps average.
Remember this. The value you find above, will be the value to use for the current resolution you used.
Other resolutions will have different values (parameters) for BlockBuster.
This is something that must be taken into consideration if implemented into MencoderME/mencoder.
Of course, if vmesquita does implement this in MencodeME, the noise floor will already be automatically set for the selected resolution (right vmesquita )
But you can go ahead and do it right now with BlockBuster. Let me know

Edit: read here to generate a black video: http://www.avisynth.org/index.php?page=BlankClip

-kwag
Reply With Quote
  #8  
05-11-2004, 01:01 PM
incredible incredible is offline
Free Member
 
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to incredible
I also thought about that

ScriptClip(clip, "diff = averageLuma()"+chr(13)+"diff < X ? Blockbuster(xxxxx,diff/4,xxxx) :Nop()"
4 is here just an example for deviding the diff so a minimal blockbuster noise gain change will occur (like in tempsoften by deviding the nf)

Find out the right X as threshold and do apply an adaptive X/y within blockbuster noise gain so you can avoid nosie kick-ins.

Just adapt it to MA.

Its like an an MA but sees if a frame gets dark, so NO comaprison to the next frame BUT analyse the present frame. So a very low y would come out on very dark scenes.
THEN! We have to setup blockbuster right that a "all over" noise will be generated, because blockbuster can be set to do thresholded noise, ... not refered to present luma! but to plain surfaces and edges.

But Mencoder on dark scenes gots a very sensible quantizer threshold.
And on Credits ... it just "CUTS" high freq's, means fine noise.I tried that already by using a static plain noise when encoding a test (ANd I do mean "noise"! .

But when using an MA-Noise-on-black script, it can process a "kick in" of noise at dark parts where the quantizer engine of mencoder "could" think .... "Oh ... no black"

But maybe since then the engine changed a bit so another test would be very senseful!

Reply With Quote
  #9  
05-11-2004, 01:08 PM
vmesquita vmesquita is offline
Invalid Email / Banned / Spammer
 
Join Date: May 2003
Posts: 3,726
Thanks: 0
Thanked 0 Times in 0 Posts
This is a very good idea. Mencoder offers basically two kinds of noise: temporal, spatial and averaged, which can by applied to luma and chroma is separated degrees.
My previous tests indicate that spatial only noise creates an effect of "the screen of the TV is dirty", while the temporal noise can create "dancing artifacts" if bitrate is too low. I used noise in MencodeME AVI filtering combo...
What kind of noise you think it would be better (temporal/spatial/averaged on luma/chroma/both)?
Reply With Quote
  #10  
05-11-2004, 01:16 PM
incredible incredible is offline
Free Member
 
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to incredible
noise[=luma[u][t|a][h][p]:chroma[u][t|a][h][p]]
Adds noise.

<0-100> luma noise
<0-100> chroma noise
u uniform noise (gaussian otherwise)
t temporal noise (noise pattern changes be- tween frames)
a averaged temporal noise (smoother, but a lot slower)
h high quality (slightly better looking, slightly slower)
p mix random noise with a (semi)regular pat- tern

The problem is ... I think theres no adaptive noise based on average luma input in mencoder like we can do in avisynth like explained above.

But maybe Im totally wrong

PS: Senseful would be to add a shock of chroma noise as you wont see it on already very low luma parts, but the encoder does interprete that as "dancing" details.
Reply With Quote
  #11  
05-11-2004, 01:21 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Here's your 350Kbps MIN bitrate

BlockBuster(method="noise", detail_min=1, detail_max=1, variance=0.1, seed=5823 )

This was tested with TMPEG.
Code:
 
BlankClip(length=3000, width=720, height=480, fps=23.976, color=$000000)
BicubicResize(704, 264, 0, 0.6, 2, 61, 716, 358)

converttoyuy2()
BlockBuster(method="noise", detail_min=1, detail_max=1, variance=0.1, seed=5823 )
Enjoy,
-kwag
Reply With Quote
  #12  
05-11-2004, 01:28 PM
vmesquita vmesquita is offline
Invalid Email / Banned / Spammer
 
Join Date: May 2003
Posts: 3,726
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by incredible
The problem is ... I think theres no adaptive noise based on average luma input in mencoder like we can do in avisynth like explained above.
Yes, you can't vary the ammount of noise per frame.
Quote:
PS: Senseful would be to add a shock of chroma noise as you wont see it on already very low luma parts, but the encoder does interprete that as "dancing" details.
Have you tested this? Because I saw the dancing details adding noise to luma only (I was trying to remove DCT blocks). Does chroma produces the same effect?

@kwag
Nice!
Reply With Quote
  #13  
05-11-2004, 01:32 PM
incredible incredible is offline
Free Member
 
Join Date: May 2003
Location: Germany
Posts: 3,189
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to incredible
Perfect Kwag!

Now try that on mencoder as it quantizes different on black frames as TmpgEnc.

So try....

ScriptClip(clip, "diff = averageLuma()"+chr(13)+"diff < X ? BlockBuster(method="noise", detail_min=1, detail_max=1, variance=0.1, seed=5823 ) :Nop()"

We have to find out the right X threshold for B.Buster kick in.
This would avoid usesless noising on average movie content as even there noise would mean less compression as seen as a whole

@ VMesquita

? Do you mean you recognised these "dancing blocks" when noising the luma only?? Maybe chroma noise is just the only we need?? We should test that
(or maybe that was it what you meant)
Reply With Quote
  #14  
05-11-2004, 01:46 PM
vmesquita vmesquita is offline
Invalid Email / Banned / Spammer
 
Join Date: May 2003
Posts: 3,726
Thanks: 0
Thanked 0 Times in 0 Posts
@Inc
I meant that I was noising the luma blocks (to remove DCTs) and saw the dancing blocks. But I didn't try to noise luma and chroma or chroma only to see what happens. More tests needed.

But looks like the avisynth idea is more suitable, specially you get the adaptative thing working, otherwise we would be wasting bits in places that doesn't need noise. Too bad it's not multiplataform.
Reply With Quote
  #15  
05-11-2004, 02:50 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Here's my final setting, to be tested with MencodeME/mencoder.

noise=3th

You can change it in MencodeME presets, for example: "DVD.fil", and it will look like this:
Code:
vf=%%FORCEDFILM%%yuvcsp,scale=%%CROPPED_WIDTH%%:%%CROPPED_HEIGHT%%:0:0:60,%%CROP%%unsharp=l3x3:0.6,hqdn3d=3:6:8,unsharp=l3x3:-0.7:c3x3:-1.5,noise=3th,expand=%%WIDTH%%:%%HEIGHT%%:-1:-1:1
@vmesquita,

I changed the noise generation from "uniform" to "temporal", because uniform is a static noise, which is identical on every frame. With the temporal option, the noise is ranrom on every frame, and it's more natural.
Anyway, the value is so low, that it's barely visible, but it maintains a MIN bitrate around 290Kbps.
Give it a whirl

Edit: This settings were tested on a 704x480 target, so if you use other resolutions, your MIN bitrate will be slightly different.

-kwag
Reply With Quote
  #16  
05-11-2004, 03:20 PM
Hydeus Hydeus is offline
Free Member
 
Join Date: Dec 2003
Location: Omicron Persei 8
Posts: 322
Thanks: 0
Thanked 0 Times in 0 Posts
And what about non black scenes, but very bright (amost white), or all of almost monochromatic scenes (full red, full, green, full other colour). IIRC the MPEG does not recognize colours, but grade of changes. This hapen very rarely but some movies are going "fade to white" not to black. Have you tested this type of scenes
__________________
Go for SECAM =)
Reply With Quote
  #17  
05-11-2004, 04:23 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Hydeus
And what about non black scenes, but very bright (amost white), or all of almost monochromatic scenes (full red, full, green, full other colour). IIRC the MPEG does not recognize colours, but grade of changes. This hapen very rarely but some movies are going "fade to white" not to black. Have you tested this type of scenes
Very good observation Hydeus
In case of the mencoder noise generator, it's irrelevant, because the noise floor is statically being generated, no matter what brightness/activity there is. So the minimum bitrate will always be present, no matter what color is on the screen, even if it's a static white screen.
I thought that this would affect BlockBuster, but I just tested it with a white screen: BlankClip(length=3000, width=720, height=480, fps=23.976, color=$FFFFFF) and I got the same result. A steady MIN bitrate of around 300Kbps
I also tried a gray screen: BlankClip(length=3000, width=720, height=480, fps=23.976, color=$808080) with similar results

-kwag
Reply With Quote
  #18  
05-11-2004, 04:27 PM
Hydeus Hydeus is offline
Free Member
 
Join Date: Dec 2003
Location: Omicron Persei 8
Posts: 322
Thanks: 0
Thanked 0 Times in 0 Posts
Great
__________________
Go for SECAM =)
Reply With Quote
  #19  
05-11-2004, 05:28 PM
vmesquita vmesquita is offline
Invalid Email / Banned / Spammer
 
Join Date: May 2003
Posts: 3,726
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kwag
Here's my final setting, to be tested with MencodeME/mencoder.

noise=3th

You can change it in MencodeME presets, for example: "DVD.fil", and it will look like this:
Code:
vf=%%FORCEDFILM%%yuvcsp,scale=%%CROPPED_WIDTH%%:%%CROPPED_HEIGHT%%:0:0:60,%%CROP%%unsharp=l3x3:0.6,hqdn3d=3:6:8,unsharp=l3x3:-0.7:c3x3:-1.5,noise=3th,expand=%%WIDTH%%:%%HEIGHT%%:-1:-1:1
@vmesquita,

I changed the noise generation from "uniform" to "temporal", because uniform is a static noise, which is identical on every frame. With the temporal option, the noise is ranrom on every frame, and it's more natural.
Anyway, the value is so low, that it's barely visible, but it maintains a MIN bitrate around 290Kbps.
Give it a whirl
This is great! In my tests I were using a higher threshold that's why I was getting dancing blocks. BTW did you try adding noise only on chroma or only on luma? The downside of temporal noise is that it's also less compressible across all frames but since you're using a small threshold this shouldn't be a problem.
Reply With Quote
  #20  
05-11-2004, 05:50 PM
kwag kwag is offline
Free Member
 
Join Date: Apr 2002
Location: Puerto Rico, USA
Posts: 13,537
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by vmesquita
This is great! In my tests I were using a higher threshold that's why I was getting dancing blocks.
Yes, I noticed that, and I was also seeing "smearing" on surfaces, so I suspected a too high temporal value. See the changes below.
Quote:
BTW did you try adding noise only on chroma or only on luma?
No I didn't. But the noise is so minimal, that it's barely noticeable But it does keep the minimum bitrate around the needed 300Kbps.
Quote:
The downside of temporal noise is that it's also less compressible across all frames but since you're using a small threshold this shouldn't be a problem.
These are the latest settings I'm using:

hqdn3d=3:6:2
noise=3th


I'm currently doing an encode with those parameters, and it looks pretty good

-kwag
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Mencoder: Using Bitrate Viewer maurus Video Encoding and Conversion 11 06-07-2004 12:00 PM
Mencoder: Move the noise parameter to the beginning of your script! kwag Video Encoding and Conversion 74 06-03-2004 04:54 PM
Mencoder: Question about average bitrate... black prince Video Encoding and Conversion 3 06-02-2004 06:53 PM
Mencoder: Predicted and bitrate maurus Video Encoding and Conversion 2 05-28-2004 03:00 AM
noise from the VHS tape caused the encoder to need more bitrate? Learner Video Encoding and Conversion 3 05-12-2002 11:51 AM




 
All times are GMT -5. The time now is 09:30 AM  —  vBulletin © Jelsoft Enterprises Ltd