Author Topic: VFR (No, nothing to do with aircraft.)  (Read 6264 times)

0 Members and 1 Guest are viewing this topic.

Offline pokute

  • n00b Hero
  • *
  • Posts: 33
    • View Profile
VFR (No, nothing to do with aircraft.)
« on: April 07, 2008, 07:20:51 pm »
I know that L-E doesn't use VFR (variable frame rate encoding), so this has nothing to do with L-E. I just need to understand something "more better".

DVD's often (too often) have hunks of 30fps content sprinkled into otherwise nicey-nice 24fps content. The most common case is where the credits and/or studio bugs at the beginning of a dvd are 30fps.
When ripping these dvd's, the best solution is to drop and dupe frames to get the 30fps bits down to 24fps. This doesn't always work out, for a variety of reasons.
One solution, which is container specific (and I believe only implemented in mkv and mp4 containers as of now) is to include hints in the container that make it possible to handle the changing framerate. This is, AFAIK, the most common application of VFR. Some fansubbers do this, and it is usually transparent when the files are viewed on a computer.

Where it becomes a problem is when someone wants to either repackage the content into an avi container for viewing with a divx compatible hardware dvd player, or re-encode the content to make it playable as a dvd (hopefully NOT so that they can sell it on ebay).

Finally, we're up to the part where I ask the question... Is there a simple strategy for transcoding VFR content from mkv/mp4 containers? I once (this sort of thing always works the first time... then never again) converted the whole mess to 30fps, and it came out fine. For some reason, this doesn't always (read as "almost never") works. Has anybody else figured out a way to deal with this?! My TV is MUCH bigger than my computer monitor...

Offline teucom

  • n00b Hero
  • *
  • Posts: 42
  • Gender: Male
    • View Profile
Re: VFR (No, nothing to do with aircraft.)
« Reply #1 on: April 07, 2008, 08:04:08 pm »
That depends on where you live and which TV system is used there.

We live in germany, europe uses PAL TV/DVD at 25fps.

So theres a simple solution for us to get a smooth 25fps PAL DVD out of VFR (30 NTSC TV / 24fps Film mixed) mkvs.

First, we *convert* the VFR file mathematicaly to 120 fps (which is the lowest common multiple of 30 and 24 fps) by inserting frames with a VFR aware filter to get a fixed frame rate. In the next step, downconvert that now fixed rate 120fps again to 24fps with a motion (picture change for anime) aware filter. Speed up the 24fps to 25fps (without adding frames) and you get a fixed PAL framerate with smooth movie and almost smooth former 30fps parts. Audio must be stretched accordingly.

The speedup 24->25fps is hardly recognized and is the usual way films get prepared for television in PAL countries - no blending, nor artefacts.

If you need that as an avisynth script, just ask.

If you live in a NTSC country and want fixed 30fps output, that simple method wont work, you have to use telecine conversion.

No, I dont sell fansubs on ebay :), but we have a local fansub dorama/anime community of *all* ages, and not everyone uses a computer to watch.
« Last Edit: April 07, 2008, 08:06:15 pm by teucom »

Offline pokute

  • n00b Hero
  • *
  • Posts: 33
    • View Profile
