Play DVDs with VLC using a filter similar to the "film effec

For questions and discussion that is NOT (I repeat NOT) specific to a certain Operating System.
DonPedro
Blank Cone
Blank Cone
Posts: 15
Joined: 14 Oct 2006 23:08

Play DVDs with VLC using a filter similar to the "film effec

Postby DonPedro » 23 Jul 2007 20:26

Is there any way to apply a "film effect"-like filter to the video when watching a DVD?
My Problem ist, that I use a quite old Plasma Television with only 8 Bit, which means that often there are harsh color-transition viewable. The "film effect" used by the DivX-Codec helps a great deal by sort of dithering between the color-steps...

Hope someone can help me and I'm sorry about my not-that-perfect english.

Cheers

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 24 Jul 2007 15:41

Could you provide a description of the film effect?
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

DonPedro
Blank Cone
Blank Cone
Posts: 15
Joined: 14 Oct 2006 23:08

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby DonPedro » 24 Jul 2007 17:39

This is a tough one....
It is some sort of a full-screen "Image-noise" or "picture-noise". I don't know how it works in detail but it seems as if the filter was adding some anti-aliasing-like effect to the border of the harsh color-transition... you know you have black and white.. put grey color between them and the transition won't be that harsh...
I hope this makes it a little more clear.

In case you have the free bs-player and a divx4-avi you can look at the filter properties of the divx-decoder-filter and enable "film-effect"...

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 24 Jul 2007 18:09

So it's basically a bluring effect? (Does it affect the current frame only based on itself? or does it use features from previous frames? ... in fact, it would be most usefull if you had screenshots of the video with and without the effect applied)

(And I don't use windows so I can't test :) )
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

DonPedro
Blank Cone
Blank Cone
Posts: 15
Joined: 14 Oct 2006 23:08

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby DonPedro » 24 Jul 2007 18:48

