Monday, January 19, 2009

Final Cut Pro / DV / Aspect Ratio / YouTube / DVD

A bunch of notes from my struggles with FCP related to aspect ratio and frame rate.

DV has data aspect ratio of 720x480 but with non-square pixels, so it displays at 640x480. Within FCP, DV is handled properly and circles in your footage appear perfectly round. If you "export with current settings" you get a .mov file full of native DV, the same data and quality as within FCP. However even the Quicktime player will play your video back at screen resolution of 720x480, wider than it should, and circles will appear squashed. Placing the quicktime player over the FCP viewer zoomed to 100%, the extra 80 pixels of width are clear.

Encountering a dv .mov which displayed too wide, I re-exported it in H.264, medium bandwidth, and under resolution selected "DV (4:3)". The resulting file plays in quicktime.


Re-exported file in Finder shows "720x480" in QT -> Info "720x480 (640x480)" Interestingly, the DV export shows identical resolution information, but displays at 720 screen pixels in QT. Also, the H.264 encode with square pixels is much sharper on the title frame than DV version... an effect of the square pixels?


Why does DV use non-square pixels? Presumably legacy reasons... perhaps relatedly due to eye and brain perception (eg interlacing is horizontal)

So isn't it correct, if preparing a file for computer use, to reencode to 640x480 with square pixels? Not if you can help it. True, if the file will be displayed at 640x480 on a computer monitor, then the video will unavoidably be resized. But videos are often watched zoomed fullscreen, with a display size much greater than 720. Having the full 720 columns of video data allows the fullscreen image to be sharper. And if you rezise to 640x480 square pixels, you are throwing away data, plus any reencode reduces quality. So better to keep full data as long as possible. (TODO: is it true that horizontal data in DV is extra dense, or is there some interlace-type effect which means it is actually half density?)

How to make sure your files play correctly? Need to have file data set so that player can know the difference between data aspect ratio and screen aspect ratio. Player needs to honor the flag. Therefore you are at the mercy of the player. However HDV footage is often (always?) stored in a distorted aspect ratio, and most players coorectly play HDV footage (is in a friendly format) so is this too much to expect?

INTERLACING

Interlacing refers to the process of transmitting video frame 1/2 at a time, odd-numered rows alternated with even-numbered rows. De-interlacing is the process of generating progressive (non-interlaced, complete) frames from interlaced data. A read of the most excellent site http://100fps.com/ show how complex this one aspect of video can actually be, and the examples at the top of the page will convince you of the importance of getting interlacing right.


DV is commonly (always?) interlaced. FCP does a good job of de-interlacing within the app, but you have to be careful on export.




EXPORTING FOR YOUTUBE

YouTube now exhorts their users to leave files at highest resolution and quality, as long as they fit within the 1GB limit. They remind users that every re-encode reduces quality, and even suggest leaving footage direct from HD cam untouched if possible. So if your DV export from FCP is under 1GB, of course you should upload it... right? Why re-encode?

However a late 2008 post in the forums, user epontius claims that YouTube will not handle non-square pixels correctly, and that it will do a low-quality job shrinking the video for standard size YouTube player.

http://help.youtube.com/group/youtube-howto/browse_thread/thread/1ba7424dff529a23/7f3e3e7604343193?hide_quotes=no

Hard to believe in the HD era that one should reduce resolution, and it flies in the face of YouTube's statements... but nonetheless I am concerned and can't find confirmation that SD DV is handled correctly.

Here lezro44 describes his process of reimporting dv codec video into a new FCP project to change to square pixels, then exporting from there.

http://help.youtube.com/group/youtube-howto/browse_thread/thread/84ba6bd4a3ce98a9?fwc=1

Try: export from FCP with "current settings" but manual override of aspect ratio to produce DV that QT displays correctly?: Export -> Use: Current Settings -> change to Custom... -> change Aspect Ratio from "NTSC DV 3:2" to "NTSC 4:3", Pixel Aspect Ration to Square, QuickTime Movie Settings -> Advanced -> Scan -> Progressive In the other tab I set Motion Effects quality to Best. TODO: left field dominance as "Even"... good?

Note: it takes twice as long to export as "current settings"

Results: The title is not as sharp as h.264 reencode (in fact i think it is just as bad as direct dv export, except tighted 10% horizontally) but deinterlacing is great, none of the jaggies visible in the native export. Nature of compression is different, I can sense it is more square. Seems like a good candidate for reencode for web. TODO: encode to h.264 and compare sharpness etc to the encode from interlace.

