Log in

View Full Version : Encoding and deinterlacing DVDs using .avs


Blovesx
12th November 2018, 21:07
Hello,

Could someone help me with how to use .avs scripts properly? I have some ripped DVDs in which videos are interlaced in 30000/1001 NTSC format. I would like to encode the video using MediaCoder, ffmpeg, MeGUI or any other program with x264 codec and to use in the encode process my .avs script. I have never deinterlaced DVDs so I'd like to get some help from you.

I read trough a lot of threads and would like to deinterlace using YADIF + nnedi3 and FFT3DFilter. I have seen video sample using TempGaussMC but it's probably taking too long to deinterlace so I'm not thinking about this plugin anymore.

Load_Stdcall_Plugin("C:\Programs\MeGUI\tools\avs\plugins\yadif.dll")
LoadPlugin("C:\Programs\MeGUI\tools\avs\plugins\nnedi3.dll")
LoadPlugin("C:\Programs\MeGUI\tools\avs\plugins\fft3dfilter.dll")
Yadif(mode=0, order=-1, planar=false, opt=-1)
nnedi3(field=1)
FFT3DFilter(sigma=3)

Is there something wrong with this script?

I tried using MediaCoder x64 and load this script but nothing happened.
I tried using ffmpeg BUT I don't know how to write .avs script with plugins and x264 settings and what commands to use while typing in console ffmpeg .... ?
I tried using MeGUI but got error saying something about wrong version...

I have installed AviSynth 2.6.0 latest version from sourceforge, ffmpeg x64, plugins x64 and x32.

Should I install another version of AviSynth?
Could someone post how to write script that I can use with ffmpeg including x264 options?

... or maybe you guys recommend another way of encoding and deinterlacing video?

PS. I found in MediaCoder 2 options:
Motion Compensation?
IVTC?

Should these be used while deinterlacing? Also if the video is in NTSC format can I use -framerate 24000/1001 without destroying the flow of video without any stuttering?

Thanks a lot for any replies.

StainlessS
13th November 2018, 00:06
It may seem a little obvious, but do you do not seem to have a Video Source in the script ?

Blovesx
13th November 2018, 17:20
I'm using directshow. Should I use maybe avisource or the other avi?
Either way what I'm most interested in right now is how do you write script for ffmpeg to use x264 encoder with settings inside the script? Someone can post an example?

And also how to avoid stuttering if I want to change ntsc framerate to film one 24000/1001?

StainlessS
13th November 2018, 21:36
I have installed AviSynth 2.6.0 latest version from sourceforge
Use this one, Pinterf avs+, better than avs v2.6 standard:- https://github.com/pinterf/AviSynthPlus/releases
(Its a little difficult to find as Pinterf dont have his own thread and original avs+ thread points to a very old version, also Pinterf sig below his posts points to the source code and not the binary, so one has to do a little bit of investigating to find it).

Should I use maybe avisource or the other avi?

Dont know, you did not post full script and so we dont know if source is avi or not, but if it is, then AviSource is almost certainly better than DirectShowSource.
(DirectShowSource should be last option where everything else fails).

I have some ripped DVDs

In that case you would want to use DGIndex and MPeg2Source.
Post a sample on some file host (MediaFire often used [EDIT: zip it up first]),
In DGIndex, mark start ('[' symbol), and end (']') of a 10 second segment with motion, then on file Menu, "Save Project and Demux Video",
and post the "m2v" file. [EDIT: Dont bother with any other produced files]

The experts here will be able to tell you if your source is interlaced or film requiring Inverse Telecine rather than deinterlace.

To determine field order

... # source filter
AssumeTFF # or also try AssumeBFF
return SeparateFields
... #

And view in eg VDub2, if jumps backwards and forwards, then wrong field order, use the other one. [EDIT: Then remove SeparateFields]
[EDIT: Will be half height, resize in VDub2 to full size when viewing]

I tried using MeGUI but got error saying something about wrong version...
Although the guys here like a good mystery, it is preferable that you actually say what the error message was.

Others here can probably help you better than I, I'm from PAL land and dont have to play with NTSC much (HeHeHe).

Blovesx
13th November 2018, 22:58
Okay, um I have ripped DVD and what I have are .VOB files.

This is it about the file from MediaInfo:
Complete name : C:\dvd\VTS_01_1.VOB
Format : MPEG-PS
File size : 1 024 MiB
Duration : 16 min 52 s
Overall bit rate mode : Variable
Overall bit rate : 8 482 kb/s
Writing library : encoded by TMPGEnc Video Mastering Works 5 Version. 5.3.0.82

Video
ID : 224 (0xE0)
Format : MPEG Video
Format version : Version 2
Format profile : Main@Main
Format settings : CustomMatrix / BVOP
Format settings, BVOP : Yes
Format settings, Matrix : Custom
Format settings, GOP : M=3, N=16
Format settings, picture structure : Frame
Duration : 16 min 52 s
Bit rate mode : Variable
Bit rate : 8 121 kb/s
Maximum bit rate : 9 400 kb/s
Width : 720 pixels
Height : 480 pixels
Display aspect ratio : 16:9
Frame rate : 29.970 (30000/1001) FPS
Standard : NTSC
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.784
Time code of first frame : 00:00:00:00
Time code source : Group of pictures header
GOP, Open/Closed : Closed
Stream size : 980 MiB (96%)
Writing library : TMPGEnc Video Mastering Works 5 Version. 5.3.0.82
Color primaries : BT.601 NTSC
Transfer characteristics : BT.601
Matrix coefficients : BT.601

Audio
ID : 189 (0xBD)-128 (0x80)
Format : AC-3
Format/Info : Audio Coding 3
Commercial name : Dolby Digital
Muxing mode : DVD-Video
Duration : 16 min 52 s
Bit rate mode : Constant
Bit rate : 192 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 31.250 FPS (1536 SPF)
Bit depth : 16 bits
Compression mode : Lossy
Stream size : 23.2 MiB (2%)
Service kind : Complete Main


I'm overwhelmed by all of the scripts, plugins, programs...

I have installed the AviSynth+ and this is my script:
LoadPlugin("C:\Programy\AviSynth+\plugins64+\DirectShowSource.dll")
DirectShowSource("C:\dvd\VTS_01_1.VOB", fps=23.97, convertfps=true, pixel_type="YV12")
Load_Stdcall_Plugin("C:\Programy\AviSynth+\plugins\yadif.dll")
Yadif(mode=0, order=-1, planar=false, opt=-1)
LoadPlugin("C:\Programy\AviSynth+\plugins64+\nnedi3.dll")
nnedi3(field=1)
LoadPlugin("C:\Programy\AviSynth+\plugins64+\fft3dfilter.dll")
FFT3DFilter(sigma=3)

