Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > High Efficiency Video Coding (HEVC)
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th November 2022, 03:04   #1  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,582
Mixed framerate in Cowboy Bebop

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.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 8th November 2022, 04:56   #2  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,989
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.
__________________
These are all my personal statements, not those of my employer :)
Blue_MiSfit is offline   Reply With Quote
Old 8th November 2022, 05:53   #3  |  Link
rwill
Registered User
 
Join Date: Dec 2013
Posts: 349
HEVC does not support frame based interlaced to begin with ...
rwill is offline   Reply With Quote
Old 8th November 2022, 21:50   #4  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
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.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 8th November 2022, 23:06   #5  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,582
Quote:
Originally Posted by benwaggoner View Post
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.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 9th November 2022, 04:43   #6  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,989
Quote:
Originally Posted by tormento View Post
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.
__________________
These are all my personal statements, not those of my employer :)
Blue_MiSfit is offline   Reply With Quote
Old 9th November 2022, 07:35   #7  |  Link
RanmaCanada
Registered User
 
Join Date: May 2009
Posts: 331
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.
RanmaCanada is offline   Reply With Quote
Old 9th November 2022, 09:54   #8  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,582
Quote:
Originally Posted by RanmaCanada View Post
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.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 9th November 2022, 23:55   #9  |  Link
RanmaCanada
Registered User
 
Join Date: May 2009
Posts: 331
Quote:
Originally Posted by tormento View Post
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.
RanmaCanada is offline   Reply With Quote
Old 10th November 2022, 22:18   #10  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
Quote:
Originally Posted by Blue_MiSfit View Post
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.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 11th November 2022, 15:06   #11  |  Link
mp3dom
Registered User
 
Join Date: Jul 2003
Location: Italy
Posts: 1,135
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.

Last edited by mp3dom; 11th November 2022 at 15:11.
mp3dom is offline   Reply With Quote
Old 12th November 2022, 10:33   #12  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,582
Quote:
Originally Posted by mp3dom View Post
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.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 12th November 2022, 14:25   #13  |  Link
mp3dom
Registered User
 
Join Date: Jul 2003
Location: Italy
Posts: 1,135
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).
mp3dom is offline   Reply With Quote
Old 12th November 2022, 23:53   #14  |  Link
Sunspark
Registered User
 
Join Date: Nov 2015
Posts: 471
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?
Sunspark is offline   Reply With Quote
Old 13th November 2022, 00:24   #15  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,377
Quote:
Originally Posted by Sunspark View Post
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.

Last edited by poisondeathray; 13th November 2022 at 00:41.
poisondeathray is offline   Reply With Quote
Old 13th November 2022, 04:00   #16  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
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.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 13th November 2022, 04:59   #17  |  Link
PoeBear
Registered User
 
Join Date: Jan 2017
Posts: 48
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
PoeBear is offline   Reply With Quote
Old 13th November 2022, 08:58   #18  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Finland
Posts: 5,733
Quote:
Originally Posted by poisondeathray View Post
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.
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 13th November 2022, 14:31   #19  |  Link
mp3dom
Registered User
 
Join Date: Jul 2003
Location: Italy
Posts: 1,135
Quote:
Originally Posted by Sunspark View Post
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.
mp3dom is offline   Reply With Quote
Old 14th November 2022, 18:37   #20  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,770
Quote:
Originally Posted by PoeBear View Post
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."
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 19:48.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.