digitalFAQ.com Forum

digitalFAQ.com Forum (http://www.digitalfaq.com/forum/)
-   Capture, Record, Transfer (http://www.digitalfaq.com/forum/video-capture/)
-   -   NTSC 4:3 aspect ratio: 720x540?? (http://www.digitalfaq.com/forum/video-capture/12059-ntsc-43-aspect.html)

kingbean 07-30-2021 02:25 AM

NTSC 4:3 aspect ratio: 720x540??
 
Hello,

I am capturing my VHS tapes to lossless HuffYUV AVI files.

For uploading to YouTube/sharing, I am using ffmpeg to change the storage aspect ratio and re-encode to H.264 MKV files. This is working fine and I've got no problems.

For archiving the original HuffYUV files, I am using ffmpeg to change the display aspect ratio and remux into an MKV. I am changing the DAR only, with the intention being simple playback at the correct aspect ratio with no other changes to the file. SAR is not changed and the file is not re-encoded.

This was going fine working with my PAL tapes (I think), but now I've tried NTSC and I'm having difficulties. I've done a lot of Googling over the past few hours but haven't really got a clear answer.

My captured files (HuffYUV AVI):

PAL: 720x576 (5:4)
NTSC: 720x480 (3:2)

My ffmpeg command:

ffmpeg.exe -i input.avi -aspect 4:3 -c:a copy -c:v copy output.mkv

My proposed archive files (HuffYUV MKV):

PAL: 768x576 (4:3)
NTSC: 720x540 (4:3)

Now, most of what I'm reading online (and everything I knew about NTSC prior to this - mostly working at DVD level) was that the NTSC 4:3 resolution should be 640x480. So, I guess that leaves me with a few questions:

1. For the purposes of direct file playback only (no streaming or disc authoring), is there any downside to having a 720x540 4:3 DAR as opposed to 640x480?

2. If preferable, is there a way to flag the MKV to opt for 640x480 instead, while keeping the video stream otherwise unaltered? Preferably from the ffmpeg cmd line.

3. Is my PAL output correct? I think it's good, but now I'm so confused about NTSC I'm not certain.

As a final note: I am not looking to do any cropping/masking, I only want to store the raw capture file in an MKV container with DAR flags to correct the aspect ratio. As such, I haven't given any thought to cropping/masking the borders/'overscan' areas, 704x480 resolutions, etc. Is this part of my problem?

Thanks in advance! :question:

lollo2 07-30-2021 02:45 AM

For a PAL 720x576 capture SAR (Storage Aspect Ratio)=720/576, DAR (Display Aspect Ratio)=4/3 and PAR (Pixel Aspect Ratio)=DAR/SAR=16/15

Avi HuffyYUV files have no DAR information, with ffmpeg you can add the DAR parameter to the file, without changing anything else (you can also keep the same avi container)

Code:

ffmpeg.exe -i input.avi -aspect 4:3 -c copy output.avi
In this way, any player reading the DAR for displaying the video, will stretch it to proper 768x576 (576xDAR=576x4/3=768); ffmpeg documentation generally calls "SAR" what normally is called "DAR", generating some confusion.

For NTSC (where I have no experience) it should be the same with its own numbers, 720x480, but it is better if you wait the answer from some experienced NTSC user.

kingbean 07-30-2021 03:03 AM

Yeah it definitely gets confusing. I didn't realise the SAR/DAR terminology in ffmpeg documentation - but that shouldn't be an issue given the command is "aspect"?

Running the -aspect 4:3 command, it gives me the following:

Code:

Stream #0:0: Video: huffyuv (HFYU / 0x55594648), yuv422p, 720x480 [SAR 8:9 DAR 4:3], q=2-31, 65397 kb/s, 29.97 fps, 29.97 tbr, 1k tbn
In this case, SAR and DAR are the correct way around, right?

lollo2 07-30-2021 03:31 AM

I think so. Play with VLC and in Video -> Aspect Ratio change from Default (=DAR) to 4:3. Nothing should change. (If you do the same with the original file vithout the DAR flag the proportions change)

Edit: what ffmpeg calls SAR in its output is what normally is called PAR :-(

kingbean 07-30-2021 03:37 AM

Yep all good there. The files are displaying and playing back correctly, the 4:3 ratio is no problem - my concern more so is: is the 720x540 resolution a problem?

Sounds like, form what you\'ve said, my PAL outputs are fine, so it\'s just a matter of the NTSC.

lollo2 07-30-2021 03:56 AM

Not sure I understand what is 720x540. If a PAL capture is 720x576, should not a NTSC capture be 720x480? Then the same formulas should apply replacing 576 with 480. Some NTSC experienced user will surely help you.

latreche34 07-30-2021 01:06 PM

I don\'t think you are heading the right way, Avoid resizing as much as you can, Don\'t crop vertically and only crop to 704 horizontally to remove the black pillars added by the capture card:

http://www.digitalfaq.com/forum/vide...html#post74958

kingbean 07-30-2021 06:36 PM

Thanks for replying. I have that thread bookmarked and have re-read your post multiple times trying to wrap my head around this. :)

Quote:

Originally Posted by latreche34 (Post 74958)
Here are some SAR values for the 4:3 frame:

NTSC:
720x480 (DV/DVD, Full frame) -> SAR=8/9
704x480 (Analog Capture, SD Crop) -> SAR=10/11
640x480 (Square pixel, SD Resize) -> SAR=1

PAL/SECAM:
720x576 (DV/DVD, Full frame) -> SAR=16/15
704x576 (Analog Capture, SD Crop) -> SAR=12/11
768x576 (Square pixel, SD Resize) -> SAR=1

From what I understand, there is no difference to changing DAR rather than SAR, other than DAR sets flags and SAR will process the video. Correct?

Since I am looking to avoid any processing of the video stream, are you saying I need to set MKV crop flags, and then set DAR?

Maybe I should clarify my entire workflow, I might be more confused that I thought I was...

HuffYUV AVI to H.264 MKV: (for YouTube/sharing)

My .AVS file:

Code:

SetMTMode(5, 11)
AVISource("input.avi")
SetMTMode(2)
AssumeTFF()
ConvertToYV12(interlaced=true)
QTGMC(preset="faster", EdiThreads=6, ChromaMotion=true, border=false)

Which feeds into a .bat file:

Code:

:: encode video with x264\x264-8bit
:: --sar=12:11 for PAL --sar=10:11 for NTSC
x264-8bit.exe --preset=medium --sar=12:11 --crf=14 --output "outvid.264" "%~1"

:: take audio from input file and extract to flac
ffmpeg.exe -y -i "%~1" -vn -acodec flac "outaud.flac"

:: repack .264 and .flac files into MKV container with original file name
mkvmerge.exe -o "H:\%~n1.mkv" "outvid.264" "outaud.flac"

I've yet to run any NTSC files through that, however on checking my PAL output I see now that the output is 785x576 :smack: Cropping the borders would solve this? Something like:

Code:

SetMTMode(5, 11)
AVISource("input.avi")
SetMTMode(2)
AssumeTFF()
ConvertToYV12(interlaced=true)
QTGMC(preset="faster", EdiThreads=6, ChromaMotion=true, border=false)
Crop(8, 0, 704, 576)

Substituting 576 with 480 for NTSC.

Running the files through that, using sar=12:11 for PAL and sar=10:11 for NTSC, I get the following message during the final muxing:

PAL:
Code:

'outvid.264' track 0: Extracted the aspect ratio information from the MPEG-4 layer 10 (AVC) video data and set the display dimensions to 768/576.
Resulting file is 704x576 with aspect ratio reported as 4:3 (1.33), giving 768x576 playback - however this is not suitable for YouTube, as square pixels are required? Should I have a resize filter in my AviSynth script as well, something like Spline36Resize(768,576)?

NTSC:
Code:

'outvid.264' track 0: Extracted the aspect ratio information from the MPEG-4 layer 10 (AVC) video data and set the display dimensions to 704/528.
Resulting file is 704x480 file with aspect ratio reported as 4:3 (1.33), giving 704x528 playback. Am I cropping incorrectly?

Sorry, I'm feeling rather lost now. Any pointers or sample scripts would be greatly appreciated!

HuffYUV AVI to HuffYUV MKV: (for archiving and direct file playback)

No .AVS file.

ffmpeg remux:

Code:

ffmpeg.exe -i input.avi -aspect 4:3 -c:a copy -c:v copy output.mkv
Putting a PAL video through that gives me a 720x576 file. Aspect ratio reported as 4:3 (1.33), giving 768x576 playback - perfect for what I want here. If there's a way to crop borders without video processing or compromising playback support, I'm all ears, but otherwise, no further concerns for PAL archiving.

Putting an NTSC video through that gives me a 720x480 file. Aspect ratio reported as 4:3 (1.33), giving 720x540 playback - is there any reason I should be forcing this to play back as 640x480 instead, and if so how?

latreche34 07-30-2021 11:19 PM

You either set the pixel aspect ratio SAR or display aspect ratio DAR, don't do both or it will resize your output, I myself just set the SAR based on 704 to avoid 3% stretch. Note that the analog aspect ratio is based on 704 not 720 because 720 is for digital formats such as DV and DVD. I'm not too sure if setting the SAR will process the video, I've never done it without encoding anyway so I wouldn't know.

For youtube resize from 704x480(576) to 1440x1080 for square pixel, as a bonus youtube sees your video as HD and applies less compression.

kingbean 07-31-2021 04:37 AM

Can you provide a sample script/cmd of how you do that? All I have seen for ffmpeg is -aspect 4:3 which sets the DAR. And gives me 720x540 instead of 640x480.

Regarding YouTube, would Spline36Resize(1440,1080) after cropping be best? Or should I be resizing in ffmpeg/x264. I thought upscaling was a no-no. Does that change between NTSC and PAL? I haven't got time to test just now but will have a play with it tomorrow.

Thanks again.

latreche34 07-31-2021 10:47 AM

Resizing is for youtube only, Always keep a master copy of the original 704x480 4:2:2 lossless files.
I personally use AvsPmod, I drop the cropping, de-interlacing and resizing scripts there and process them all at once for youtube, it uses vdub plugin and QTGMC and gives you a visual frame to see the effect of each script instantly. I never encode for youtube, I just gives it the resulting lossless HuffYUV files after de-interlacing and resizing to 1440x1080 and let it use its own encoding, That's how you get the best quality for youtube.

I will post a copy of some scripts when I get home.

kingbean 07-31-2021 05:12 PM

Thanks!

As I mentioned, I'm keeping the master lossless files, simply looking to remux into MKV with appropriate aspect ratio.

Quote:

Originally Posted by latreche34 (Post 78872)
Always keep a master copy of the original 704x480 4:2:2 lossless files.

Are you capturing at this resolution?? Or are you going:

- Capture file: Lossless 720x480
- Cropped file: Lossless 704x480
- Delete capture file
- Cropped file is now the master copy?
- Run all processing using new cropped master copy

All I want is:

- Original HuffYUV AVI repacked in MKV with aspect flags (I'm happy with no cropping for these)
- Deinterlaced, cropped and resized H264 for YouTube (you are suggesting not using H264?)

My problem is:
- Setting DAR 4:3 on NTSC AVI gives me 720x540, not 640x480
- Completely lost on best method for YouTube :question:

Would love to see some scripts, thanks!

latreche34 07-31-2021 05:26 PM

Capturing at 720 and cropping to 704, Again it's only about 3% stretch if you keep 720 and don't mind the ugly 16 grey pixels on the sides of the frame. 704 is accurate, 720 is an approximation according to the D1 standard.

latreche34 07-31-2021 06:48 PM

Encoding for playback I use these ffmpeg scripts depends on whether the video is de-interlaced or kept interlaced:

Code:

NTSC i:
ffmpeg -i In.avi -vf "scale=w=-1:h=-1:interl=1,format=yuv420p,setsar=sar=10/11" -flags +ildct+ilme -c:v libx264 -crf 18 -x264opts bff=1:colorprim=smpte170m:transfer=smpte170m:colormatrix=smpte170m:force-cfr -c:a aac -b:a 192k Out.mp4

NTSC p:
ffmpeg -i In.avi -vf "format=yuv420p,setsar=sar=10/11" -c:v libx264 -crf 10 -x264opts colorprim=smpte170m:transfer=smpte170m:colormatrix=smpte170m:force-cfr -c:a aac -b:a 192k Out.mp4

PAL i :
ffmpeg -i In.avi -vf "scale=w=-1:h=-1:interl=1,format=yuv420p,setsar=sar=12/11" -flags +ildct+ilme -c:v libx264 -crf 10 -x264opts bff=1:colorprim=smpte170m:transfer=bt470bg:colormatrix=bt470bg:force-cfr -c:a aac -b:a 192k Out.mp4

PAL p:
ffmpeg -i in.avi -vf "format=yuv420p,setsar=sar=12/11" -c:v libx264 -crf 10 -x264opts colorprim=smpte170m:transfer=bt470bg:colormatrix=bt470bg:force-cfr -c:a aac -b:a 192k Out.mp4


traal 07-31-2021 06:55 PM

Quote:

Originally Posted by kingbean (Post 78839)
1. For the purposes of direct file playback only (no streaming or disc authoring), is there any downside to having a 720x540 4:3 DAR as opposed to 640x480?

With a 720x480 SAR file, 720x540 and 640x480 PAR are exactly the same thing. "720x540" just tells you that your video player window needs to be at least that big to see all the pixels.

A slightly different question is, which is a better resolution for capture, 720x480 or 640x480? I like 720x480 because it matches DVD, but others like 640x480 because of the square pixels, and both are high enough capture resolutions for VHS so there's no right answer.

latreche34 07-31-2021 08:03 PM

Capturing is always 720, Some capture cards have the option to resize on the fly but there is no such 640 capturing.

lordsmurf 07-31-2021 09:31 PM

Quote:

Originally Posted by latreche34 (Post 78885)
Capturing is always 720, Some capture cards have the option to resize on the fly but there is no such 640 capturing.

That's not accurate.

Some cards do have 640x480 hardware limitation, but it's mostly ancient late 90s capture hardware, or cheap Chinese 2000s cards (USB, PCI, other). I know of several USB1 cards that did 640x480, but I forget the names now, that was literally decades ago.

So while not accurate, nothing you'd see today. None of that stuff will run on modern Win7/8/10, and in fact many quite working due to Windows XP, being 95/98/98SE/ME hardware only.

In 2021, this is trivia, a footnote. :2cents:

kingbean 07-31-2021 09:47 PM

Quote:

Originally Posted by traal (Post 78884)
With a 720x480 SAR file, 720x540 and 640x480 PAR are exactly the same thing. "720x540" just tells you that your video player window needs to be at least that big to see all the pixels.

Great, thank you, that settles that part of my dilemma, then. I'll continue to set DAR 4:3 and archive the 720x576/768x576 and 720x480/720x540 master files.

I've got no intention to change my capture resolutions, 720 is perfect.

Quote:

Originally Posted by latreche34 (Post 78883)
Code:

NTSC i:
ffmpeg -i In.avi -vf "scale=w=-1:h=-1:interl=1,format=yuv420p,setsar=sar=10/11" -flags +ildct+ilme -c:v libx264 -crf 18 -x264opts bff=1:colorprim=smpte170m:transfer=smpte170m:colormatrix=smpte170m:force-cfr -c:a aac -b:a 192k Out.mp4

PAL i :
ffmpeg -i In.avi -vf "scale=w=-1:h=-1:interl=1,format=yuv420p,setsar=sar=12/11" -flags +ildct+ilme -c:v libx264 -crf 10 -x264opts bff=1:colorprim=smpte170m:transfer=bt470bg:colormatrix=bt470bg:force-cfr -c:a aac -b:a 192k Out.mp4


I'll try out these ffmpeg scripts now and see how I go with them.

traal 07-31-2021 10:41 PM

So, I prefer to archive the original .avi files verbatim as they came from the capture card (or rather VirtualDub), in case any software I use post-capture unexpectedly changes something in the file and I don't realize until it's too late.

Instead, I set the DAR in MkvToolNix when I'm combining the separately restored audio and video streams and creating chapters. (I don't know of an easier way to create chapters.)

kingbean 07-31-2021 10:43 PM

Quote:

Originally Posted by latreche34 (Post 78883)
Encoding for playback I use these ffmpeg scripts depends on whether the video is de-interlaced or kept interlaced:[/CODE]

Sorry I think I may have confused you with my rambling questions.

For playback I do not want ANY encoding whatsoever. Just a simple DAR change. traal's post above has put my mind at ease on this matter.

The only encoding I want to do is from the raw capture file to a YouTube friendly mkv/mp4. I tried the ffmpeg scripts you provided, but it didn't seem to be what I'm after. My interlaced, 720x480 NTSC AVI became an interlaced, 720x480/720x528 1.36 ratio MP4.

You'd mentioned earlier about giving YouTube a 1440x1080 file? Can you break it down step by step?

HuffYUV AVI > AviSynth script > ffmpeg script > YouTube friendly file

Scripts should be something like...

Code:

SetMTMode(5, 11)
AVISource("input.avi")
SetMTMode(2)
AssumeTFF()
ConvertToYV12(interlaced=true)
QTGMC(preset="faster", EdiThreads=6, ChromaMotion=true, border=false)
Crop(8, 0, 704, 576)
Spline36Resize(1440,1080)

and then

Code:

ffmpeg -i "%~1" -c:v libx264 -crf 14 -x264opts bff=1:colorprim=smpte170m:transfer=smpte170m:colormatrix=smpte170m:force-cfr -c:a aac -b:a 192k Out.mp4
Something like that??

Not sure what the red parts in the x264 options do exactly - I noticed your transfer and colormatrix settings differed between NTSC and PAL.

NTSC: transfer=smpte170m:colormatrix=smpte170m
PAL: transfer=bt470bg:colormatrix=bt470bg


All times are GMT -5. The time now is 07:54 AM

Site design, images and content © 2002-2022 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2022 Jelsoft Enterprises Ltd.