Log in

View Full Version : Preserving interlacing?


shadowofdarkness
26th June 2015, 03:28
I need to clean up some space on my media server so I'm starting to convert any of my DVD mpeg2 content to HEVC so all content is interlaced and I was wondering do I have to do anything special over this command to have the output file have proper info on the interlacing. I have not seen any interlacing when watching my test files so I think I'm fine but mediainfo never shows that the output is interlaced so I may of just been lucky to not notice any.

My command to convert from makemkv mkv's created from retail DVD
ffmpeg -i input.mkv -c:v libx265 -c:a copy -c:s copy -x265-params crf=18:fast-decode output.mkv
The output is roughly 8.5% - 9.5% the size of the original and looks great on my TV (Player is a Raspberry Pi 2)

I'm not looking to de-interlace just make sure my current files are proper and with minimal changes just going from mpeg2 to x265

LoRd_MuldeR
27th June 2015, 19:00
First of all, MPEG-2 doesn't imply that the content is interlaced! Actually most movie DVD's are progressive. Some are telecine (https://en.wikipedia.org/wiki/Telecine#2:3_pulldown)'d, which means that even though you might be seeing "combing" artifacts, the original progressive frames can be restored easily (by using IVTC filter or "force film" mode). Only if the content is "true" interlaced, you need to bother about encoding it as interlaced (or, alternatively, applying a deinterlace filter). And do not get confused by stream flags! The stream flags only tell you how it was encoded; it does not tell you the actual nature of the content. Progressive content can be (and often is!) encoded as interlaced. In this case, the content is progressive and thus should be treated as progressive.

Secondly, HEVC/H.265 is a "progressive only" format, in the sense that HEVC/H.265 does not support special coding tools for interlaced video (such as MBAFF and PAFF in AVC/H.264). You can still encode interlaced footage with HEVC/H.265 though. But HEVC/H.265 then simply stores the fields of an interlaced video as separate (progressive) frames. There is a special SEI message included, which tells the decoder to weave the fields to an "interlaced" frames - after the actual decoding.

With x265, you can enable this "interlaced mode" by using the --interlaceMode (https://x265.readthedocs.org/en/default/cli.html#cmdoption--interlaceMode) parameter. But be aware: If you do this, "fields must be provided to the encoder, in the correct temporal order" and "the source dimensions must be field dimensions and the FPS must be in units of fields per second". In other words, if you used Avisynth to feed the source into x265, you would have to put a SeparateFields() (http://avisynth.nl/index.php/SeparateFields) at the end of your script for x265's --interlaceMode to work properly!

shadowofdarkness
27th June 2015, 22:01
Thanks for the info it helps me a lot, I never knew DVD content could even be progressive and seeing the mediainfo output talk about tff made me think it was interlaced even more. But I will try figuring out IVTC which I tried once but with forcing a deinterlace I had unusable output which turned me off on the process.

I had saw some stuff about that interlaceMode but it never worked and just a bit ago I found out it is actually just "interlace"

I will keep trying but sadly I can't use avisynth due to no access to Windows machines and I am using straight ffmpeg since I tried but failed to get avxsynth to work under Linux.

As I write this post I started a encode trying to IVTC using a quick Google search command but I'm seeing output like "Past duration 0.605644 too large" so I'll wait until the encode ends to figure out what that means and if it affects the output.

LoRd_MuldeR
27th June 2015, 22:15
Thanks for the info it helps me a lot, I never knew DVD content could even be progressive and seeing the mediainfo output talk about tff made me think it was interlaced even more. But I will try figuring out IVTC which I tried once but with forcing a deinterlace I had unusable output which turned me off on the process.

MediaInfo and similar tools, which only look at the stream flags, can not tell you whether the content is actually interlaced or not! They can only tell you how the stream has been encoded! But, as said before, a lot of progressive content happens to be encoded as interlaced. Still that content is perfectly progressive! So, if you want to know if some stream is actually interlaced or not, just watch it in a player that does not apply any post-processing filters - especially no deinterlacing or resizing - and go to scene with a lot of motion. If then you see the well-known "combing" artifacts (http://100fps.com/distortion2.jpg), the footage is probably interlaced (or telecine'd). Otherwise it is progressive, regardless of what any stream flags may indicate. Trust your eyes!

BTW: IVTC only works on footage that is actually telecine'd! It cannot fix "true" interlaced video. And applying IVTC filter on progressive content is only going to mess it up (or do nothing at all). So don't apply IVTC filter "just because you can".