Try: further attempts to convert from progressive, square dv

Results: still interlaced!

Try: "quicktime conversion" to h.264 and mp4 at highest quality, under video -> settings -> size check the "deinterlace source" box *even though source is not interlaced!*

Results: non-interlaced output! however, one bit of footage in my project had "problematic" interlacing with a missing row near the bottom. In FCP and exported progressive DV the artifact had disappeared... but now it is back again in encodes!

Try: MPEG Streamclip, export to mp4, h.264 encoder full quality, FIELD DOMINANCE LOWER, deselect the interlace options as dialogue suggests.

Result: non-interlaced, but problem footage scanline reappears!!

Try: add de-interlace filter to problem line video within FCP (TODO: details). Also add desaturate just so I can be sure everything is re-rendered.

NOTE: can't find the contrast / black level filters I added to clean up line footage! Seq embed problem.

Result: 640 prog export looks great - but it always does.

Try: new prog 640 clip -> quicktime player -> file -> export -> movie to quicktime movie -> options... -> video settings -> highest bitrate. movie settings -> size -> check the "deinterlace source" box *even though source is not interlaced!*

Result: looks like it worked, no interlacing and no artifacts in line feed.

Try: exporting according to dvcreators guide (above) EXCEPT - current size showed <640 !?! so override to VGA.

Result: dvcreators version indeed looks sharper on title frame, but bassbot footage is all re-interlaced! Gaaah!


EXPORTING FOR DVD

NOTE: FCP -> DVD Studio toolchain works well, so export "current settings" dv .mov to use for DVD use, and use the progressive square version for computer formats. TODO: isn't a progressive scan DVD better? research.

Here is a guide for simple FCP->DVDSP workflow that doesn't address progressive video. http://fcproducer.com/2007/04/make-a-final-cut-pro-movie-into-mpeg-2-for-dvd-studio-pro/

An HD->SD workflow http://www.produxion.net/tag/final-cut-pro/

Suggests compressing to progressive mpg2 to get a DVD that looks good on computer and TV. Seems to be the same process as I do, how does it work for this guy? http://www.geniusdv.com/weblog/archives/a_fix_for_chopiness_in_dvd_video.php

User **DONOTDELETE** claims high-end players often screw up 30p (29.97p?) http://www.2-popforums.com/forums/showthread.php?t=51948

This guide to handling film footage is well-written and touches on related issues http://www.lafcpug.org/Tutorials/basic_video_to_film.html

dvdcreators.net suggests exporting to png frames for best quality - but isn't this just a high-bandwidth version of the indentical output you get from DV render? Or does a DV export with any editing or filters actually introduce a re-compression? Makes sense that edit export is re-compressed, although many people recommend "export with current settings" as "no video loss" - but if it compressed to DV there is a slight loss they might not detect... rendering motion / deinterlace / aspect ratio / square pixels to a lossless format would seem to avoid a reencode. http://www.dvcreators.net/how-do-i-export-a-high-quality-movie/ somewhere they have a thumbnail comparison of the soft text from default output vs the sharp text of their method.

TODO: Wikipedia says mpeg2 allows 720 but not 640... so I shouldn't convert from 640 export then? http://en.wikipedia.org/wiki/MPEG-2


There are two opinions about interlacing re: FCP and DVDSP

1) Don't ever de-interlace, let the interlace continue through the workflow, produce an interlaced DVD, it will look fine on TV's

2) De-interlace at some point in the process, produce a progressive DVD

Old displays relied on interlacing. DV footage comes interlaced from the camera. Computer displays are progressive. DVD's can include either interlaced or progressive video. Interlaced video can be de-interlaced at time of playback *if your player supports it*. Reportedly new versions of the OSX DVD Player include deinterlacing so that interlaced DVDs appear smooth. The big issues are the quality of the deinterlace (depending what step executes it) and requirements from hardware. De-interlacing is a tricky problem, if trying to keep the best possible time and visual resolution. 1000fps site details many approaches. Some hardware has fantastic deinterlace abilities, beyond what the FCP toolchain offers, when outputing to a progressive display. Other hardware will display lots of interlace jaggies.

