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. |
![]() |
#1 | Link |
Registered User
Join Date: Sep 2023
Posts: 10
|
Encoding Interlaced Stream with Separated Fields
Hello, everyone! I'm writing with regards to a problem I've been having for maybe well over a month already, and which now is starting to drive me crazy.
I have a few interlaced MPEG2 (1080/25i, 1080/29.97i) streams on hand that I want to re-encode to AVC, while simultaneously changing the "Scan type, store method" to Separated Fields, and the "Scan Order" to TFF (Top Field First). The thing is I want to KEEP THEM INTERLACED...I'm not interested in de-interlacing. I was trying with ffmpeg at first, but gave up on it after a few botched attempts (i,e., the stream becoming progressive, horrible scanline artifacts, etc.). Then I was recommended some AviSynth scripts to see if I'll get what I need, which too didn't help...this script not only made my source progressive, but also dropped the frame rate from 29.97 to 12.500fps (not gonna lie, though...I think this was for progressive > interlaced conversion): Code:
LWlibavVideoSource("input.avi") z_ConvertFormat(pixel_type="RGBPS", colorspace_op="709:709:709:l=>rgb:709:709:f") Rife(gpu_thread=1, model=6, sc=true, sc_threshold=0.12) # defaults to double frame rate z_ConvertFormat(pixel_type="YUV420P8", colorspace_op="rgb:709:709:f=>709:709:709:l") AssumeTFF() SeparateFields() SelectEvery(4,0,3) Weave() Code:
LWLibavVideoSource("input.avi") AssumeTFF() SeparateFields() AssumeTFF() SelectEvery(4, 0, 3, 2, 1) Weave() AssumeTFF() Here's what the majority of my sources look like: Code:
Video ID : 4113 (0x1011) Menu ID : 1 (0x1) Format : MPEG Video Format version : Version 2 Format profile : Main@High Format settings : BVOP Format settings, BVOP : Yes Format settings, Matrix : Default Format settings, GOP : Variable Format settings, picture structure : Field Codec ID : 2 Duration : 3 min 58 s Bit rate mode : Constant Bit rate : 37.2 Mb/s Maximum bit rate : 33.3 Mb/s Width : 1 920 pixels Height : 1 080 pixels Display aspect ratio : 16:9 Frame rate : 25.000 FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Interlaced Scan order : Top Field First Compression mode : Lossy Bits/(Pixel*Frame) : 0.718 Time code of first frame : 00:00:13:11 Time code source : Group of pictures header Stream size : 1.03 GiB (74%) Color primaries : BT.709 Transfer characteristics : BT.709 Matrix coefficients : BT.709 Code:
Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : High @L4.1 Format settings : 3 Ref Frames Format settings, CABAC : No Format settings, Reference frames : 3 frames Format settings, GOP : M=3, N=15 Codec ID : V_MPEG4/ISO/AVC Duration : 3 min 58 s Bit rate mode : Variable Bit rate : 36.9 Mb/s Width : 1 920 pixels Height : 1 080 pixels Display aspect ratio : 16:9 Frame rate mode : Variable Frame rate : 25.000 FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Interlaced Scan type, store method : Separated fields Scan order : Top Field First Bits/(Pixel*Frame) : 0.718 Stream size : 1.03 GiB (74%) Default : Yes Forced : No Color range : Limited Color primaries : BT.709 Transfer characteristics : BT.709 Matrix coefficients : BT.709 |
![]() |
![]() |
![]() |
#2 | Link |
Registered User
Join Date: Sep 2023
Posts: 10
|
Also, forgot to add some of the files also have 4:2:2 chroma subsampling, which too I'd like to preserve in the re-encoding process. Soo, will be glad to receive advice on how to keep it.
And please also include the exact plugins and filters I'll need for the scripts. Thank you all in advance! |
![]() |
![]() |
![]() |
#3 | Link |
Registered User
Join Date: Jul 2018
Posts: 1,000
|
Scan type and store method is the option to your used MPEG4-AVC encoder. If you, for some reason, not like MBAFF for interlaced - you need to disable it in the AVC encoder options. Also if you can use MBAFF you need to provide interlaced options to AVC encoder. AVS do not make auto-deinterlacing but still send full frame to AVC encoder so it is task for AVC encoder configure person to set correct options for interlaced encoding.
"but also dropped the frame rate from 29.97 to 12.500fps" You can set AssumeFPS() at the end of script to provide any required framerate to downstream MPEG encoder. Or set framerate manually in the encoder options. Also RIFE() may not work with interlaced frames directly - you need to SeparateFileds() before (or better to make deinterlace - maybe with QTGMC() to double frame rate). "some of the files also have 4:2:2 chroma subsampling, which too I'd like to preserve in the re-encoding process. Soo, will be glad to receive advice on how to keep it." You need compatible with 4:2:2 MPEG encoder and provide required options for encoding format. The only task for AVS is to provide compatible data format (interleaved or planar format and maybe minor tweaks for chroma location). But you need to get compatible 4:2:2 formats list from your MPEG encoding engine. Last edited by DTL; 21st September 2023 at 15:00. |
![]() |
![]() |
![]() |
#4 | Link | |
Registered User
Join Date: Sep 2023
Posts: 10
|
Quote:
Do you know exactly how what I need can be achieved? Last edited by simon744; 21st September 2023 at 14:59. |
|
![]() |
![]() |
![]() |
#5 | Link |
Registered User
Join Date: Jul 2018
Posts: 1,000
|
If you use x264 for encoding it is better to ask in the MPEG4-AVC forum section how to configure it to interlaced encoding. AVS only responsible to output undamaged interlaced frames to encoder. For ffmpeg it is also some different forum how to feed AVS output to ffmpeg and set all required command line options for its AVC-encoding library. Same is about 4:2:2 - you may need special build of x264 (with High 4:2:2 Profile) and compatible with 4:2:2 output from AVS. Or compable build of ffmpeg.
Typically encoder output debug text about its input format and encoding mode - if input something not expected you can ask here about AVS scrpiting to generate required output. So your question is partially between AVS and MPEG encoder and configuration of MPEG encoder. Do you really want to double frame/field rate of your source ? Your expected output of AVC format shows standard 25 FPS frame rate. |
![]() |
![]() |
![]() |
#6 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,285
|
If the source content is interlaced, and it is encoded interlaced - you don't need avisynth or any scripts. (ie. the source is ok, and media players recognize it properly to begin with)
Just encode it interlaced - This does not change the "smoothness" or anything , it keeps it the content the same as the input. (In another forum you mentioned something about increasing smoothness, but provided no details about the content on the actual sources - mediainfo does not provide that information) . So the question is WHY are you doing this? The interpolation scripts assumed your sources were 25p content encoded as 25i. The script interpolates the content to 50p (synthesizing new inbetween frames, creating more samples), then re-interlaces to 25i (50 fields/s interlaced content and encoding) - this changes the actual content and increases smoothness, at the risk of artifacts (sometimes severe) . If you don't know what you have, post a sample of the source. Nobody can help you properly if you don't provide the correct information If you want AVC interlaced PAFF, x264 cannot do it - it only encodes MBAFF (There is a modified branch on github, but I don't know if it works and you have to compile to test it https://github.com/kierank/x264-paff) . MBAFF yields higher quality at the same bitrate compared to PAFF. MBAFF is compatible with most equipment and media players - many blu-rays and broadcasts use MBAFF But if you require PAFF, you can use NVEnc (FFMpeg or NVEncC) to encode interlaced PAFF with separated fields, but the quality is significantly lower (ie. you need higher bitrates to achieve similar quality) . The desired "output" mediainfo is 36.9Mb/s - so that is quite high and should be enough bitrate if that is your target bitrate range. Then the question again, is why are you doing this - the bitrate is about the same as the source. A side benefit is NVEnc encodes very fast (but requires an NVidia card) . Alternatively, you can use a paid NLE like Premiere Pro , but the quality is again lower for AVC PAFF using it's bundled encoder. |
![]() |
![]() |
![]() |
#7 | Link |
Registered User
Join Date: Jul 2018
Posts: 1,000
|
I see your post at videohelp forum about doubling frame rate while keeping interlaced storage domain.
To do it with better quality you need to decompress interlaced fields to frames (QTGMC()). Next double framerate (I hope RIFE() is good enough for this). And downsample fileds to interlaced format again. So script is something like Code:
Source("file.ext") QTGMC(preset=..) // convert 25i to 50 fps progressige high quality RIFE(..) // convert 50p to 100p fps in progressive domain UserDefined2Resize(b=.., c=.., src_top=0.0001) // apply some vertical conditioning (low-pass anti-Gibbs filtering) AssumeTFF() SeparateFields() SelectEvery(4,0,3) Weave() // sample 100p to 50i Last edited by DTL; 21st September 2023 at 20:24. |
![]() |
![]() |
![]() |
#8 | Link | ||||||
Registered User
Join Date: Sep 2023
Posts: 10
|
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
||||||
![]() |
![]() |
![]() |
#9 | Link | ||
Registered User
Join Date: Sep 2023
Posts: 10
|
Quote:
Quote:
As to the dots inside the parentheses, as in...: Code:
QTGMC(preset=..) Code:
RIFE(..) Code:
UserDefined2Resize(b=.., c=.., src_top=0.0001) |
||
![]() |
![]() |
![]() |
#10 | Link |
Formerly davidh*****
Join Date: Jan 2004
Posts: 2,478
|
One reason to ask such a question is that it may turn out that you don't need to after all - if your reason for thinking you need to turns out to be faulty - or it may allow someone to suggest an even more appropriate tool if we know more specifics. But just "I need to" doesn't help with either of those things.
|
![]() |
![]() |
![]() |
#11 | Link | ||||
Registered User
Join Date: Sep 2007
Posts: 5,285
|
Quote:
Again, mediainfo provides no information about the actual content. Mediainfo only provides information about flagging and encoding type e.g you could have progressive content encoded interlaced . You could have various pulldown patterns. You could have field blending. You could have phase shifting (looks combed but is progressive). Mediainfo does not report anything about the most important information - the content Quote:
Quote:
eg. ffmpeg nvenc PAFF encoding @ 40Mb/s , audio copied from source. Assumes HD source with Top field first Quote:
|
||||
![]() |
![]() |
![]() |
#12 | Link | |
Registered User
Join Date: Jul 2018
Posts: 1,000
|
Quote:
And yes - for .. arguments you need to read the docs on the listed filters to set best params for your task (typically defining quality/performance balance like profile for QTGMC or more settings, also anti-Gibbs/anti-aliasing prefiltering before downsampling progressive to interlaced scan mode depends on your source sharpness and all previous filters non-linearity and your preffered 'makeup/look' of V-sharpness/acutance of the output and balance with possible aliasing). Also as RIFE() typically (currently) only works with abstract float32 RGB samples only it is required more convert filters before and after like Code:
z_ConvertFormat(pixel_type="RGBPS", colorspace_op="709:709:709:l=>rgb:709:709:f") Rife(gpu_thread=1, model=6, sc=true, sc_threshold=0.12) # defaults to double frame rate z_ConvertFormat(pixel_type="YUV420P8", colorspace_op="rgb:709:709:f=>709:709:709:l") For 4:2:2 you need to change Code:
z_ConvertFormat(pixel_type="YUV420P8", colorspace_op="rgb:709:709:f=>709:709:709:l") "what would you recommend me to enter in place of them?" You can try to start with QTGMC(preset="Slow") - see examples at http://avisynth.nl/index.php/QTGMC Rife(gpu_thread=1, model=6, sc=true, sc_threshold=0.12) # defaults to double frame rate UserDefined2Resize(b=105, c=0, src_top=0.0001) - see https://forum.doom9.org/showthread.p...50#post1951250 for recommended b/c params combinations, increasing b/c makes things softer and decreases ringing,aliasing,sharpness,acutance. For simple start you can try replace it with Blur(amountV=0.5) (adjust param in about 0.2..1.0+ range). You may skip difference between PAFF/MBAFF interlaced encoding modes in AVC because typically MBAFF produces better quality so maybe only supported mode in opensource freeware encoders like x264 or libx264 . MediaInfo will report you MBAFF interlaced. Like Code:
Scan type : MBAFF Scan type, store method : Interleaved fields Scan order : Top Field First Last edited by DTL; 23rd September 2023 at 10:54. |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|