Am I missing something? When I tried to encode it trough ffmpeg I got error: Cannot load a 32 bit DLL in 64 bit Avisynth: 'C:/Programy/AviSynth+/plugins/yadif.dll'

So I downloaded yadifmod2 and it works fine.

This is all too hard for me. Maybe I will tell what I'm trying to achieve.
My goal is to encode the .VOB file to .mp4 file using x264 plugin with my own settings, deinterlace it and if possible change fps to 23.97 or if it's better to leave as it is then it's fine then I would like to save image sequences and run batch file to resize it and encode it back into .mp4 resized version.

PS. I have installed AviSynth+ x64 and x86, aswell ffmpeg x64, mediacoder x64, megui. If I should use different programs to do so let me know.

PS2. I have also installed VapourSynth64Portable I found on this forum it's probably for resizing video but I'd better stick with resizing images since it won't be a piece of cake to use this program probably...

Oh well that's it.

EDIT.
What should I write in the script if I want to encode all the .VOB files 01, 02, 03, 04 and join them together into .mp4?

Sharc
14th November 2018, 14:02
….I'm overwhelmed by all of the scripts, plugins, programs….. ….This is all too hard for me..... ….Oh well that's it.

EDIT.
What should I write in the script if I want to encode all the .VOB files 01, 02, 03, 04 and join them together into .mp4?
Hmmm….. much can go wrong. Maybe it's easier when you open the Video_ts folder which contains all your .VOBs in Handbrake and select .mp4 as output container. It will join the .VOBs and encode with x264.
I doubt that you should deinterlace. Your video is probably telecined film, but we would need a sample to be sure. So leave as is and don't resize it in a first attempt.

Edit: You could also import your DVD in BD-Rebuilder and select the .mp4 output container. You need to familiarize with BD-Rebuilder though and carefully follow its installation instructions.

Good luck.

FranceBB
15th November 2018, 09:21
If it's a VOB extracted from a DVD, don't use DirectShowSource, use DGIndex instead.
DGIndex it's gonna index your VOB and extract audio tracks.
Once you have done that, check whether it's truly interlaced or telecined.
If you are not sure whether it's interlaced or telecined, just try to deinterlace it first and go frame-by-frame; if it has dups, it probably means that it's telecined.

If interlaced:

#Indexing
video=DGDecode_MPEG2Source("video.d2v")
audio=WAVSource("audio.wav")
AudioDub(video, audio)

#Deinterlace to 29.970fps progressive
tdeint(mode=2, order=-1, field=-1, mthreshL=6, mthreshC=6, map=0, type=2, debug=false, mtnmode=1, sharp=true, cthresh=6, blockx=16, blocky=16, chroma=true, MI=64, tryWeave=true, link=1, denoise=true, slow=2, opt=4)

#Resize
Spline64Resize(848, 480)

if telecined:

#Indexing
video=DGDecode_MPEG2Source("video.d2v")
audio=WAVSource("audio.wav")
AudioDub(video, audio)

#IVTC to 23.976fps
tfm(mode=1,pp=5,slow=2,micmatching=2,clip2=tdeint(mode=2,type=3))
tdecimate(mode=2, rate=23.976)

#Resize
Spline64Resize(848, 480)

I hope it helps. ^_^

Blovesx
17th November 2018, 23:59
Why would I resize the original VOB to 848x480?

This is the information about my VOBs I have:
Stream Type: MPEG2 Program
Profile: main@main
Frame Size: 720x480
Display Size: 720x480
Aspect Ratio: 16:9 [3]
Frame Rate: 29.970030 fps
Video Type: NTSC
Frame Type: Interlaced
Coding Type: B
Colorimetry: SMPTE 170M
Frame Structure: Frame
Field Order: Top

It says also the pics/s are 29,97 also frames and fields 59940 (interlaced, tff) 3:2 sar, dar 16:9

What more... it is animation. So I believe I should save it as D2V project file using 'Honor Pulldown Flags' and use the IVTC one code you gave me? Should I also deinterlace it?

One more question I don't get about colours is which is the one people mostly use for PC? I'm always confused... but I'm sure in ffmpeg you can only choose yuv420p whatever it is meant to be. Also should I use yuv420p10 if I want to use x264 to encode to 10bit?

PS. Most important question I have 4 .VOB files from the DVD but I'd like to merge 2 of them only. Should I run it trough IVTC process then merge it using ffmpeg option? Then I can encode it for .mp4 format?

Maybe stupid question how do I use the script?

LoadPlugin("C:\Programy\AviSynth+\docs\dgmpgdec158\DGDecode.dll")
video=MPEG2Source("VTS_01_1.d2v")
audio=AC3Source("VTS_01_1 T80 2_0ch 192Kbps DELAY 0ms.ac3")
AudioDub(video, audio)

#IVTC to 23.976fps
tfm(mode=1,pp=5,slow=2,micmatching=2,clip2=tdeint(mode=2,type=3))
tdecimate(mode=2, rate=23.976)

Tried ffmpeg -i dvd.avs test.mp4 and nothing happened.

FranceBB
18th November 2018, 18:38
Why would I resize the original VOB to 848x480?


Your source is 720x480 which is anamorphic flagged 16:9.
720x480 can be either flagged 4:3 or 16:9, it's up to the player to display the correct aspect ratio.
You could leave it as it is and just flag it, but if you are gonna watch it on a computer, I think it's better if you resize it yourself to 16:9.

What more... it is animation. So I believe I should save it as D2V project file using 'Honor Pulldown Flags' and use the IVTC one code you gave me? Should I also deinterlace it?

Save it as it is, then use the IVTC code I gave you: TFM will use Tdeint to deinterlace and Tdecimate to detect dups and output 23.976fps.
This way, you'll have the original progressive framerate back.

One more question I don't get about colours is which is the one people mostly use for PC? I'm always confused... but I'm sure in ffmpeg you can only choose yuv420p whatever it is meant to be. Also should I use yuv420p10 if I want to use x264 to encode to 10bit?

I'll try to explain, then. ^_^

Color Sampling:

4:2:0, 4:2:2, 4:4:4 are the chroma sampling.
4:2:0 is generally the standard as it's supported by a wide majority of devices.
4:2:2 is generally used by studios in order to make mezzanine files. (I use it on a daily basis).
4:4:4 is generally used for master files and it retains as many details as possible for chroma.

The reason why the standard chroma sampling is 4:2:0 is that luma samples are more important than chroma samples for our eyes due to rods and cones.