However I am with group 2) because all hardware is capable of re-interlacing the video if necessary for display - and unlike de-interlacing, interlacing has one correct answer (ignoring field order etc) and there is no voodoo to achieve better results. Therefore it is better to do the best possible deinterlacing during production - there may be a handful of systems which could have done a better job during playback, but you demolish the worst-case scenario. More and more people view DVD on progressive displays and the commercial DVD market sells progressive scan as a feature, so it is past the time of producing interlaced DVD's.

The question becomes where in the toolchain to deinterlace. You can

1) de-interlace option in DVD Studio Pro

2) export to progressive scan DV file, import to DVDSP

3) apply builtin or 3rd party deinterlace filter to your final FCP sequence before exporting it

I opted to try 2 - my project and sequences are all interlaced, but when exporting I changed the settings to progressive. I actually tried this method because it is invisible... no de-interlace settings to tweak, no changes to my FCP project, just part of the output process. It seems like it should be "correct" based on what it knows of DV. If the results are good I won't have to worry about any details or test with various deinterlace settings.

There is also the question of whether to mpeg compress FCP output or let DVDSP do it on import. I prefer compess on export, just to be able to crank up the bitrate for short videos and also to avoid the encoding hit if I use the clip in more than one DVD or rebuild DVD from scratch.

Try: Export -> Custom settings -> (ntsc dv 2:3, dv pixel ratio) advanced -> progressive, 4:3

Notes: fast export

Results: title is soft as native, QT displays it extra wide (TODO: need to specify 4:3 at export?) Perfectly progressive, looks good other than squashedness. Remains to be seen if ratio comes out correct on DVD.

Try: Compressor on "for dvd", best for 90 min, field dominance: progressive, 4:3

Results: output is mega-interlaced despite selecting "progressive" from popup... is is possible selecting "progressive" caused a double process and re-interlacing? Guess I have to try without forcing progressive and compare.

Try: Still believe in the progressive export. Try compressor with "90 min best" no funky options.

Result: m2v is still interlaced.



Try: Interlaced output into Compressor with "field dominance" -> progressive.

NOTE: FCP and DVDSP are all part of FCSP, could well be using identical de-interlacing.



A BUNCH OF TESTS with the goal of a nice progressive output for use on web etc

(all of this is with an extra de-interlace in the troublesome line footage)

set up a four-second clip

from progressive sequence:

1) export quicktime, custom, 720 NTSC DV 3:2, CCIR601 PAR, no field dominance, advanced -> progressive 4:3

2) export quicktime, custom, 640 NTSC DV 4:3, square PAR, no field dominance, advanced -> progressive 4:3

3) export -> quicktime conversion -> setting -> png non-interlaced <- -> size 640 VGA, don't de-interlace

1 and 2 titles are soft and pixellated but all footage is clean. 1 is extra wide. 3 is interlaced all footage (except line video?) The interlacing seems more extreme and clean that usual, as if PNG output was being interlaced despite my settings.


from standard dv interlaced sequence:

1) export quicktime, custom, 720 NTSC DV 3:2, CCIR601 PAR, no field dominance, advanced -> progressive 4:3 (no deinterlace option, trust FCP to know how to handle)

2) export quicktime, custom, 640 NTSC DV 4:3, square PAR, no field dominance, advanced -> progressive 4:3 (ditto above)

3) export -> quicktime conversion -> setting -> png non-interlaced <- -> size 640 VGA, do de-interlace source video

2 titles are mungy and hair seems less precise as if subject to same munging TODO: compare hair resolution with best result for deficiencies. 3 titles are sharp but video is interlaced to hell, as above super sharp.

4) like 3 but skip deinterlace of source

still interlaced output, can't detect any clear difference to 3

5) interlaced png without deinterlacing source

result: same

6) interlaced png, deinterlace source

result: same

7) export -> quicktime -> 640 NTSC 4:3 square, qv compressor = uncompressed 8 bit

result: same interlace problem!

NOTE: can set PNG compressor here - save size only?

8) prog png, deinterlace source, swap fields TODO: deinterlace as filter to control order?

9) above without deinterlace source

created "output filter test" interlaced seq and drag 4 sec interlaced seq into it. right-click, show in viewer, video filters -> video -> shift fields

1) 8 bit uncompressed (aka test 7 above)

result same as above - interlaced output file



A BUNCH OF TESTS with the goal of a clean progressive output. because it is intended for DVD I leave it 720.


