Log in

View Full Version : Mixed framerate in Cowboy Bebop


tormento
8th November 2022, 03:04
Cowboy Bebop in italian BDs has been encoded in a clever but strange way.

The entire video has been soft tagged as 29.97p but when playing you can see the real framerate change. There parts in 23.976p (hand drawn) and others in 60i (CGI).

Is there a way to instruct x265 what parts to encode as 23.976p and what parts as 60i? And how to automatically recognize those parts?

Perhaps I am wrong but something bad could happen if I encode the whole movie as 29.97p, simply ignoring the real framerates.

Blue_MiSfit
8th November 2022, 04:56
I believe mixed frame rates like this are common with anime, unfortunately.

There are methods to encode content with variable frame rate, but I'm not personally familiar with them.

A simpler technique (which I don't necessarily advise, just pointing out) is to use a really good motion adaptive bob-deinterlacer to bring the content up to 59.94p. A good deinterlacer should simply dupe the progressive frames as-is, yet create cleanish progressive frames from each interlaced field when appropriate.

The downside is that coding everything at 59.94p is less efficient, but modern codecs are pretty good at coding skip frames / blocks :)

This will probably give you better playback results than just encoding at 29.97p and hoping your player figures out when sections are interlaced so it can switch to bobbing.

The VFR process certainly involves an analysis process and storing some timing info, then muxing that into your result, and depending on player support.

rwill
8th November 2022, 05:53
HEVC does not support frame based interlaced to begin with ...

benwaggoner
8th November 2022, 21:50
Arguably, converting it into 120p is your highest quality option, if supported by your target players. That's a multiple of all the standard animation frame rates, so it won't bake in judder like encoding to just 24p or 30p. And it's a lot easier and more reliably to get the inverse telecine/deinterlacing done right in preprocessing versus encoding as is and rely on myriad playback devices to figure out how to optimally extract the content frame rate from a 30i stream. Because they will get it wrong, for particularly this use case.

The bitrate shouldn't really be impacted if the content isn't noisy, as you'll get tons of skip CUs and skip frames where there aren't frame-to-frame changes. Lower frame rates only improve efficiency if they're throwing out temporal or spatial data, which is not what you want! The bitrate shouldn't be higher than encoding the source as-is at 30i, as HEVC isn't particularly good at interlaced encoding. Interlaced support at all was a pretty last-minute addition.

That said, make sure the 30i is actually 60 unique fields per second, and not 24 with 3:2 pulldown applied. Sounds like that is the case here.

tormento
8th November 2022, 23:06
Arguably, converting it into 120p is your highest quality option
Mmm... I don't know about player and device compatibility.

Thanks for your explanation and how did they encode that way for the BD?

Another option is, indeed, just recompress to hevc and leave the very same framerate that they used.

Blue_MiSfit
9th November 2022, 04:43
Thanks for your explanation and how did they encode that way for the BD?



Probably by just encoding it at 29.97i :) Lots of horrible things have been done in disc authoring by ill-equipped post houses.

This used to be a very hot industry, but sadly the money isn't really there anymore.

RanmaCanada
9th November 2022, 07:35
I would just leave it as a remux as anime mastering is completely hit and miss, and this appears to be a massive miss. I'm sure the dvd's are better quality anyways, and that these are just a bad upscale, as most anime from that time being transfered to bluray is.

tormento
9th November 2022, 09:54
I'm sure the dvd's are better quality anyways, and that these are just a bad upscale
Dynit did it on purpose. It was the only way, to them, to preserve the crispness of every scene.

RanmaCanada
9th November 2022, 23:55
Dynit did it on purpose. It was the only way, to them, to preserve the crispness of every scene.

It's not, as Animego in the past has cleaned up Macross which is much older. What they could do is go back to the original film and rescan and clean it up. Instead, most houses just take the dvd and do a horrible upscale, and we are also seeing people use AI to upscale older content with the claim they are making it better.

