Log in

View Full Version : AviDemux and correct way to deinterlace


jimhoyle
25th January 2010, 21:04
I've done very nice deinterlacing on VirtualDub, using a simple .avs file containing:

AVISource("C:\test.avi")
separatefields

Then I do the deinterlace with "Deinterlace - smooth v1.1" by Gunnar Thalin. I get great quality, 25fps interlaced home video makes a 50fps smooth motion, high quality progressive result. How can I do this same with AviDemux? I don't understand how AviSynth is supposed to work there.

Could you please give me a full walkthru or tips about AviSynth separatefields functionality in AviDemux?

LoRd_MuldeR
25th January 2010, 22:01
SeparteFileds() does NOT deinterlace! It simply separates the fields, as the name implied.

Furthermore applying a deinterlace filter after you have already separated the fields does not make any sense at all! :confused:

Anyway, given that you have material that is truly interlaced, you can deinterlace it with Yadif, for example...

jimhoyle
25th January 2010, 23:51
I meant after SeparateFields I do deinterlace in the Filters section. I have used this method for years and it gives me excellent quality. I learnt it from http://100fps.com/ .

If you know how, could you tell how to deinterlace 25fps interlaced to 50fps progressive with the best quality? I tried AviDemux with Active Filters / yadif in place, tried both top and bottom first and got horrible results. Not really deinterlaced much at all. And yes, I know what interlaced and progressive are and what they should look like. What's the correct procedure in AviDemux?

LoRd_MuldeR
26th January 2010, 00:20
I meant after SeparateFields I do deinterlace in the Filters section. I have used this method for years and it gives me excellent quality. I learnt it from http://100fps.com/.

As said before, after you have applied SeperateFields(), there is NOTHING to deinterlace! Because you only have individual fields, stored as consecutive (progressive) frames.

Of course you can weave the separated fields back together (which will give interlaced video again) before you then put them through a deinterlacer. But why separate them in the first place then?

I'm not aware of any deinterlacer that takes or expects separated fields as input :rolleyes:

If you know how, could you tell how to deinterlace 25fps interlaced to 50fps progressive with the best quality?

First of all stop doing weird things! Then take your interlaced video "as-is" and put it trough the deinterlacer of your choice! That's it, really ;)

As deinterlacer you may use "Yadif" or "TDeint", for example. Both are available (not only) in Avidemux.

(BTW: What looks like interlaced video may actually turn out to be telecined. In that case (and only in that case) you'd need an IVTC filter!)

I tried AviDemux with Active Filters / yadif in place, tried both top and bottom first and got horrible results. Not really deinterlaced much at all. And yes, I know what interlaced and progressive are and what they should look like. What's the correct procedure in AviDemux?

If you used SepearteFields() before putting the video through Yadif, then of course you won't get good results!

So instead of doing weird things simply open your interlaced video file in Avidemux, add either Yadif or TDeint inside the Filter Manager and finally save the result.

And if you still get results that aren't as expected, give us details! That means: Post a piece of your unprocessed(!) source or at least a screenshot...

jimhoyle
26th January 2010, 10:04
Deinterlace - smooth v1.1 works only if SeparateFields is there. The quality is excellent.

I tried the simple way, just AviDemux, open video and put yadif on place. Tried with all different options but the result was pretty much the same: not really deinterlaced. I didn't put any SeparateFields in AviDemux (I don't even know how).

I can post my examples later when I get home, but the material is definitely interlaced (as it reads also in MediaInfo) and the result is definitely very clearly combing.

LoRd_MuldeR
26th January 2010, 12:51
Deinterlace - smooth v1.1 only if SeparateFields is there.

Maybe it does. But 99.9% of all deinterlace filters do NOT work on separated fields, but on interlaced frames ;)

Consequently you must NOT use SeperateFileds() when you apply a deinterlace filter, such as YADIF or TDeint or KernelDeinterlacer or SmartDeinterlace or...

So, I did the simple way, just AviDemux, open video and put yadif on place. Tried with all different options but the result was pretty much the same. Not really deinterlaced. I didn't put any SeparateFields in AviDemux (I don't even know how).

Works pretty well here:
http://mulder.brhack.net/temp/adm_toxic.htm

Also "Not really deinterlaced" is NOT a useful information. Post an unprocessed(!) piece of your original source, if you expect any helpful comments!

...but the material is definitely interlaced (as it reads also in MediaInfo) and the result is definitely very clearly combing.

MediaInfo only tells you how the video was encoded. It tells you NOTHING about the nature of the content.