Color Matrices:

The most known color matrices are BT601 (for SD contents), BT709 (for HD and FULL HD contents) and BT2020 (for UHD contents).
In your case, the color matrix is BT601 and you should keep it that way, unless you wanna upscale. In that case, you would have to convert it.

Levels (TV and PC):

TV and PC is actually just a different name for "Limited" and "Full".
TV range is Limited range. PC range is Full range.
Because TVs can't display as many things as PCs, everything that goes on air must be in Limited range, otherwise it will be refused on QC.
Limited range is 16-235 (0.0 - 0.7V), while Full range is 0-255 for 8bit.
In your case it's limited range, with 16 as pure black and 235 as pure white and you should leave it as it is.

Bit depth:

The standard has always been 8bit, but nowadays, with HEVC, UHD contents are 10bit.
As a matter of fact, x264 has been able to encode in 10bit for many years, but unfortunately it has never been standard and it was possible to play such files on computers only (and a very limited number of devices).
Anyway, Avisynth has been supporting high bit depth for years and there's a reason: filtering.
In other words, I always suggest to encode to 10bit in H.264 if you don't care about playback compatibility for two reasons:

1) If you wanna filter out issues, index your 8bit source, bring everything to 16bit, filter out issues, then dither it down to either 10bit or 8bit.
2) If you wanna encode an 8bit source to 10bit, it would still make sense to encode it to 10bit 'cause x264 will use 10bit precision calculations internally and it will manage to save more space (at the same quality) than 8bit.

If you do wanna have playback compatibility, then you should encode to 8bit.

Most important question I have 4 .VOB files from the DVD but I'd like to merge 2 of them only. Should I run it trough IVTC process then merge it using ffmpeg option?

You can do "append" with Avisynth


#Indexing
video=DGDecode_MPEG2Source("VTS_01_1.d2v")
audio=AC3Source("VTS_01_1.ac3")
AudioDub(video, audio)

#IVTC to 23.976fps
tfm(mode=1,pp=5,slow=2,micmatching=2,clip2=tdeint(mode=2,type=3))
tdecimate(mode=2, rate=23.976)

#Resize
Spline64Resize(848, 480)

part1=last


#Indexing
video=DGDecode_MPEG2Source("VTS_01_2.d2v")
audio=AC3Source("VTS_01_2.ac3")
AudioDub(video, audio)

#IVTC to 23.976fps
tfm(mode=1,pp=5,slow=2,micmatching=2,clip2=tdeint(mode=2,type=3))
tdecimate(mode=2, rate=23.976)

#Resize
Spline64Resize(848, 480)

parte2=last

#append
part1++part2



This way you'll have two videos, one after another, appended together.

By the way, may I suggest you to use x264, NeroAAC and Mp4box instead of ffmpeg?

Blovesx
19th November 2018, 20:59
One more thing is could you explain me how do I use the script and could you give me example scripts concerning the other programs and the commands to use them trough cmd aswell as the order in which I should use them? I have downloaded x264 10bit and 8bit version, NeroAAC and Mp4box now I need to know how to use them.

Another thing is I have installed AviSynth+ 64 bit should I use AviSynth+ x86 version instead? Do you recommend using x64 plugins or x86 plugins what's the difference?

Last one, you explained to me how the colors work but I'm still not sure is it i420 or yv12 I should use?
The reason why the standard chroma sampling is 4:2:0 is that luma samples are more important than chroma samples for our eyes due to rods and cones.

That would be it. Thank you for your interest in the topic.

hello_hello
20th November 2018, 10:18
If you use MeGUI, it should take care of your concerns, and it comes with the programs you mentioned, except for NeroAAC (copy it to the "MeGUI\tools\eac3to" folder if it exists, and enable NeroAAC in MeGUI's options).

MeGUI comes with a portable version of Avisynth+ that it uses by default. I assume 32 bit MeGUI comes with 32 bit Avisynth+ and 64 bit MeGUI includes 64 bit Avisynth+.
You can't mix and match. If you installed 32 bit Avisynth then you need to use 32 bit Avisynth plugins with it. It's probably better for the "installed" Avisynth to be the same as MeGUI's portable version, as then scripts created by MeGUI will open in other programs (only MeGUI uses it's portable version). There used to be a shortage of 64 bit plugins, although I think it's getting better now, but installing 32 bit versions of everything is probably the safer bet.

FranceBB
20th November 2018, 20:23
You should install Avisynth+ (pinterf) x86, 'cause it's more stable and there are many filters for it.
You can get a list of plugins from me as I included "plugins" and "plugins+" in the rar I uploaded: Link (https://mega.nz/#!uR8W0IZB!3YkgsKgFyMr1aQTgXEFZ6r1kFrkAX68--1GGQlKZTMg)

In the rar you'll find:
1) Plugins
2) Plugins+
3) encoder

In the "encoder" folder, you'll find avs4x264mod.exe, Bepipe.exe, NeroAAC.exe, MP4Box.exe, x264-10b.exe, Command Line H264 10bit.bat and AVS Script.avs.

Copy all my plugins in your plugins directory.
Make sure you have all the C++ Redistributable and .NET Framework installed.

Leave the AVS Script as it is, just make sure that the names and the path are correct.
Then, double click on the .bat and the encode should start.

The bat is pretty easy, it basically encode the video with x264 10bit in 4:2:0 High level 4.1 crf 19 and creates a ".h264" file.
Bepipe gets the audio from Avisynth and pipes the uncompressed audio stream to NeroAAC which encodes in AAC at 320kbit/s (bitrate should be enough, but you can change it).
NeroAAC creates a ".aac" audio.
Last but not least, MP4Box muxes video and audio and creates a ".mp4" file.

AVS Script:


#Indexing
video=DGDecode_MPEG2Source("VTS_01_1.d2v")
audio=AC3Source("VTS_01_1.ac3")
AudioDub(video, audio)

#IVTC to 23.976fps
tfm(mode=1,pp=5,slow=2,micmatching=2,clip2=tdeint(mode=2,type=3))
tdecimate(mode=2, rate=23.976)

#Resize
Spline64Resize(848, 480)

part1=last


#Indexing
video=DGDecode_MPEG2Source("VTS_01_2.d2v")
audio=AC3Source("VTS_01_2.ac3")
AudioDub(video, audio)

#IVTC to 23.976fps
tfm(mode=1,pp=5,slow=2,micmatching=2,clip2=tdeint(mode=2,type=3))
tdecimate(mode=2, rate=23.976)

#Resize
Spline64Resize(848, 480)

parte2=last