Q: export quicktime "field dominance" to set output or needs to match sequence? is it ignored when "progressive" is set under "advanced"?

NOTE: seems true that NTSC DVD is NTSC meaning PAR is non-square.

Q: to preserve best data/time res wouldn't it be better to leave interlaced even for a computer display? or at least to 60fps half-height video?

NOTE: de-interlacing often means throwing away the odd/even frames, which softens the image because half the vertical info is discarded!

TIP: option-double click on item in browser to open it in its own viewer window

NOTE: changing length of nested sequence will change length within parent sequence, and ripple and time changes to prevent gaps/overlaps. But this only happens if you nested the whole sequence *without in/out points set* or set the length of nested seq within parent seq. Does this mean i can spoil it by fucking with in/out point??? dangerous!

NOTE: all rendered frames are written to disk even if render is cancelled.

PROGRESSIVE DVD:

edited sequence interlaced. made a 720 ntsc 3:2 dv progressive seq, nest my edit seq in it. add deinterlace filter to nested clip. verify with canvas at 100% that it is progressive. add titles. export to quicktime movie

general tab: 720 3:2 ntsc dv, ntsc PAR, field dominance none, uncompressed 8-bit
processing tab: high precision YUV, superwhite, best motion quality

note: 10-bit is an option, but some filters don't support it, and the source is 8-bit anyway, and i don't have subtle gradients.

note: superwhite because benton said so. this preserves details in the whites (prevent brightness clipping) but makes everything ~8% darker. except.. this supposedly only involves RGB material and I don't have any so... no need to worry.

export to .mov, import to dvdsp. settings -> best 90 min all. delete one of the audios. click on mpeg setting and poke around inspector. in GOP tab set the GOP size as short as possible, maximize i-frames - eg IBBP 7

Q: what about mpeg2 encoding at one-pass CBR set to 8M+ since my project is very short? multi-pass only helps with VBR data allocation (http://www.afterdawn.com/glossary/terms/multipass.cfm) so for short projects forcing max bitrate is best.

video bitrate: "Maximum video bit rate is 9.8 Mbps" (by which he seems to mean V+A) "LPCM is fixed at 1536_Kbps" = 8.2 Mbps for video but round down to 8.0 because people tend to.

MARKERS: FCP manual says that FCP will automatically insert compression markers at edits, but that certainly doesn't work with edit nested in title/export sequence. need to test edit sequence export to see if markers even works there.

DVD encode: could I force all iframes at 8.0M, would that look OK, is it legal? accomplish this with a compression marker at every frame?

Make a new setting based on "DVD 90 min best", change to progressive CBR 8Mbps, GOP IP closed 6 IPPPPP. Save as "DVD Best".

TIP: option-\ to play one frame at a time, not real-time but slo-mo preview. useful if you can't play full quality real time

compression frames tell encoder to put a full mpeg frame just after each edit, to avoid artifacts due to difference-frames across edits. but you have to be careful to preserve them all the way to the encoder. how to preserve to compressor? can i automatically add at every edit point? FCP knows...

how do compression markers interact with nesting?

FCP docs say it adds compression markers automatically at edit point (if exporting with correct settings) but does this work in nested sequences? manual doesn't say.

can I do mpeg with all i-frames for a 5-minute dvd? does that exceed max bitrate without throttling frame quality?

Q: can i examine a .mov text track to determine which markers are present? can i look at file size difference between export 1 and export 2 files to determine if markers are present?

NOTE: on liberty dvd export final 1, zoom-in at beginning of liberty looks all interlaced!!! does this prove that i need de-interlaced sequences and fix each source asap? but it doesn't happen once the song starts even tho we are still zoomed in... only under title?

TODO: record timestamped midi performace. could have used for liberty fx to match visuals.



http://dvd-hq.info/bitrate_calculator.php


Strategy: split fields to convert 60i to 60p - same quality loss but twice the data and time detail. can convert first and edit in 60p. need to convert back to 30p or 60i at the end, which means that we'll end up throwing half away. but could make a 60fps file for computer viewing. do HDTV's deinterlace to 60p? Hey... can take my interlaced edit, export a copy to interlaced uncompressed, split fields, reimport and title in a 60p sequence. Use that source for high-speed

NESTING:
http://www.kenstone.net/fcp_homepage/basic_nest.html
also see FCP manual "sequence to sequence editing"

No comments: