Log in

View Full Version : Best command script for encoding Separate Field Interlaced files?


cjdavis83
5th September 2021, 22:17
Hi!

I have been trying to encode some interlaced NTSC video with interlaced frames (preserving interlacing and fields) but in my previous attempt, I somehow got interleave fields as an output. The original source was from analog capture (the source is true analog, interlaced NTSC video - not telecined).

In another forum, I was told that separate field interlacing outputs a progressive file, which is what it did?

I have attached an image of the screen shot from MediaInfo which shows the scan type as Interleaved Fields.
The command prompts I used for FFmpeg were:
ffmpeg -i - -f s16le -r 44.1k -ac 2 -i "/mnt/Mary-1.efm.pcm" -vcodec ffv1 -level 3 -framerate ntsc -pix_fmt yuv422p10 -vf hue=h=-20:s=1.15 -aspect 4:3 -acodec wavpack /mnt/Mary-1.mkv

I need to know if there is anything I must change in the scripts to retrieve and preserve originally captured field rate and interlacing as well as video resolution?


Do I need to select a 'planar' type YUV color space to support non-interleaved interlacing? If so, what?

Read more: http://www.digitalfaq.com/forum/video-conversion/12155-best-command-script.html#ixzz75cyCCSdv

VoodooFX
5th September 2021, 23:33
Where is your Avisynth script or sample?

johnmeyer
6th September 2021, 03:30
I am not sure what you are asking.

If you have a result that is separated into fields, then you can recombine them into a normal interlaced video using selecteven(), selectodd(), interleave() and weave().

Here is code from a script I have lying around. As you can see it first separates the video into fields (which is what I think you have, and which you want to fix); it then calls my RemoveTears() function for the top and then the bottom fields. Finally, it takes those top and bottom fields and recombines them back into interlaced video.

So the steps are:

1. Put your separated video into even and odd fields.
2. Interleave those fields
3. Weave the fields back into interlaced video.

Actually, depending on what you actually have, you may only need to do #3.

function Remove_TearsI(clip source) {
ml = 100 # mask scale
scene_change = 200 # scene change

fields=source.SeparateFields()
even_fields=selecteven(fields)
odd_fields =selectodd(fields)

even_result_fields = RemoveTears(even_fields,ml,scene_change)
odd_result_fields = RemoveTears(odd_fields, ml,scene_change)

#Put even and odd fields back together into interlaced video
interleave(even_result_fields,odd_result_fields)
weave()

} # End Function RemoveTearsI

poisondeathray
6th September 2021, 03:49
In another forum, I was told that separate field interlacing outputs a progressive file, which is what it did?



It's encoded progressively when you use separate fields - because each separate field is a 720x240 picture of even or odd scanlines. Each single field is treated by the encoder as single picture - ie. progressive scanning. It's not a 720x480 collection of even scanlines with matte black odd scanlines, or 720x480 collection of odd scanlines with "black" even scanlines

But separated fields is still interlaced content - it's only organized as separated fields. If you weave the fields, you're back to interlaced interleaved fields. This is lossless if done correctly. Separated fields retains the original 720x240 resolution NTSC fields , at the 60000/1001 NTSC sampling rate

You cannot encode interlaced separated fields, because that would imply 720x120, or half fields at 120000/1001. It does not exist as a standard

cjdavis83
7th September 2021, 11:39
I am not sure what you are asking.

If you have a result that is separated into fields, then you can recombine them into a normal interlaced video using selecteven(), selectodd(), interleave() and weave().

Here is code from a script I have lying around. As you can see it first separates the video into fields (which is what I think you have, and which you want to fix); it then calls my RemoveTears() function for the top and then the bottom fields. Finally, it takes those top and bottom fields and recombines them back into interlaced video.

So the steps are:

1. Put your separated video into even and odd fields.
2. Interleave those fields
3. Weave the fields back into interlaced video.

Actually, depending on what you actually have, you may only need to do #3.

function Remove_TearsI(clip source) {
ml = 100 # mask scale
scene_change = 200 # scene change

fields=source.SeparateFields()
even_fields=selecteven(fields)
odd_fields =selectodd(fields)

even_result_fields = RemoveTears(even_fields,ml,scene_change)
odd_result_fields = RemoveTears(odd_fields, ml,scene_change)

#Put even and odd fields back together into interlaced video
interleave(even_result_fields,odd_result_fields)
weave()

} # End Function RemoveTearsI

Do you have a very short snippet you could upload? I did not realise that interleaved is now the uniform standard? It appears to me that it Interleaving is partly progressive and partly interlaced?

cjdavis83
7th September 2021, 15:34
If I wanted to use v210 uncompressed in am mkv wrapper, what command would I use? Can I use the same in ffmpeg?

poisondeathray
7th September 2021, 16:50
Do you have a very short snippet you could upload?


What would you like a snippet of ? code, video ? Be specific

I did not realise that interleaved is now the uniform standard?


Yes. Interleaved fields is just a method of storage. You can interleave or "deinterlave" (ie. separate fields) at your leisure - and this is a lossless operation if done correctly




It appears to me that it Interleaving is partly progressive and partly interlaced?

You have to distinguish between "type of encoding" vs. "content"

In terms of encoding, interlaced encoding of interleaved fields is always scan line based. Interlaced encoders use alternate line scans for search patterns, instead of zigzag (or other patterns) for progressive scanning.

In terms encoding, MBAFF is partially progressive, partially "interlaced" determined on a macroblock basis, not lines - It can be thought of truly "partly interlace, partly progressive" from an encoding standpoint

In terms of content, interleaved fields can be progressive, when there is no motion. When a field pair comes from the same moment in time - ie. there is no motion. e.g. A still image, or no camera or subject motion. The field pair is weaved into a full quality progressive image 720x480, instead of half resolution 720x240. This only occurs when interleaved fields are handled properly (weaved) and not deinterlaced upon playback, during those scenes with no motion. This is one of the main reasons broadcast engineers decided on the "interlace" tradoff many years ago in the first place - full progressive quality during scenes no motion, full temporal resolution (50Hz "PAL" /59.94Hz "NTSC") during scenes with motion , with lower bandwidth compared to full progressive


If I wanted to use v210 uncompressed in am mkv wrapper, what command would I use? Can I use the same in ffmpeg?

avisynth does not encode anything, it's just a frameserver - You have to "hook" it up to some encoder

Everyone is assuming you're referring to avisynth ,because you posted in the avisynth subforum

In ffmpeg v210 encoding in mkv container would look like


-c:v v210 -f mkv output.mkv


One difference is ffmpeg v210 encoder clips to [4,1019] instead of [0,1023] - that clipping is compliant with SDI and broadcast standards (those 0-3, 1020-1023 code values are reserved for SDI timing). But "computer" v210 utilizes full 10bit code values [0,1023] with no loss of precision. You can use vdub2 to get the full code values if you wanted to. Depending on the situation you might choose one over the other. If you've captured full code values or start with full code values - you technically incur some quality loss if clipping occurs (psnr will not be "infinity") when you use ffmpeg v210. To determine what you "started" with , you can check with a 10bit waveform. eg. FFmpeg has one, or avisynth does too

(my opinion - a codec shouldn't "clip" anything, it should be up to the user to clip or apply some filter)