#append
part1++part2

#Color Matrix Conversion
ColorMatrix(mode="Rec.601->Rec.709", interlaced=false, threads=0, thrdmthd=0, opt=3)

#Clipping
Limiter(min_luma=16, max_luma=235, min_chroma=16, max_chroma=240)


Command Line H264 10bit.bat:

avs4x264mod.exe "AVS Script.avs" --x264-binary "x264-10b.exe" --preset medium --level 4.1 --profile High10 --crf 19.0 --vbv-maxrate 25000 --vbv-bufsize 25000 --deblock -1:-1 --overscan show --colormatrix bt709 --range tv --log-level info --thread-input --transfer bt709 --colorprim bt709 --videoformat component --nal-hrd vbr --output "raw_video.h264"

Bepipe.exe --script "Import(^AVS Script.avs^)" | neroAacEnc.exe -lc -br 320000 -if - -of "audio.aac"

mp4box.exe -add "raw_video.h264" -add "audio.aac" "final_output_10bit.mp4"

pause



Cheers

Blovesx
23rd November 2018, 04:23
Thank you for your help FranceBB. You helped me a lot and probably other people who were watching this thread.

Though, I had problems using the script you gave me but I found somehow the solution to it.

I had to use these plugins:
LoadPlugin("C:\Programs\AviSynth+\plugins\MPEG2DEC.dll")
LoadPlugin("C:\Programs\AviSynth+\plugins\DGDecode.dll")
LoadPlugin("C:\Programs\AviSynth+\plugins\NicAudio.dll")

and change:
video=DGDecode_MPEG2Source to video=MPEG2Source

as well as:
audio=AC3Source to audio=NicAC3Source

I don't know why but the script just wouldn't let me convert using the ac3audio.dll I had an error something with wrong argument or unable to find argument...

Since we're at it could you tell me how using this script I can encode part1 and part2 certain amount of time for ex. from 0 to 10 min. only not the whole file.

I'm not really sure what the rest of the script is doing:
#Color Matrix Conversion
ColorMatrix(mode="Rec.601->Rec.709", interlaced=false, threads=0, thrdmthd=0, opt=3)

#Clipping
Limiter(min_luma=16, max_luma=235, min_chroma=16, max_chroma=240)

but I left the color untouched so YUV 4:2:0 was being used.

Not really sure what's Limiter doing which plugin is responsible for this and ColorMatrix?

PS. Can I use NicAC3 to encode .ac3 format to also my chosen bitrate and bits, khz? It's said in documents only .raw file.
PS2. How should I approach the encoded file now if I want to save all the frames as image sequences so I can run batch file to resize it using another program? After that can I just use ffmpeg to connect image sequences into *.mp4 without encoding?

FranceBB
23rd November 2018, 06:46
I don't know why but the script just wouldn't let me convert using the ac3audio.dll I had an error something with wrong argument or unable to find argument...

You can use LWLibavAudioSource or FFAudioSource to index audio, it's not a big deal.

Not really sure what's Limiter doing which plugin is responsible for this and ColorMatrix?

As to Colormatrix, it converts from BT601 to BT709, but you could just flag x264 to encode it as BT601 and remove that line.
As to Limiter, it just makes sure that Limited TV Range is respected and values don't exceed the range 16-235. (Ever since I started working in broadcast, I started to be extremely concerned about tv range).

Can I use NicAC3 to encode .ac3 format to also my chosen bitrate and bits, khz? It's said in documents only .raw file.

As it is now, Avisynth just outputs an uncompressed audio and video stream which is encoded by x264 and NeroAAC, but if you wanna encode audio to AC3, you can just use ffmpeg to encode audio only.

You said that you wanted a specific frequency; in that case, you can either use ResampleAudio() or SSRC in Avisynth to feed the audio encoder (ffmpeg) with the desired sampling rate.

Like:

#Loudness Correction
ResampleAudio(48000)

Since we're at it could you tell me how using this script I can encode part1 and part2 certain amount of time for ex. from 0 to 10 min. only not the whole file.

You can just use "trim" and trim files.
For instance:

#Indexing
video=DGDecode_MPEG2Source("VTS_01_1.d2v")
audio=AC3Source("VTS_01_1.ac3")
AudioDub(video, audio)

#IVTC to 23.976fps
tfm(mode=1,pp=5,slow=2,micmatching=2,clip2=tdeint(mode=2,type=3))
tdecimate(mode=2, rate=23.976)

#Resize
Spline64Resize(848, 480)

#Trimming the first 1000 frames
trim(0, 1000)

part1=last


#Indexing
video=DGDecode_MPEG2Source("VTS_01_2.d2v")
audio=AC3Source("VTS_01_2.ac3")
AudioDub(video, audio)

#IVTC to 23.976fps
tfm(mode=1,pp=5,slow=2,micmatching=2,clip2=tdeint(mode=2,type=3))
tdecimate(mode=2, rate=23.976)

#Resize
Spline64Resize(848, 480)

#Trimming 5000 frames randomly (from frame 2000 to frame 7000)
trim(2000, 7000)

parte2=last

#append the trimmed parts
part1++part2

#Color Matrix Conversion
ColorMatrix(mode="Rec.601->Rec.709", interlaced=false, threads=0, thrdmthd=0, opt=3)

#Clipping
Limiter(min_luma=16, max_luma=235, min_chroma=16, max_chroma=240)

In the script above I just trimmed the first 1000 frames for the first video and 5000 frames randomly for the second video.
AVSPmod will also help you edit and preview Avisynth scripts, so you can actually *see* what you are trimming. ;)

Thank you for your help FranceBB. You helped me a lot and probably other people who were watching this thread.