The upper half is with "NOISE" (That's how ffd-show names it), the lower half is without... hope one can see it...

Image

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 24 Jul 2007 21:48

Ok, I think that i get it (shouldn't be too hard to add such a filter to VLC ... I'll let you know when it's done and you can test with a nightly build)
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 24 Jul 2007 23:15

I just found this small tutorial (for the GIMP) http://www.gimpguru.org/Tutorials/FilmGrain/ . Looks like it's doing exactly what we (... err, you ...) want. I'm feeling kind of sleepy right now but this should definitely be easy to implement. I'll be committing a first version of this filter so you can test sometime tomorrow.
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

DonPedro
Blank Cone
Blank Cone
Posts: 15
Joined: 14 Oct 2006 23:08

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby DonPedro » 24 Jul 2007 23:22

That's wonderful, thank you very much!

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby Jean-Baptiste Kempf » 25 Jul 2007 10:39

Dionoea: yet another video filter for VLC ? Cool.

Isn't there any standard for video filters ? I mean like AVS for visualisation.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 26 Jul 2007 00:12

I've posted two snapshots of the current code I have on my PC on http://people.videolan.org/~dionoea/grain/ . Left side has the filter applied, right side is just a plain copy of the original video.

Does this feel like what you wanted? (of course nothing beats seeing the filter in action on a real video to judge, but I still want to make a few changes before I commit it ... couldn't get it done all because of that stupid Simpsons Movie (awesome movie!))
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

DonPedro
Blank Cone
Blank Cone
Posts: 15
Joined: 14 Oct 2006 23:08

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby DonPedro » 26 Jul 2007 08:15

Seems to me that is exactly what I had in mind. Let's see how the finished filter works with my stupid old television....

And take your time! There is no need to hurry.. I can wait!

Thank you!

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 26 Jul 2007 09:36

Hehe, it's not like it only took 15 minutes to code and compile that filter :)
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby Jean-Baptiste Kempf » 26 Jul 2007 10:10

Hehe, it's not like it only took 15 minutes to code and compile that filter :)
O_o
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

HenrikE
New Cone
New Cone
Posts: 4
Joined: 22 Jun 2007 02:22

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby HenrikE » 26 Jul 2007 14:28

Cool 8)

Remember that point of the grain is a) to break down codec artefact pixelation (i.e. the filter should work on the screen/window buffer, not the frame pixels which are bigger, b)to keep areas that are not changing 'alive' (such as dark areas in horror movies ( - codec says 'they are dark, user won't see if I freeze it)). Remember also that the same noise is more visible in some areas than others - in the same frame! Because of intensity. (How to fix that, I don't know.)

Would be nice if one could set parameters like grain size, minimum framerate (to keep alive low fps movies), and % of grain effect to use. Or at least some good defaults, like toon, normal, dark. Then everyone would be able to adapt the grain perfectly to the movie that they have.

Let me know if you want me to betatest or assist you if you want. Great work!
Last edited by HenrikE on 26 Jul 2007 17:04, edited 1 time in total.

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 26 Jul 2007 15:10

Remember that point of the grain is a) to break down codec artefact pixelation (i.e. the filter should work on the screen/window buffer, not the frame pixels which are big
That won't be possible given the way VLC video filters work (they work on the decoded frame, the video output is responsible for the scaling if you have a decent graphics card ... which you do)
b)to keep areas that are not changing 'alive' (such as dark areas in horror movies ( - codec says 'they are dark, use won't see if I freeze it)).
So basically always change the grain for every new frame? (This is already what it's doing)
Remember also that the same noise is more visible in some areas than others - in the same frame! Because of instensity. (How to fix that, I don't know.)
So noise amplitude should depend on the base luminosity of a pixel? Or is that something different? (I guess that grain was due to irregularities in the film used when shooting a movie, and the reproduction process. Must mean that the grain isn't really dependant on the frame's content ... except maybe the amount of light it was exposed to)
Would be nice if one could set parameters like grain size, minimum framerate (to keep alive low fps movies), and % of grain effect to use. Or at least some good defaults, like toon, normal, dark. Then everyone would be able to adapt the grain perfectly to the movie that they have.
Currently it's a fixed size (for speed issues) but changing the grain size would be really easy so I'll probably make it possible (at least chose in a list of presets).
Framerate is currently set to the original movie's framerate and I don't intend on changing that (as it would imply a completely different type of plugin, which I don't like).
As for % of grain effect, I guess that you mean something like the std deviation of the grain's randomness compared to the allowed luminosity range? (Movies allow 256 levels of luminance, which is basically luminosity, and I was currently using a range of random numbers in the [-15;15] range to add noise, followed by a convolution by a 5x5 gaussian which is what 'sets' the grain size mentioned earlier before applying that noise to the original frame. The two chroma planes are left untouched.)
Let me know if you want me to betatest or assist you if you want. Great work!
More comments are always welcome :) If you have knowledge about other kinds of algorithms that can be used to add grain to a movie (or precise desciptions about the physical phenomenon involved in the grain's creation in old movies) I would be glad to read those to improve the current algorithm.

Thanks,
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 26 Jul 2007 15:16

http://en.wikipedia.org/wiki/Film_grain mentions the origin of the grain but I'm not sure how that applies to color photography. I guess that it uses more than 1 chemical component to get all the colors so that you have different kinds of grain that get added. (While on black and white photography you only had one chemical component, which means only one source of grain)
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 26 Jul 2007 15:29

Hum, I found some more info on wikipedia which basically sums up to:
If you want to emulate grain on a pre mid 1930s color photograph, you only have one source of grain (since all the colors are recorded on a single chemical film ... exactly like in black and white photography). See http://en.wikipedia.org/wiki/Autochrome_Lumi%C3%A8re for details.
If you want to emulate grain on a modern color photgraph, you have three sources of grain, since blue, green and red are each on a different layer. See http://en.wikipedia.org/wiki/Photographic_film for detail. They even mention films with more than 3 layers in that article ... but I think that it's safe to assume that those are so good that they don't have any noticeable grain.
Of course, that doesn't take into account the development process which might add another source of grain.
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 26 Jul 2007 15:43

Still some more wikipedia reading. "Granularity varies with exposure — underexposed film looks grainier than overexposed film." (from http://en.wikipedia.org/wiki/Film_speed#Film_grain), which answers one of my questions.
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 26 Jul 2007 15:59

Yet some more: http://en.wikipedia.org/wiki/Color_film ... film_works . Different layers are available for each base component. Some have a coarse grain, others a finer grain. (I'll stop posting wikipedia links now :) )
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

HenrikE
New Cone
New Cone
Posts: 4
Joined: 22 Jun 2007 02:22

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby HenrikE » 26 Jul 2007 20:08

Hehe, thanks for the quick reply!
That won't be possible given the way VLC video filters work (they work on the decoded frame, the video output is responsible for the scaling if you have a decent graphics card ... which you do)
Argh! Oh no! :cry: What a bummer. That means that pixelated (i.e., low res, you know, "700MB type movies") will only look a little better. (i.e., the CODEC pixelation/smoothing is broken up, but the noise will become apparent, since frame pixels are 2.5x2.5 physical pixels on normal PC screens.)
So basically always change the grain for every new frame? (This is already what it's doing)
Perfect! Don't change a thing :)
So noise amplitude should depend on the base luminosity of a pixel? Or is that something different? (I guess that grain was due to irregularities in the film used when shooting a movie, and the reproduction process. Must mean that the grain isn't really dependant on the frame's content ... except maybe the amount of light it was exposed to)
I read up a bit, and apparently grain is the difference in density (manufacturing processes aren't perfect) of the silver halide layer. The grain becomes more apparent when more photons hit that layer, such as when you overexpose a poorly lit scene. Film makers do this for effect (I know this from my 3D @ Uni) - they decrease the shutter width and/or shutter time, so that fewer photons make it onto the film, and then overexpose it back so you can see something :) The photons that DID affect the layer are few, only here and there, and so you get a more uneven (exaggerated) layer.

This density difference becomes grain when a projector shines with a constant light level through the film and the layer - since the layer has uneven density, more or less light is blocked by the layer.

What this means is that when an .avi has become pixelated and codec-smoothed, the grain isn't there. To reproduce it, you must emulate it, by giving dark areas more (visually, maybe not mathematically) grain and light areas less. You can see that constant grain (as in your picture of the guy with the katana) gives no visible grain on his body (dark) but grain on the skies.

(If someone is a film expert, please correct me. But I think I got it roughly correct.)
Currently it's a fixed size (for speed issues) but changing the grain size would be really easy so I'll probably make it possible (at least chose in a list of presets).
Framerate is currently set to the original movie's framerate and I don't intend on changing that (as it would imply a completely different type of plugin, which I don't like).
As for % of grain effect, I guess that you mean something like the std deviation of the grain's randomness compared to the allowed luminosity range? (Movies allow 256 levels of luminance, which is basically luminosity, and I was currently using a range of random numbers in the [-15;15] range to add noise, followed by a convolution by a 5x5 gaussian which is what 'sets' the grain size mentioned earlier before applying that noise to the original frame. The two chroma planes are left untouched.)
More comments are always welcome :) If you have knowledge about other kinds of algorithms that can be used to add grain to a movie (or precise desciptions about the physical phenomenon involved in the grain's creation in old movies) I would be glad to read those to improve the current algorithm.
To me, the main thing with grain size is to have it reduce frame resolution pixelation. The usual movies are around 600x350, which makes each film pixel about 2x2 to 3x3 physical pixels on 1280x1024 screens. With the usual filtering, it's ok for these movies, but any lower and you can see the pixelation clearly. If it's impossible to do grain smaller than the .avi resolution, I don't see any need for grain size. I mainly meant some way of adjusting it if the grain is too big, such as when the .avi is low res.

% is simply "amount of graininess". I bet there are as many methods as there are programmers. I'm not sure luminosity covers it all, the main thing is that grain is visually equal both in dark and light areas, I think.

I don't intend these ideas as telling you what to do, I hate it when someone does that :) Just ideas. Here is my idea, if I knew how to code stuff for VLC.

I always think of the most luxurious or quality solution first. If it can't be coded (too high PC specs required) or too much work or there is a nifty solution, then that is worth more consideration. I just think this filter would make the average user, with 700MB type .avis, look at VLC and be blown away with that his small movie looks so great in VLC than others!

I feel that it definitely needs to be done on the screen pixel level. If VLC renders with some engine like DDraw or OpenGL, or similar, then it could be easily applied to the screen buffer? Don't know.

1) Make one or more pixel masks in the form of an [optionally] repeated huge texture, like 2048x2048. I would bring a frame into Photoshop and try the built-in filters first until the frame looks good and less pixelated when the texture is overlaid at a certain scale. This is just to build antipixelation into the grain.
2) I would then use this texture to make a layer mask for a noise filled texture with size=screen/window pixel size. This is the texture applied with "subtractive blend" to the zoomed frame. Black pixels don't go below rgb(0,0,0), so only lighter areas are affected.
3) I'd use the same texture (antipixel pattern) inverted with additive blend to make sure there is live in black areas too. White pixels can't get whiter.

So basically, make your noise pattern as usual. Multiply it with the antipixel pattern to make the noise break up the pixelation, and subtract it. Invert it (same noise), multiply, additive.

I write too much as usual :) Tell me if this is impossible. If it's possible then I'd be happy to do some PS experiments ;) And tell me if it's old, but I think this is new technology?

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 26 Jul 2007 20:54

Using DirectX/OpenGL/... textures would basically imply one implementation per different video output we have ... which is not what I want to do (If someone wants to implement it directly in one or more vouts, feel free to do so and submit a patch).

Btw, most scaling algorithms do not "pixelate" the image. They interpolate the different pixels' colors to make it looks smooth (hence I kind of fail to see how the extra grain would make it look better).

I'll commit a test version of the plugin soon so you can both test it.
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

DonPedro
Blank Cone
Blank Cone
Posts: 15
Joined: 14 Oct 2006 23:08

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby DonPedro » 01 Aug 2007 12:26

Really looking forward to it!

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby dionoea » 07 Aug 2007 14:37

I've been away for a week with no internet access. I commited a test version of the filter 10 days ago (just before I left for the train station :p). You should be able to use it command line with any recent nightly build using:

Code: Select all

vlc --video-filter grain <someinput>
The left hand side has grain, the right one doesn't. This is still work in progress but I'd appreciate any comments you could have. (The grain effect only has one default setting at the moment, I'll make it possible to change parameters later)
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

DonPedro
Blank Cone
Blank Cone
Posts: 15
Joined: 14 Oct 2006 23:08

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby DonPedro » 16 Aug 2007 19:25

I'm sorry but I can't figure out what exactly you want me to do...

Simply adding the expression to the command line doesn't seem to make any sense since the filter isn't installed... with a new version of the player it also doesn't seem to work.. what am I doing wrong?

DonPedro
Blank Cone
Blank Cone
Posts: 15
Joined: 14 Oct 2006 23:08

Re: Play DVDs with VLC using a filter similar to the "film effec

Postby DonPedro » 15 Oct 2007 20:45

Still nothing new? :(


Return to “General VLC media player Troubleshooting”

Who is online

Users browsing this forum: No registered users and 17 guests