Upscaling the dvd is them being cheap. Nothing more.

benwaggoner
10th November 2022, 22:18
Probably by just encoding it at 29.97i :) Lots of horrible things have been done in disc authoring by ill-equipped post houses.

This used to be a very hot industry, but sadly the money isn't really there anymore.
Yeah, for disc things would get left at 30i for the most part, or remastered to 24p when feasible. In a lot of cases the pirated download of an anime could look better than the disc or broadcast version due to well-tuned preprocessing and frame reconstruction. Generally the only challenge there is if there are native 30i elements (which get judder converted to 24p unless some fancy optical flow stuff gets applied), or if cel elements got composited out of sequence on a 30i timeline. the first season of Family Guy is an infamous example. Plenty of shots have different cels running at a different 3:2 cadence than other cels on the same frame!

The AVISynth scripts to fix that back in the day were long, subtle, and ran slowly.

mp3dom
11th November 2022, 15:06
Unlike two episodes that were upscaled (by japanese themselves), the rest of the title is based on real HD source, but at that era (1998), most parts were made on film, and some parts were made digital. The end result is a mixture of real HD 23.98p source with upscaled 30p parts and even some real 60i parts (due to a later editing made for the "remix" episodes). Forcing real 30p or 60i parts to 23.98p would lead to juddering or interlacing artefacts left into the image, plus, since it's an official distribution, we can't alter the image too much (i.e. "new" mo-comped frames).
The italian encode was made with a BD encoder that allows to flag the frames/sequences as pulldowned, interlaced or progressive. Pulldown frames are ivtc'ed and progressively encoded at 23.98+RFF, 30p progressive frames are encoded as progressive but flagged interaced, and 60i interlaced frames are encoded... interlaced. Everything is then carried in a 59.94 framerate but a quite smart decoder should recognize how to handle the playback correctly.

I personally think this is more "hit" than a "miss", because the bitrate is used in a better and smarter way.

tormento
12th November 2022, 10:33
I personally think this is more "hit" than a "miss", because the bitrate is used in a better and smarter way.
The thing is that I can't have an idea about how to encode that in the best way.