You're welcome.
Whenever I have a little bit of spare time at work, I always go to Doom9.
I took so much from this community, as Avisynth helped me so much back in 2004 and ever since 2013 I tried to give something back (that's why I love open source). ^^

Blovesx
30th November 2018, 02:39
I'm back to ask for a few more things.

1. I have DVDs encoded as:
720x480 / 16:9
720x480 / 4:3

How should I do it to keep the 16:9 to be 16:9 and 4:3 to be 16:9? I will be encoding for PC usage.
So far I have tried the 16:9 video encoding using SAR 1:1 but then I got 3:2, SAR 16:9 got 2.667, SAR 40:33 got finally 16:9... but whatever I don't get it anyway.

If I use this 848x480 resize filter you told me to use I have from 720x480 / 16:9 again 16:9 somehow but this thing probably blurs the video because of resizing? I just love mathematics.
All I want to do is keep the video 720x480 / 16:9 so I can resize it to 1280x720p or 1080p. So probably I should tell x264 to use SAR 40:33 for 16:9 and for 4:3 SAR x ?

2. Do you know what's the difference here:
motion-adaptive cubic interpolation deinterlacing
motion-adaptive modified-ela deinterlacing

3. Can I move chapters from DVD to .mp4?

4. You've written few posts above about colours: is it i420 or yv12 I should use?

5. Could I ask you for PAL .avs settings if it's not top secret? Haha.

Thank you!

FranceBB
30th November 2018, 18:42
1. I have DVDs encoded as:
720x480 / 16:9
720x480 / 4:3

All I want to do is keep the video 720x480 / 16:9 so I can resize it to 1280x720p or 1080p.


You are dealing with anamorphic contents, 720x480 flagged as 16:9 or 4:3.
If you wanna resize it to 16:9, just resize it to 848x480, if you wanna resize it to 4:3, just resize it to 640:480.

If I use this 848x480 resize filter you told me to use I have from 720x480 / 16:9 again 16:9 somehow but this thing probably blurs the video because of resizing? I just love mathematics.

Yes, whenever you upscale a content, you introduce blur.
There are some upscaling kernels that are sharper than others, for instance Bilinear is kinda blurry, Bicubic is sharper than Bilinear but it's prone to introduce ringing, Lanczos is generally as sharp as Bicubic without introducing too much ringing.
What I generally use to upscale it's Spline, 'cause I find it very sharp and I like the idea behind it.
In order to get better results, you could also use NNEDI instead of a "simple" resizing kernel, but using NNEDI to do such a little upscale it's an overkill.

You said that you don't want to upscale and it's perfectly understandable if you don't wanna "waste" bitrate, however, you also said

All I want to do is keep the video 720x480 / 16:9 so I can resize it to 1280x720p or 1080p

I don't get it.
If you leave the content as it is (720x480) and you just flag it as 16:9, then it's up to the player to upscale it to the full resolution of your monitor.
Because players have to render the result in real time, the vast majority of them use something simple like a "FastBilinear" which is very blurry or something crappy like PointResize (if you love mathematics, then you'll love the explanation behind the nearest neighbour and other resizing kernel and you'll probably understand why I prefer a Spline-based resizing kernel): http://avisynth.nl/index.php/Resampling
In other words, if you wanna deliver the content on PCs, then keep in mind that the majority of people will see it with a random player that will use a "simple" resizing algorithm, so you are better off upscaling it using NNEDI and Spline64 than to let them upscale it.

Anyway, if you wanna leave it as it is and just flag it to the correct aspect ratio:

NTSC 4:3 DAR = 8:9
NTSC 16:9 DAR = 32:27

Could I ask you for PAL?

PAL 4:3 DAR = 16:15
PAL 16:9 DAR = 64:45

Can I move chapters from DVD to .mp4?

I'm pretty sure that you can have chapters in mkv, but I'm not sure for mp4; perhaps there's a way to do it via MP4Box.

You've written few posts above about colours: is it i420 or yv12 I should use?

yv12 is 4:2:0 planar in Avisynth.
i420 is the same but not in Avisynth.
Different terms, same meaning, I think.

Could I ask you for PAL .avs settings?

It's pretty much the same, but without the "inverse telecine" part.
Just use Tdeint with the normal settings to deinterlace (it will produce a 25fps progressive file) and upscale to 1024x576.


tdeint(mode=2, order=-1, field=-1, mthreshL=6, mthreshC=6, map=0, type=2, debug=false, mtnmode=1, sharp=true, cthresh=6, blockx=16, blocky=16, chroma=true, MI=64, tryWeave=true, link=1, denoise=true, slow=2, opt=4)

Spline64Resize(1024, 576)

Cheers.

Blovesx
1st December 2018, 21:43
FranceBB, do you mean I should use the same TFM settings and these "tdeint" settings you gave me post above for PAL DVDs without this setting?
TDecimate(mode=2, rate=23.976)

Another question. I downloaded a file but with funny settings I think so, do you know what to do in case of this funny encoded .mp4 file with these framerate settings?
Frame rate mode : Variable
Frame rate : 25.474 FPS
Minimum frame rate : 14.985 FPS
Maximum frame rate : 119.880 FPS
Original frame rate : 29.970 (30000/1001) FPS

I don't know how to re-encode it to 23.996 properly without any stuttering and big damage to the encoding. I believe someone encoded NTSC DVD somehow that way but can something be done to fix it? Do you have special settings for these kind of encodes?

Another question for you or someone who's knowledgable with color format who can explain to me how is that and what color primaries were actually used in the attached photos? I don't really get it but when I play the one encoded by x264 (default settings) and with resizer (spline) in a VLC or any other player I can see the same colors but inside of Photoshop it's different? BT706 is just encoded as extra one. Is the one done by spline64 copying color primaries from original DVD keeping BT601 and ignoring x264 default color settings i420?

x264 (default settings)
http://oi66.tinypic.com/5k35ht.jpg

Spline64
http://oi66.tinypic.com/dotj09.jpg

BT706
http://oi63.tinypic.com/zmb67d.jpg

Selur
2nd December 2018, 07:09
to put my two cents in,...

Frame rate mode : Variable
Frame rate : 25.474 FPS
Minimum frame rate : 14.985 FPS
Maximum frame rate : 119.880 FPS
Original frame rate : 29.970 (30000/1001) FPS
So the container of the file reports that the input is vfr with a frame rate between 14.986 and 199.880, the stream itself is flagged as 29.97 and the average frame rate is 25.474 fps and you want to go to 23.976.
(Audio sync issues aside)
In case your source really in some parts requires 119.88 to appear fluid, you won't get to 23.976 without stuttering.
My first approach for this would be to try some things:
1. remux the content to mkv drop the time codes in the process wo see whether the content has just broken time codes or not. If the content really is cfr and not vfr things would be easier. (you might still not get to 23.976 without stuttering, in case you need the 29.97fps for fluidity)
2. look at the actual frame to see whether there a duplicates, ghosting etc. In case you got clean pictures and motion between each frame you probably won't get to 23.976 without suttering
3. play around with sRestore and similar filters to go for 23.976 and see how they handle the file
4. if none of the above provides a usable solution I would think about whether writing a full custom script is really worth the time and effort. (depending on the nature of the clip something like Yatta/Wobbly/... or a script like AnimeIVTC might also be helpful)

copying color primaries from original DVD keeping BT601 and ignoring x264 default color settings i420?
Unless you got a RGB<>YUV conversion whether the content is BT/Rec.601 or BT/Rec.709 shouldn't matter, since the information isn't needed. (read: https://en.wikipedia.org/wiki/YUV)
So during normal DVD reeencoding where you stay the whole time in YUV 4:2:0 the only thing that is required is that the information is kept as a flag for the output (VUI) so the decoder of the player knows the right matrix when converting from YUV to RGB.
If the color between players/tools differ, it usually means that either the vui matrix information got dropped somewhere or simply got ignored.

Cu Selur

hello_hello
2nd December 2018, 10:02
Another question for you or someone who's knowledgable with color format who can explain to me how is that and what color primaries were actually used in the attached photos? I don't really get it but when I play the one encoded by x264 (default settings) and with resizer (spline) in a VLC or any other player I can see the same colors but inside of Photoshop it's different? BT706 is just encoded as extra one. Is the one done by spline64 copying color primaries from original DVD keeping BT601 and ignoring x264 default color settings i420?

i420 and BT601/709 are different things. I420 is a pixel format. Often referred to as YV12, although they're slightly different. You almost never have to specify an input colorspace with x264 when encoding normal video such as DVDs.
http://avisynth.nl/index.php/I420

BT601/709 describes how the YUV colorspace is converted to RGB on playback. It has to be converted to RGB as all displays are RGB. Normally when you re-encode a video though, it's decoded as YUV, filtered as YUV and re-encoded as YUV (at least in Avisynth). There's no RGB conversion in the process.

BT601 is the method used for most standard definition to convert the YUV colorspace to RGB. BT709 is generally used for HD. They're slightly different and that's why you're sometimes seeing a slight color difference. Your x264 and Spline64 screenshots have slightly different colours, by the way.

As standard definition is normally BT601 (unless you're re-encoding a video someone else downscaled) you'd set the following for the x264 colour matrix option.

For PAL it's --colormatrix bt470bg
It's the same as BT601.

For NTSC it's --colormatrix smpte170m.

For HD it's --colormatrix bt709.

I think the -colormatrix option is the only one that really matters, but "colormatrix", "transfer characteristics" and "color primaries" have no effect on how the video is encoded. They only offer suggestions as to how it should be converted to RGB on playback.

When upscaling or downscaling, I try to stick with the same colorimetry rules (BT601 for SD and BT709 for HD). In order to do that, the colormatrix filter can be using to convert BT601 to BT709 when upscaling.

ColorMatrix(mode="Rec.601->Rec.709", clamp=0)

Then you'd specify --colormatrix bt709 for the x264 encoder.
When downscaling, you'd do it the other way around.

If you don't convert the colors when upscaling and downscaling, then you should specify the original colormatrix. Many players will read the info and display the video correctly. Some players might ignore it and just use BT601 for SD and BT709 for HD anyway, so personally I think converting the colors when upscaling/downscaling is a good idea.


For encoding VFR sources...
I'd try decoding while converting back to the original frame rate (I think the 119.880 FPS maximum rate is going to be some sort of anomaly in MediaInfo's interpretation of the frame rate). In theory, conversion to the original CFR while decoding will replace the duplicate frames that were dropped to make it variable, and from there you can often apply IVTC normally, as required.

FFVideoSource("D:/Video/mp4", fpsnum=3000, fpsden=1001)
TFM().TDecimate() # if required

LSmashVideoSource has the same options.

If that doesn't work and the output isn't smooth, you can extract the timecodes (or ffmpegsource has an option to write a timecodes file while while indexing) and you can give the timecodes to x264 and it'll encode in VFR mode (in which case you wouldn't convert to CFR while decoding). If x264 writes directly to MKV, the timecodes will be included in the output file and all you need to do is add the audio etc.
The x264 option is this (the timecodes file name can be anything):

--tcfile-in "D:\video timecodes.txt"

MeGUI's OneClick encoder does that sort of thing for you these days. I think it assumes MP4 and MKV sources will be VFR by default (although I don't actually use the OneClick encoder myself).

