View Full Version : Emulating real dropdupe+vfr in mkv and x264
OvejaNegra
10th October 2007, 22:17
One anime encoder (me) and another one are having a discussion about x264 VS Real. He was showing his encodings. The filezise was very small and the quality was really good. But i was suspecting he was cheating.
And yes he was:
He was using a smaller audio bit rate (64kbps) but thats not the point.
The point is, that using Real Player i see that the framerate of the videos is lower in the less action scenes (12 fps or less). The movement looks normal because in anime there is a lot of repeated frames. After some investigation i found this:
http://forum.doom9.org/showthread.php?t=56564&highlight=anime+duplicated+frames&page=6
That's the reason (i think)
Now this is a very usefull thing for anime encoders.
But how can i do this with X264 and MKV?
How can i delete duplicate frames and lower the framerate? And (of courser) generate a timecode for mkv for a variable frame rate video.
I'm interested in this because is usefull for me, and because i wan't beat him (this is not a valid reason :-)
I'm posting here because i think that all i need are some AVS filters.
Donald Graft's Dup Avisynth filter detect duplicates but creates a
copy of the frame, not a VFR video.
Is there another suggestion?
Thanks
Sorry for the english.
I'm starting a new thread because all the other ones about dropdupe are only for the RealMedia people.
Thanks
Unearthly
10th October 2007, 23:09
I believe the filter you are looking for is Dedup (http://akuvian.org/src/avisynth/dedup/).
However, this approach has been thought of before and I recall it being said that x264 handled exact duplicate frames well enough that it wasn't worth the trouble.
However, if you don't mind the trouble, go ahead and try it and tell us your results.
Adub
11th October 2007, 00:29
Check here:
http://avisynth.org/VariableFrameRateVideo#create-vfr-mkv
OvejaNegra
11th October 2007, 02:54
AHH!!! I was sure a AVS filter was all i need. I will try dedup.
BTW: the curiosity is killing me: I wan't to extract al the REAL FRAMES from a video (no the dups) and compress them with jpg, to make some experiments (i have something in my head, maybe is nothing but ,maybe not).
I have imagewriter ,but i don't know how write a function to "detect" and "write" the differents frames . Any suggestion?
For now, i will play with dedup
thanks
Adub
11th October 2007, 03:22
Why not use TIVTC, like in the link I posted? It's better quality, as in lossless.
For extracting all of the real frames, couldn't you just use TIVTC or Dedup, your preference, to remove all of the dupes using Avisynth, then feed your script to Virtualdub and use the "Export -> Image Sequence" function?
I did sort of the same thing to create an ASCII movie once, and it worked fine.
foxyshadis
11th October 2007, 07:10
(Updated version (http://avisynth.org/mediawiki/VFR). Old wiki really needs to finally be taken offline, I don't think there's anything left on it that Wilbert hasn't transferred.)
If you use Dup, x264 and mkv will combine to use about 8 bytes per unused frame. Dedup is a fair bit of hassle just for 2-3k at most, especially since by the time you get it to a usefully high value you're guaranteed to need overrides, and have to go through the whole video checking; I'm willing to do it because that's actually a sizable fraction at the sizes I use for portables. Even without Dup, x264 will tend to compress the nearly identical frames hard enough that they only use up 20-30 bytes. Try it, double the framerate with changefps, raise the b-frames to compensate, and see how much larger a cq comes out. It won't be much at all.
TIVTC is only useful for 24/30 VFR, not drop-frame VFR. They aren't interchangeable, and can be combined if you have something with both.
If you want to use your time more usefully, use dark shikari's satd+esa+prepass patch. That'll raise quality/lower size compared to standard umh much more than dropping frames, unless you start dropping action frames.
OvejaNegra
11th October 2007, 08:45
Merlin: That's not axactly what i need. Dedup and dup always force a new frame every 20 frames (even if it's a copy). I don't want those frames, i'm looking for the all-different frames (only to see ho many real frames the anime have, that's all)
foxyshadis: I'm very sure about the potential of X264. I'll try what you say and i'll post the results.
The problem that is ***** me is the ***** real video file. It was very small (I checked the original and no small-movement scenes were affected).
X264 does not give me a better or equal quality with the same size (with all settings max)
I'm doing noise prefiltering and all the necesary stuff to clean the picture but nothing.
Of course, the Real video is not so perfect as i like, but looks very good. X264 does not look as good (with the same filezise)
Thats why i'm trying to delete the duplicated frames (maybe only a few will make the difference)
Maybe, some kind of smart low-action-scene -> 12 fps/8fps-only-needed will make the difference.
That's what i'm trying to do with dedup.
(YES, i must confess, i cannot accept the defeat, i'm defensor of X264+mkv)
My friend must be very happy. Now i cannot sleep. I'm playing with dedup.
Usual animes have very slow framerate in "talking" scenes and sometimes are scenes with a single repeated frame.
I you make trim and then delete frames (using convertfps) to 8/12 fps you cannot note any jump in the scene.
Thats what i'm trying to do.
Thanks
Just to clarify: YES we are using the same Vobs (i have it now to make the test)
Wilbert
11th October 2007, 19:36
(Updated version. Old wiki really needs to finally be taken offline, I don't think there's anything left on it that Wilbert hasn't transferred.)
I transferred everything except half of the scripts.
foxyshadis
12th October 2007, 10:47
If you really want ultimate Xtreme dupage, you need to modify dedup to use partial frames and refer to frames further back (for duplicate cycles), partial frames, and such. Just to shave off a few tens of bytes here, a few tens there. I spent a bit modifying it a while back, but never worked all the bugs out or got all the features I wanted in it.
Have you also tried m4g's smooth matrix, which I find reduces blocking at low bitrates? Also, I'm not sure, but is real's actual resolution smaller than its stated resolution? (In which case you'd be allowed to go that route too, since lower resolution can look a lot better at low bitrates.)
OvejaNegra
13th October 2007, 00:19
Wait:
Are you saying that Real make smaller frames and then scale again during playback? Like VP7?
I'm not sure about this.
foxyshadis
13th October 2007, 10:26
Beats me. If I were designing a codec for crazy low streaming bitrates I would let it drop the real resolution instead of cranking the quant, especially on I-frames. Blurring is better than blocking. In fact I'd use multiscale (start small, enlarge and fill in details, repeat), but that's a lot more complex and only works usefully on I-frames. Since RMVB is proprietary, there's no way to really know this without some in-depth analysis.
A matrix that chops off much of the high-frequencies of I-blocks (again like m4g smooth) has a similar effect to lowering the resolution. The more extreme the chop, the lower the effective resolution.
OvejaNegra
13th October 2007, 23:24
I'm going to try that matrix too.
Where can i find it?
Also, avisynth can be used to write your own functions.
What about something like this:
vid = AviSource("file")
vid_blur = vid.Blur(1.5)
ConditionalFilter(vid, vid_blur, vid, "AverageLuma()", "lessthan", "20")
But using the "level of action in the scene"
Someyhing like blurring the frame in high motion scenes.
This is taken from the AVS help.
BTW: VP7 have a function to "eat" the resolution in high motion scenes
Dark Shikari
13th October 2007, 23:30
Blurring the frame in high-motion is likely bad because anime takes very little data to encode to begin with--blurring it might actually make it worse rather than easier to encode.
I'd suggest just using some very very strong settings, heavy denoising, TTempSmooth, and watch RealVideo pale by comparison. You don't need all these silly methods to save a few bits.
foxyshadis
14th October 2007, 00:28
Matrix (https://forum.doom9.org/showthread.php?t=117041).
The ultimate thing you could do for anime is CelForeground/CelBackground, you can eliminate all banding and get an extremely strong temporal denoise without detail loss that way. Sadly, only foreground works. If anyone took up that mantle, they'd be heroes.
I'm personally averse to smoothing the hell out of anime, but shikari's right, it is the best way to lower bitrate. Best used in conjunction with a matrix (eqm ulr/lr for ASP, m4g smooth for AVC), just to minimize blocking. (It mainly bothers me when people smooth way more than they need to for the bitrate they use. Heavy-handed application of Deen is a common symptom. Try it here, though.)
OvejaNegra
14th October 2007, 09:36
NONONONO:
It was just a suggestion. I like quality more than anything and preserve the original picture as accurate as possible.
My point with the Real is that many animes are with 8 fps in most of the animations (you can try convertfps to set to 8fps and the movement looks the same in many animes) so my point is remove the duplicated frames to restore the original 8fps / 12 /16 to save some bits.
If you take some animes and playback frame by frame, you will see many dup frames. Remove those frames could help. Maybe not.
I'm playing with dedup (works very well for me), if the saving is enough, maybe is something useful. Maybe not.
Of course, extreme smoothing is another thing to try, but that's another path.
MMhh: About CelForeground/CelBackground, i remember something now related to something like that.
Some kind of filter (for AVS?). The filter make some kind of "average" with the pixels of the backgrounds or large areas (but preserving small details and lines), like "flattening" the big areas. When used too much the anime star to look like a flash movie. I don't remember the name.
Anyone remembers the name?
Maybe a Premiere filter or After FX?
Not sure but was interesting. Give "Flashy" look to the animes.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.