Re: VFR (No, nothing to do with aircraft.)
« Reply #2 on: April 07, 2008, 08:59:16 pm »
Hmm... The interesting part there is the "VFR aware filter". I think I can come up with that in Transcode (Avisynth isn't available for Linux). It also didn't occur to me that the target framerate needs to be a common multiple of the component framerates.

There is a very interesting (incomplete?) Transcode invocation purporting to be able to rectify VFR here:

http://www.transcoding.org/cgi-bin/transcode?Tutorials/Framerate_Conversion

It bears a striking resemblance to Fermat's Last Theorem.

I'm certain that will NOT work exactly as stated, but it's probably 90% of the way there. It appears to be doing the 120fps conversion and the subsequent decimation in a single pass!

Offline teucom

  • n00b Hero
  • *
  • Posts: 42
  • Gender: Male
    • View Profile
Re: VFR (No, nothing to do with aircraft.)
« Reply #3 on: April 07, 2008, 10:43:37 pm »
Hmm... The interesting part there is the "VFR aware filter".
Meant is simply the mkv video filter for DirectShow which gives
adaptive FR information to DirectShowSource()

Heres the frame rate conversion part of the avisynth script I usually use for vfr mkv->DVD PAL reconversion if source is mostly 24fps...


[...]
DirectShowSource("source/abc.mkv",fps=119.88,convertfps=true)
#Used mkv DS input filter from the mkv package is vfr aware,
#with the given parameters frames are correctly inserted to achieve
#a fixed bitrate of 119.88 even if sources framerate is variable
#(119.88 = lowest common multiple of 23.976 and 29.970)

FDecimate(23.976)
#"Anime" Version of Decimate(),
#drops frames to achieve target framerate
#but tries to select anime dupe frames

AssumeFPS(25)
#slight speedup to 25fps PAL

TimeStretch(tempo=(100.0*25.0)/23.976)
#Correction of  Audio length by slight stretching,
#does NOT change pitch but preserves sync

SSRC(48000)
#Ensures 48khz sampling rate for DVD
[...]

AviSynth 3.0 for Linux is still alpha stage. And thats mostly the only reason
for the win partition on one of my desktop pcs... hope that will change eventually.
sigh.

Offline pokute

  • n00b Hero
  • *
  • Posts: 33
    • View Profile
Re: VFR (No, nothing to do with aircraft.)
« Reply #4 on: April 08, 2008, 12:00:27 am »
This is great! I think we just did a better job capturing the nuts and bolts of this issue than I have seen in any video forum!

Thanks teucom!

Offline teucom

  • n00b Hero
  • *
  • Posts: 42
  • Gender: Male
    • View Profile
Re: VFR (No, nothing to do with aircraft.)
« Reply #5 on: April 08, 2008, 01:28:45 am »
This is great! I think we just did a better job capturing the nuts and bolts of this issue than I have seen in any video forum!
Thanks, but this solution is pretty basic and known to everyone who doesnt use vector prediction/compensating frame rate conversion (with image rebuilding), as latest professional sophisticated (read: expensive) studio hardware does.

There are avisynth libs even trying these advanced vector prediction methods, but early staged, currently working with 1-2 frames per second rendering on a 3+GHz machine, and suffering from heavy image distortions when used on animated sources with duped frames. The prof studio hardware converters naturally come as black boxes, heavily secured against backward engineering. The algorythms are well protected company secrets...

And remember, the simple method works only for us "lucky" 25fps PAL people due to the 1fps difference 24>25fps, you cannot use that for NTSC 30fps reconversion unless theMIXED fps source is MOSTLY 30fps, which hardly never occurs... This is why 24/25->30fps conversion has to use such ugly solutions as interlaced telecine or blurry frame blending on progressive sources, at least until now.

The reason why Home Cinema dedicated LCD/Plasma Flat TVs offer a true 24fps mode is to completely avoid that 30fps NTSC legacy and its difficult and quality lowering FILM workarounds... in PAL countries FILM conversion is easily done just with the mentioned slight speedup, and noone would notice the difference between 24/25fps.
« Last Edit: April 08, 2008, 02:04:49 am by teucom »

Offline pokute

  • n00b Hero
  • *
  • Posts: 33
    • View Profile
Re: VFR (No, nothing to do with aircraft.)
« Reply #6 on: April 08, 2008, 05:24:54 pm »
That may be. But if you get most of your dvd's from China and India, you have a lot of material that did not benefit from this sophisticated hardware. With these dvd's I am happy to settle for simple linear blending, combined with the progressive mode of my TV, which at least makes them watchable.

Since the problem that I was trying to solve requires only the detection of small chunks of "proper" (not pathological) hard-telecine content, which the Transcode 32detect filter can do, I think I will be able to do what I want to do, which is to properly decimate small sections of 30fps content in 24fps content, without accidentally dropping a keyframe. Mencoder, btw, does not seem to offer a filter that can detect hard-telecine reliably.

Offline bastard-sama

  • Live Evil Members
  • Rakuen Hero
  • *
  • Posts: 311
  • in the middle of nowhere
    • View Profile
Re: VFR (No, nothing to do with aircraft.)
« Reply #7 on: April 09, 2008, 09:08:25 am »
so what is this aircraft about?
The resident bastard.

Offline pokute

  • n00b Hero
  • *
  • Posts: 33
    • View Profile
Re: VFR (No, nothing to do with aircraft.)
« Reply #8 on: April 09, 2008, 08:27:42 pm »
so what is this aircraft about?

Eh?  ???