Blovesx
3rd December 2018, 05:27
I'm back with some news (forgot to mention it was .mp4 file).

Here's what I did:
1. Since I had problems with opening the file in DGAVCIndex I demuxed the video out and I put .h264 inside of the program and run save project to take a look at the file.
Stream Type: AVC Elementary
Profile: High
Level: 4.1
Frame Size: 720x480
SAR: 32:27
Display Size: 853x480
Frame Rate: 29.970030 fps
Colorimetry: BT.601* [2]
Frame Structure: Frame
Frame Type: not yet
Coded Number: 22969
Playback Number: 22969
Frame Repeats: 0
Field Repeats: 0
Bitrate: 0.039
Bitrate (Avg): 1.520
Bitrate (Max): 5.110
Elapsed: 0:00:46
Remain: 0:00:00
FPS:
Info: Finished!


Framerate looks exactly like the ones I have on my DVDs.
Not really sure how do you read this: BT.601* [2] but inside of MediaInfo all I see is info that the file is using YUV colorspace (nothing is mentioned that the color matrix is BT.601 or anything).

2. Encoded using .h264 from DGAVC (I don't know if you can use .dga to change framerate of file):
video = FFVideoSource("TRY_track1.h264", fpsnum=30000, fpsden=1001)

Only that. I'm very happy with the output. It's super fluid as it should be without ghosting, blending, banding, duplicates... now the most important question: How do I sync the audio now?

I tried converting using MediaCoder and ffms with set framerate to 29.97 and it worked like a charm. I have no idea what settings the program used so I hope you will tell me how to set .avs script and neroaac settings. I got only info in the log:[12-03 02:59:16] Suspended for 1.3 secs to sync [AudioEncodeThread]
[12-03 02:59:18] Suspended for 1.8 secs to sync [AudioEncodeThread]
[12-03 02:59:19] Suspended for 1.8 secs to sync [AudioEncodeThread]

When I was looking into the log on google I found this thread where dev only said it's supposed to be like this: http://forum.mediacoderhq.com/viewtopic.php?t=13197


Okay, here's some replies to you Selur:
remux the content to mkv drop the time codes in the process wo see whether the content has just broken time codes or not
I don't know how you should read time codes so it's a black magic for me just a numbers (but I can see the video is going as it should every ~34 frames or whatever it is and the audio is also going in same numbers ~22).
Video: https://pastebin.com/A4SgJUMF
Audio: https://pastebin.com/qgiPEUuS (was too long, cut half of the file).

play around with sRestore and similar filters to go for 23.976 and see how they handle the file
Not tried yet but maybe I should just try the standard settings and see what happens now TFM().TDecimate() as hello_hello said or with different settings not defaults?

This is what I believe a video settings were before destroying the framerate (of course not same length):
Stream Type: MPEG2 Program
Profile: main@main
Frame Size: 720x480
Display Size: 720x480
Aspect Ratio: 16:9 [3]
Frame Rate: 29.970030 fps
Video Type: NTSC
Frame Type: Interlaced
Coding Type: P
Colorimetry: SMPTE 170M
Frame Structure: Frame
Field Order: Top
Coded Number: 30342
Playback Number: 2
Frame Repeats: 0
Field Repeats: 0
VOB ID: 1
Cell ID: 7
Bitrate:
Bitrate (Avg):
Bitrate (Max):
Audio Stream: 80: AC3 2/0 192
Timestamp: 0:16:51
Elapsed: 0:00:16
Remain: FINISH
FPS:
Info:

and last one considering colors:
If the color between players/tools differ, it usually means that either the vui matrix information got dropped somewhere or simply got ignored
~or I simply didn't encode with a code in .avs to say encoder about color matrix? I should add some line?


Some replies to hello_hello:
Your x264 and Spline64 screenshots have slightly different colours, by the way
Yeah, default x264 for x264 image and again default settings + resizing trough Spline64. That's it not sure why it's a bit different should I force some color matrix or something?

ColorMatrix(mode="Rec.601->Rec.709", clamp=0)
Then you'd specify --colormatrix bt709 for the x264 encoder
I got it. Just a personal question: do you prefer encoding DVDs with original color settings or full RGB is more popular for PC use? I'm not really using TV much or anything beside PC but does it matter nowadays what's the color primaries, is it TV range or PC or any x264 settings which won't allow to play encodes on TV? I know for sure I can't play High10 bit videos on my TV but everything else is playing fine. I wasn't even looking at if there is a difference in colors: DVD standards and RGB but everything is working.
Back to the topic FranceBB gave me this code I wasn't really looking into the plugins settings and what these means. How is it different from your simple Rec->Rec setting?
#ColorMatrix(mode="Rec.601->Rec.709", interlaced=false, threads=0, thrdmthd=0, opt=3)

and finally a last one:
If that doesn't work and the output isn't smooth, you can extract the timecodes (or ffmpegsource has an option to write a timecodes file while while indexing)
and you can give the timecodes to x264 and it'll encode in VFR mode (in which case you wouldn't convert to CFR while decoding).
If x264 writes directly to MKV, the timecodes will be included in the output file and all you need to do is add the audio etc.
That was just an option if the video settings wouldn't work and video wasn't smooth? I'm not really sure if I understand you. This --tcfile-in "x:\xxxx.txt" should be put in x264 encoder settings? What's the command to write in .avs script to get the file with timecodes trough ffms or can I aswell use timecodes taken from mkvtoolnix? Timecodes help with smoothing, settings the frames?