mp3dom
12th November 2022, 14:25
x264 and x265 doesn't allow to encode mixed content together. You can index the files with DGIndex, set to honor the pulldown flag and encode everything at 59.94i (that's how the japanese version was made), or ivtc everything at 23.98 (that's how the US edition was made) but a couple of episodes can't be fully converted to 23.98, you need to do additional postprocessing in Avisynth to fix them and probably you'll still get some problems (small sequences with judder or small artefacts).

Sunspark
12th November 2022, 23:53
Does the possibility exist that the video file could be sectioned out, each section with a different refresh rate encoded separately, and then re-joined?

poisondeathray
13th November 2022, 00:24
Does the possibility exist that the video file could be sectioned out, each section with a different refresh rate encoded separately, and then re-joined?

Yes, VFR - popular among anime forums

Each section runs at it's proper frame rate, encoded with unique frames, so it's the most efficient encoding wise (instead of hardcoding duplicates in a pattern), and timestamps (used to be called "timecodes", but it's the same thing) keep everything in sync and specify the display times per frame. x264 supports this encoding directly with --tcfile-in , or you can mux in timestamps in mkvmerge (for mkv), or mp4fpsmod (for mp4)

Compatibility is generally a non issue with almost all devices in the last 10 years, phones, tablets, computers. TV's , BD players and set top boxes that can play "files" directly such as MP4, MKV via usb/sd usually support VFR correctly as well.

The original 2pass TIVTC does not do the 59.94p sections correctly for VFR - there are some threads about that on this forum. I believe ctools addresses that, by I haven't tried it.

benwaggoner
13th November 2022, 04:00
Yeah, if you can do VFR, that's the best option. I doubt there are many devices our there that can decode 120p that can't decode VFR.

Note that repeat frames are essentially nil bitrate if they are truly encoded as repeat frames; the frame becomes just a frame_repeat tag. The --frame-dup and its threshold could be useful in making that work correctly, although I personally haven't had much luck with it.

PoeBear
13th November 2022, 04:59
For an encode, I would probably IVTC to 23.976 like the US Blu-ray

And then put in some extra work for the CGI scenes. 60i -> 23.976 would likely look fine, but the 29.97 scenes would probably need some interpolation to a higher framerate, and then a reduction down to 23.976, or else the motion may be too jumpy if just doing a simple TDecimate/frame drop

Boulder
13th November 2022, 08:58
Yes, VFR - popular among anime forums

Each section runs at it's proper frame rate, encoded with unique frames, so it's the most efficient encoding wise (instead of hardcoding duplicates in a pattern), and timestamps (used to be called "timecodes", but it's the same thing) keep everything in sync and specify the display times per frame. x264 supports this encoding directly with --tcfile-in , or you can mux in timestamps in mkvmerge (for mkv), or mp4fpsmod (for mp4)

Compatibility is generally a non issue with almost all devices in the last 10 years, phones, tablets, computers. TV's , BD players and set top boxes that can play "files" directly such as MP4, MKV via usb/sd usually support VFR correctly as well.

The original 2pass TIVTC does not do the 59.94p sections correctly for VFR - there are some threads about that on this forum. I believe ctools addresses that, by I haven't tried it.

Kodi based media players may have issues with hybrids that have typical NTSC framerates, unless you enable "Sync playback to display". This has then its own issues like disabling audio passthrough. PAL VFRs (25/50 fps) work fine.

mp3dom
13th November 2022, 14:31
Does the possibility exist that the video file could be sectioned out, each section with a different refresh rate encoded separately, and then re-joined?

Yes as long as you play that "file" as a mp4/mkv and similar.
No if you want to do a proper bluray disc because the buffer and vbv on the join sections are completely out of control and would probably lead to buffer over/underflows.

benwaggoner
14th November 2022, 18:37
For an encode, I would probably IVTC to 23.976 like the US Blu-ray

And then put in some extra work for the CGI scenes. 60i -> 23.976 would likely look fine, but the 29.97 scenes would probably need some interpolation to a higher framerate, and then a reduction down to 23.976, or else the motion may be too jumpy if just doing a simple TDecimate/frame drop
This is really where optical flow style techniques can really pay off. I remember being blown away by Apple's Compressor's optical flow resampling on my old Mac G4 workstation. Also took several hours per minute of standard definition content I was playing with.

30i to 24p works really well when the 30i was generated from 24p via 3:2 pulldown in the first place. but if it's rendered native 30i with 60 unique fields per second, it's the same conversion as from 60p. Scrolling credits can get a lot of judder without some sort of advanced temporal interpolation.

"Sufficiently advanced preprocessing is indistinguishable from rotoscoping."

kolak
3rd February 2023, 00:40
There are at least few motion adaptive/AI tools which will do 30p to 24p at acceptable level.
AVS FrameRateConverter is probably one of them- its quite advanced now and has RIFE AI interpolation implemented.
Others are GV File (aka Alchemist) and Tachyon (Tachyon may be better for this case).

Other way around (24p to 30p) is way more problematic.

g0ren
11th April 2023, 19:20
The italian encode was made with a BD encoder that allows to flag the frames/sequences as pulldowned, interlaced or progressive. Pulldown frames are ivtc'ed and progressively encoded at 23.98+RFF, 30p progressive frames are encoded as progressive but flagged interaced, and 60i interlaced frames are encoded... interlaced. Everything is then carried in a 59.94 framerate but a quite smart decoder should recognize how to handle the playback correctly.


If you're at liberty to say, which BD encoder was used if it wasn't x264?

tormento
14th April 2023, 06:44
AVS FrameRateConverter is probably one of them- its quite advanced now and has RIFE AI interpolation implemented.
As I am new about this topic and the files are still lying on my SSD, can you show us some script examples and results?