Log in

View Full Version : How to encode 1080i source with x265 interlaced?


cagali
21st March 2019, 06:01
Source clip, a segment of a BD M2TS:
Bit depth : 8 bits
Scan type : Interlaced
Scan type, store method : Separated fields
Scan order : Top Field First
Bits/(Pixel*Frame) : 0.317

AVS:
LoadPlugin("LSMASHSource.dll")
LWLibavVideoSource("some.m2ts")

AssumeTFF()
SeparateFields() #actually the encoded .265 has the same md5 even if this line is removed



Command:
avs2yuv -raw %1.avs -o - | x265_SSSE3_32 --input-res 1920x1080 --fps 30000/1001 --interlace tff --preset medium --output %1.265 -- -

Using this setup, a resulting clip with the following mediainfo is encoded.


...
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 (30000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Bits/(Pixel*Frame) : 0.127
Stream size : 46.0 MiB (100%)
Writing library : x265 3.0+1-ed72af837053:[Windows][GCC 8.2.0][32 bit] 8bit+10bit+12bit
Encoding settings : cpuid=1049071 / frame-threads=2 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=1920x1080 / interlace=1
...


It cannot be correctly detected as 1080i TFF video with mpc-hc's lav video decoder using default settings.
If the "field order" is set to TFF instead of AUTO, the playback is somehow at 60fps.
However from the screen capture, it looks like it is force-deinterlacing a bad-deinterlaced progressive clip.

Are there any tools to check if the encoded clip is a properly interlaced one?
With mediainfo, it shows the "Scan type" of mpeg4 1080i as "MBAFF".
But for hevc 1080i clips, it shows nothing about the scan type.

Thank you very much!

(Yes interlaced mode is deprecated in x265.
This is just a test. :))

Selur
21st March 2019, 07:48
iirc.:

H.264 support Picture-adaptive frame/field (PAFF) and macroblock-adaptive frame/field (MBAFF) coding. So either per frame (paff) or macroblock (mbaff) it can decide whether to encode interlaced or progressive. (afaik x264 only supports MBAFF)
read https://forum.doom9.org/showthread.php?t=96598 it should clear what is possible with H.264
MediaInfo reports:
progressive encoding: "Scan type : Progressive" / "Frame Structure: Frame"
interlaced, PAFF: "Scan type : Interlaced" / "Frame Structure: Fields"
interlaced, MBAFF: "Scan type : MBAFF" / "Frame Structure: MBAFF"
see: https://forum.doom9.org/showthread.php?p=1631600#post1631600
H.265 only has the old either the clip as a whole is encoded interlaced or it is encoded progressive.


Are there any tools to check if the encoded clip is a properly interlaced one?
Not sure how to anwser this. Can you describe what's the difference between proper and improper interlaced content?

Personally I would look at the frames to decide whether the content is interlaced or not and then decide what I deemed best for my usage goal.

Cu Selur

cagali
21st March 2019, 08:22
iirc.:
Not sure how to anwser this. Can you describe what's the difference between proper and improper interlaced content?


Please cmiiw,
For h264 clips...

if the "scan type" flag in mediainfo is MBAFF, and when checking the screen capture, there are combed edges for moving objects, it should be a proper one.

if the "scan type" flag in mediainfo is Progressive, but there are still combed edges, then it should be a bad-interlaced (or bad-deinterlaced) clip. It happens when an interlaced source is fed to the x264 encoder without the --tff switch.

Personally I would look at the frames to decide whether the content is interlaced or not and then decide what I deemed best for my usage goal.

The source in the test is a truely interlaced/combed video, i.e. it is 30i before deinterlacing, and 60fps after that.

Selur
21st March 2019, 08:30
Assuming this isn't just a wrongly flagged stream (flagging interlaced as progressive) and really interlaced content encoded progressively, I sadly don't know of any tool that will detect such cases. :)

cagali
21st March 2019, 08:58
Assuming this isn't just a wrongly flagged stream (flagging interlaced as progressive) and really interlaced content encoded progressively, I sadly don't know of any tool that will detect such cases. :)

Thanks Selur.

Anyway it is just a side question.
The main one is "How to encode 1080i source with x265 interlaced (using avisynth)?"

:p

Sharc
21st March 2019, 09:28
Thanks Selur.

Anyway it is just a side question.
The main one is "How to encode 1080i source with x265 interlaced (using avisynth)?"

:p
You could try
AssumeTFF()
separatefields()

Now encode with x265 using --interlace tff --sar 1:2

From the doc:
https://x265.readthedocs.io/en/default/cli.html#executable-options

HEVC encodes interlaced content as fields. Fields must be provided to the encoder in the correct temporal order. The source dimensions must be field dimensions and the FPS must be in units of fields per second. The decoder must re-combine the fields in their correct orientation for display.