Phew, that's a lot of writing. Thanks for helping me out by the way guys!

Selur
3rd December 2018, 07:19
I don't know how you should read time codes so it's a black magic for me just a numbers (but I can see the video is going as it should every ~34 frames or whatever it is and the audio is also going in same numbers ~22).
timestamp format v2:
a. line for each frame
b. each line shows when to start displaying the frame in 'ms'
if the video is cfr (and isn't interlaced or telecined) the difference between the timestamps should ideally be constant.
Seeing that the timestamp differences between frames just switch between 33 and 34, I would drop the time codes.
To do that:
a. extract video using mkvextract
b. extract audio using mkvextract
c. multiplex audio&video using mkvmerge (make sure to set your frame rate during this step)
this way you dropped all time codes, if the multiplexed content plays fine/synch your content is cfr.

Not tried yet but maybe I should just try the standard settings and see what happens now TFM().TDecimate() as hello_hello said or with different settings not defaults?
I would try it, shouldn't hurt. (just make sure to adjust the output frame rate)

~or I simply didn't encode with a code in .avs to say encoder about color matrix? I should add some line?
If you don't use any rgb<>yuv conversion changing the color matrix is not really necessary. It's recommend to change it, when you resize between HD and SD, but it should not be necessary.
Question is what you are comparing, I thought you compared one file in different players, not a file and it's reencode.

Cu Selur

Blovesx
4th December 2018, 00:43
I did that but nothing is in synch... only the MediaCoder is helping me there restoring framerates to 30000/1001 and the audio is in sync though it's stuttering sometimes. Gah, I don't really know how to sync will have to read more when I will have more time.

One last question:
I put my original DVD .vob file into GSpot and it says (pics/s and frames/s = 29.97, progressive). When I look at the file it's 3:2 or 4:1 pulldown? I don't know how you call it... this is what happens: https://files.tinypic.pl/i/00975/9ug3t40a28sb.jpg

What settings should I use to encode it and plugins? What to choose in DGIndex (honor flags, force film or the other one?).

PS. What will happen when I encode the video trough x264 with audio then save frames as images run batch file resizer and encode them again with same settings and copying audio? I will have problems with sync? What to do if so?

hello_hello
4th December 2018, 18:28
video = FFVideoSource("TRY_track1.h264", fpsnum=30000, fpsden=1001)

Only that. I'm very happy with the output. It's super fluid as it should be without ghosting, blending, banding, duplicates... now the most important question: How do I sync the audio now?

If the audio was in sync originally, it should still be in sync. Converting the frame rate doesn't change the duration.
When VFR is decoded as constant frame rate without converting it, the frames, which would display for different durations, display with the same duration (usually the average), changing the audio sync.
Decoding while converting to CFR adds (or drops) frames to keep the frame rate constant, but the original frames should stay (roughly) in the same place, so the audio sync shouldn't change.

Edit: I just notice you're applying the frame rate conversion to a raw .h264 stream. I've no idea if a raw stream retains the VFR timecode information. I've only used the frame rate conversion method with an MKV as the source. It should work for MP4 though. From what you've said it appears to be working, but I've never done it that way. Likewise, I'm not sure if you'd be able to index a raw.h264 and have FFVideoSource write the correct VFR timecodes. Someone else may know.


I don't know how you should read time codes so it's a black magic for me just a numbers (but I can see the video is going as it should every ~34 frames or whatever it is and the audio is also going in same numbers ~22).

The audio timecodes aren't relevant here. The video timecodes.... well they can be almost impossible to interpret, especially as there's so many of them. For PAL (25fps) the frame durations are exactly 40ms. For 23.976fps the durations are roughly 41.708ms and for 29.97fps it's 33.667. The time-codes are usually in exact millisecond increments though, so for 29.97fps they usually alternate between 34ms and 33ms in some sort of pattern.

play around with sRestore and similar filters to go for 23.976 and see how they handle the file
Not tried yet but maybe I should just try the standard settings and see what happens now TFM().TDecimate() as hello_hello said or with different settings not defaults?

SRestore is designed to fix blending so it's not the right tool here (I assume). If your MP4 video was originally 23.976fps before it was encoded, it was probably converted to 29.97fps by repeating fields (3:2 pulldown), that process was reversed and it was encoding for the MP4 by dropping duplicate frames to become VFR, and you've put them back by converting to CFR. If that's all that happened, then the defaults for TFM().TDecimate() would be fine and the output would be 23.976fps CFR, but one reason for encoding as VFR is a video can be a combination of 23.976fps "film" sections and 29.970fps "video" sections.

TFM().TDecimate() can be used to convert "hybrid" video to a single constant frame rate (see the Hybrid option in the TDecimate help file), but it involves adding or dropping frames using frame blending. Often that's okay, as sources are often mostly one frame rate or the other, and back in the Xvid/AVI days they had to be CFR. Encoding as VFR avoids any conversion though (in theory the output ends up being a combination of two different constant frame rates). I live in PAL land but these days I'd encode any "hybrid" NTSC DVD as VFR.
That can also be done with TFM().TDecimate(). It requires 2 passes, but read the help file and if you can't make it work ask for help here. It's not hard once you know how to do it, although I use MeGUI to make it a bit easier.

Some replies to hello_hello:
Your x264 and Spline64 screenshots have slightly different colours, by the way
Yeah, default x264 for x264 image and again default settings + resizing trough Spline64. That's it not sure why it's a bit different should I force some color matrix or something?

When you upscaled, either the wrong colormatrix was set or no colormatrix was set. The SD source was probably meant to be converted with BT601 on playback, you upscaled it, so the player converted it using BT709 instead. I think DGIndex will give you the correct colorimtery if you open the index file with notepad, but that's also assuming the original video contained colorimetry info. Often it doesn't, in which case I'd assume SD was BT601 and HD was BT709. That's why converting to BT709 while upscaling is probably a good idea.


I got it. Just a personal question: do you prefer encoding DVDs with original color settings or full RGB is more popular for PC use? I'm not really using TV much or anything beside PC but does it matter nowadays what's the color primaries, is it TV range or PC or any x264 settings which won't allow to play encodes on TV? I know for sure I can't play High10 bit videos on my TV but everything else is playing fine. I wasn't even looking at if there is a difference in colors: DVD standards and RGB but everything is working.

For PC/full range the luminance levels are 0-255. 0 being black and 255 being white.
For TV/limited range the luminance levels are 16-235, where 16 is black and 235 is white.
Pretty much all video is limited range. Keep it that way. When playing video on a PC, a player (or your video card) should expand the limited range levels to full range. TVs expect limited range (although it can often be changed for when they're connected to PCs etc). These days, some PC monitors default to limited range for the HDMI inputs, even though PCs are traditional full range. The LCD monitor I bought a while back defaults to limited range. VGA and DVI inputs should always be full range.

Color primaries and TV/PC range are two different things. You can convert between TV and PC range with Avisynth.
ColorYUV(Levels="PC->TV")
but don't unless you know you need to.
The x264 --range option has no effect on how the video is encoded, it just provides information on how it should be decoded. You don't need to bother setting it at all.

Back to the topic FranceBB gave me this code I wasn't really looking into the plugins settings and what these means. How is it different from your simple Rec->Rec setting?
#ColorMatrix(mode="Rec.601->Rec.709", interlaced=false, threads=0, thrdmthd=0, opt=3)

interlaced=false is the default. If a video is interlaced I de-interlace first and then convert the colors if need be with interlaced=false. I've never used the other settings (I had to read the help file), but they control how colormatrix uses the CPU. Theoretically they'd ensure a more accurate conversion, so they can't hurt.


That was just an option if the video settings wouldn't work and video wasn't smooth? I'm not really sure if I understand you. This --tcfile-in "x:\xxxx.txt" should be put in x264 encoder settings? What's the command to write in .avs script to get the file with timecodes trough ffms or can I aswell use timecodes taken from mkvtoolnix? Timecodes help with smoothing, settings the frames?

If you encode the video using the timecodes file the output would have the same VFR as the source and there's no need to convert to a CFR, or use TFM().TDecimate(). You don't need to do anything else if x264 is writing the output directly to an to MKV. For MP4 you might have to add the timecodes file to the output and I'd have to research that one.
I always remux as MKV and extract the timecodes myself if necessary, but to get ffms2 to do it while indexing it should be:

FFVideoSource("D:\Video.mp4", timecodes="D:\VideoTimcodes.txt")

Once the indexing is done, it might pay to remove the timecodes option. I'm not sure if ffms2 would keep over-writing it otherwise.

--tcfile-in is just another x264 command line option. ie

--level 4.1 --preset slow --tune film --crf 18.0 --tcfile-in "D:\VideoTimcodes.txt"

If x264 rejects the timecodes file, open it with notepad and check to see it says this at the top

# timecode format v2

If it says

# timestamp format v2

change it.

The format name was changed (at least for mkv) a while back and the last time I tried it, x264 wouldn't recognise "timestamp".

Blovesx
7th January 2019, 22:56
Hello,

I'm back with a 2 questions but first regarding your post hello_hello I did tried to encode into CFR using timestamps but the outcome wasn't good I mean the audio was out of sync not sure if I encoded .raw video or .mp4. I will try to sync the audio somehow later on using timestamps again on .mkv file but for now I will leave the trouble makers (VFR files) because I'm stuck with other important things.

First - My goal is to achieve all video encodes to be 1280x720p (16:9).
I have right now mostly a lot of NTSC anamorphic DVDs with 720x480 resolution. Videos without anything to crop I'm leaving to encode as it is using SAR 1:1 in x264 settings not sure if I'm doing it right.
What to do if I have to crop videos like the one I have right now by 8 px from left and right. How should I approach this file?
I don't really know how to calculate the resizing... even though I'm using AvsPmod and resizing calculator (my videos are 3:2 sar, 32:27 par, 16:9 dar).

Second - What happens if I use IVTC on my NTSC videos to get it back to 23.97 fps, use a program like photoshop maybe to save image sequences keeping the framerate do some batching on all these frames and re-encode it back using same settings and same audio file? I did already tried it and everything is smooth and audio is not out of sync but just to be sure what I did is messing up something?

This is it:
#Indexing
video = ImageSource("%04d.jpg", 0000, 9999, 23.97)
audio = FFAudioSource("*.aac")
AudioDub(video, audio)
DelayAudio(0.000)