Progressive content can be encoded as interlaced just fine and this is done a lot in TV broadcast! So looking at bitstream flags in MediaInfo is completely useless here.

You must look at the content with your eyes to decided whether it is interlaced or not. Also you must decide between telecine and "true" interlaced.

Gavino
26th January 2010, 18:16
I'm not aware of any deinterlacer that takes or expects separated fields as input :rolleyes:
Actually, Avisynth's dumb Bob() filter will accept separated fields as input, although it is more usual to give it the interlaced frames. It will work either way.

jimhoyle
28th January 2010, 12:12
I just found out that AviDemux Interlacing/Swap Fields (and Smart swap fields) works perfectly! And only those work properly even if field orders are changed Top/Bottom and other options are changed. So. What does this mean? (Source material is MJPEG, I assume real interlaced but now I'm not 100% sure any more.)

On another source material (recorded directly to compressed MP4 by a cheap Pinnacle S-Video capture module), there is combing. Now, when I do Keep even fields, I still see some of combing mess and other mess as well. What does this mean? Does this mean the MP4 compression has destroyed the interlacing and it can't be fully fixed any more?

roozhou
28th January 2010, 15:08
I just found out that AviDemux Interlacing/Swap Fields (and Smart swap fields) works perfectly! And only those work properly even if field orders are changed Top/Bottom and other options are changed. So. What does this mean? (Source material is MJPEG, I assume real interlaced but now I'm not 100% sure any more.)


libavcodec's mjpeg decoder is buggy. Sometimes it outputs wrong field order. Look at this (https://roundup.ffmpeg.org/roundup/ffmpeg/issue1493). It is still not fixed.

jimhoyle
28th January 2010, 15:27
Thanks. But could you tell me, now that only swap fields is enough to make the result perfect, does this mean the source material is not interlaced at all? Or how is that possible?

LoRd_MuldeR
28th January 2010, 17:45
Thanks. But could you tell me, now that only swap fields is enough to make the result perfect, does this mean the source material is not interlaced at all? Or how is that possible?

If a filter like "Swap Fields" can remove the combing (restore progressive frames) from what appeared to be "interlaced", this means your source was NOT interlaced. It was field-swapped progressive content.

As roozhou said, this may be the result of a buggy decoder. But you also encounter that phenomenon in the wild. TV broadcasters do all kind if weird things with their content...

alancarre
27th November 2014, 20:05
Thanks. But could you tell me, now that only swap fields is enough to make the result perfect, does this mean the source material is not interlaced at all? Or how is that possible?

Ask yourself a question and try to answer it without looking anything up. Why is broadcast audio/visual content always transmitted in interlaced format?

Hint: I'll give you a choice of 3:
a. Because it's faster and you get better compression
b. Historical reasons
c. Because of the geometry of the surface on a TV screen

The answer, obviously, is c. It would not be possible to transmit TV data in any other format because of the way the screen is laid out. I don't think I can draw it or, maybe I can. First realize that a television screen, old or new, is composed of light-emitting "cells" in horizontal rows one after the other from top to bottom. The layout can have only one possible formation:

.x.x.x.x.x.x.x.x.x.x <-- even row
o.o.o.o.o.o.o.o.o.o <-- odd row
.x.x.x.x.x.x.x.x.x.x
o.o.o.o.o.o.o.o.o.o

Because the font is not fixed width it is not easy to tell that the even and odd rows above are not aligned vertically. Instead they form the same kind of structure found in a bee hive. A "honeycomb". The principle utility of the honeycomb layout is that each "cell" is equidistant from all of its nearest neighbors. Once again, the font kills me in an attempt at a demo, but I'll try:

x/-----\
/xxxxxx\
\xxxxxx/
x\____/

That's supposed to be a hexagon. Take a hexagon like that and tilt it by 30 degrees so as to make what you see now as bottom and top, become instead the left and the right "vertical" sides of the hexagon. After doing that you can line them up into a row all flush.

Okay, imagine in your mind this row and below it you want to fill in another one. Question is, will it fit? Because if it fits then the centers of those hexagons will be the same distance from the centers of all of their neighbors. And therefore you can make a TV screen work without having to deal with Pythagoras whose rectangle has the annoying property of setting diagonals 1.4 times as far away as horizontals. Making a TV work *like that* would be madness. Sheer and utter madness.

Now if you want to draw an image on that beautiful surface just created all you have to do is get the right color values into the right cells. No need to compensate for the square root of two or anything. To transmit your image to another screen is simply a matter of sending signals along a wire containing the data to be placed at the position indicated in the data right?

So the scan lines have to be misaligned because their target is not a rectangular grid, it's a honeycomb. The part you call "image" is what is supposed to go into the cells, not what is meant to make up the resulting image. That image is obtained by building a honey comb. NOT by aligning the scan lines because that data does not form the rows and columns of any image (or frame).

A complete frame consists of the entire layout of cells.

Therefore it follows that it is actually *impossible* to "perfectly" deinterlace any interlaced image stream because the data is not mapped from a rectangular grid. Some kind of averaging has to be done. Always.

What baffles me though, is why the requirement that progressive frames be used for internet streaming. I mean we have caches and buffers etc. Why not cache up a few scan lines and run it interlaced? Because in the end, your deinterlacing will be returned back to interlaced data for visual display.

- A

If this post is successful I may continue explaining some of the popular ways to work with this phony problem.

alancarre
27th November 2014, 20:50
This post will date me, but just now I went to test a theory. I downloaded a VIDEO-TS file from the internet containing a music concert by a band (the current year is 2014) called "Warpaint". The video data was encoded in AVC format, the audio Dolby 5.1 and the overall video stream characteristic was (or is) 1920x1080i [interlaced].

Now, usually when I run into one of these interlaced TS files I simply load it up into Avidemux and clip out the bit I want and save. And I get a progressive scan at 50 Hz. But not this time. This time I got an *interlaced scan* at 50 Hz!

It didn't make any sense to me. And maybe I just screwed up a setting but anyway I loaded it up into Virtual Dub and low and behold what it had done was add blank frames leaving full images every 2nd frame! Well that seems impossible and I'm sure they're not full images, but that doesn't matter. What matters is that it has already been deinterlaced but it is ready to be played on a machine that expects interlacing. All I would have to do is delete every 2nd frame and run it in a progressive manner. But there is no such setting. I searched and searched and found nothing.

Understanding what to do however paid off in the end. There is a filter called "interpolate" which is used to change frame rates. One method is to take an average of frames, and the other way is to discard. I chose "discard".

I have an AVC encoder installed but it's so slow and I know that it doesn't matter what codec I choose as long as I get all the data so I chose XviD single pass at 10,000 kbps video data rate and uploaded the result to YouTube here: https://www.youtube.com/watch?v=P9YDabUbZFw

wonkey_monkey
2nd December 2014, 14:19
Why is broadcast audio/visual content always transmitted in interlaced format?

It isn't. Quite a few channels broadcast in 720p, particularly in the US. In the UK, Freeview HD can (allegedly) switch to 1080p dynamically when the content suggests it (though I believe the rest of the broadcast chain remains 1080i).

Hint: I'll give you a choice of 3:
a. Because it's faster and you get better compression
b. Historical reasons
c. Because of the geometry of the surface on a TV screen

The answer, obviously, is c.

No, I'm pretty sure it's b...

The layout can have only one possible formation:

It can have any formation the manufacturer wants, as long as he can display an image on it to meet his customers' satisfaction. I was under the impression that most modern TVs use a rectangular grid of pixels (hence the existence of "screen fit" modes which map pixels exactly 1:1 and are noticeably, if slightly, sharper than overscan modes).

David

Asmodian
9th December 2014, 22:42
What baffles me though, is why the requirement that progressive frames be used for internet streaming. I mean we have caches and buffers etc. Why not cache up a few scan lines and run it interlaced? Because in the end, your deinterlacing will be returned back to interlaced data for visual display.

Scan lines!?! I know the majority watching streaming video today are doing it on a sample-and-hold display (LCD monitor/TV). These displays (LCD and OLED) don't have scan lines but a nice regular grid of square pixels that are always displaying an image and simply change to the new image every screen refresh. Interlacing is terrible on these displays. There are no reasons to use interlacing anymore and good reasons not to.

Even "back in the day" (most?) TVs used rectangular pixels. You seem to be confusing phosphor layout (shadow mask or aperture grille) with pixel geometries.

No, I'm pretty sure it's b...

Yes, b. for sure but with a bit of a. too. Broadcasters have to think about bandwidth limits, there are better compression methods than interlacing but they are still using interlacing as a compression method.

c. is not true. All modern screens use a regular grid of square pixels. Long gone are the days of non-square pixels, offset rows, or other oddities (except Samsung OLED has introduced "PenTile". I hope no one will optimize content for it so let's ignore it for now).