Archive for the ‘Software’ Category (feed)

Canon AVCHD 24p Pulldown Removal

Please do not reproduce without authorization, instead just link back here.

Note: This tutorial is for AVCHD cameras, for HDV look here.

Introduction

Canon’s consumer HD cameras have 24p support, only that it’s not a… truly true 24p. It’s PF24, which incorporates both progressive and interlaced frames in a 60i stream. To get the pure 24p stream, you need to do a “pulldown removal” (aka “inverse telecine”). PAL users don’t need to do anything special, this burden is only for 24p NTSC users. If your final output is the TV (e.g. via DVD or the camcorder itself), and as long as you never de-interlace that footage, then you don’t need to remove pulldown. But if your output is not a home DVD/TV but professional work, the web, or a PC or other viewing device, then you better get to work and remove pulldown because your footage will have an ugly “ghost” effect whenever there is motion on the screen. Here are pulldown-removed images before & after, showcasing the problem and its fix. Here’s another example showing the problem.

There are several ways to remove PF24 pulldown for the Canon HDV cameras, but their AVCHD cameras (e.g. HG10, HR10) did not enjoy the same fate, until now. If you are using the latest versions of After Effects or Final Cut Pro, then you can use the tutorials linked to remove pulldown (although I have not confirmed that these tutorials will work for AVCHD formats as well). On the PC side, the cheapest, fastest and cleanest way to do it, would be to purchase the Cineform NeoHDV or NeoHD tools (discount here). However, there is another way, a freeware method, as long as you already have a video editor that supports the AVCHD format, DirectShow/VfW and 24p (e.g. Sony Vegas/VMS, AE/Premiere, Avid etc). Please note that Premiere Elements, Pinnacle, Magix Movie Edit Pro and Ulead don’t support true 24p so avoid these for 24p editing. This method is an involved procedure to follow and it requires some very basic usage of the DOS prompt (found in Windows’ Accessories program menu as “MS-DOS”), but if you have no money and you need it done, it should work fine (tested with HG10’s PF24 files).

Windows XP/2k/Vista

1. Download the plain version of Mplayer for Windows and unzip it somewhere that you can find back easily. Inside that unzipped mplayer folder, create a folder named “input”, and a folder named “output”. This action only needs to be done once for your system.

2. Download the Huffyuv lossless codec. Unzip the .zip file on your desktop, right click on the huffuyv.inf file and select “Install” (note: Vista might not give you that option, in which case manual registration of the codec’s DLL file must happen via the DOS prompt, google it). After about 15 seconds, you can delete these files from your desktop, as the Huffyuv lossless codec is now installed on your system. Open a DOS prompt and navigate to the mplayer folder (e.g. “cd C:\Mplayer\”, without the quotes). There, run this command: vfw2menc -f huff -d huffyuv.dll -s settings.mcf and on the new dialog that pops up select: “Predict median (best)” from the first drop down menu, and “<-- Convert to YUY2" from the second drop down menu, while leaving unchecked the other options. Then click "ok" to discard the Huffyuv configuration dialog. This action only needs to be done once for your system.

3. Download the Lagarith lossless codec. Unzip the .zip file on your desktop, right click on the lagarith.inf file and select “Install” (note: Vista might not give you that option, in which case manual registration of the codec’s DLL file must happen via the DOS prompt, google it). After about 15 seconds, you can delete these files from your desktop, as the Lagarith lossless codec is now installed on your system. Open a DOS prompt and navigate to the mplayer folder (if it’s not open already at that folder). There, run this command: vfw2menc -f laga -d lagarith.dll -s settings.mcf and on the new dialog that pops up select: “YUY2″ from the “Mode” menu, and “Use Multithreading” if your CPU is hyperthreaded/multi-CPU or it has more than one Core (leave unchecked if you don’t know). Then click “ok” to discard the Lagarith configuration dialog. This action only needs to be done once for your system. Note: Do not change to YUY2 if you are using Adobe’s editors, as they don’t understand that format.

4. I will work with Vegas on this step because that’s what I use, but it should be similar for Premiere/AE/Avid. Open Vegas and load your PF24 .m2ts or .mts AVCHD files in the “Project media” bin. Make sure that these files were indeed recorded as PF24 (don’t mix 60i and PF24-recorded files), and that your hard drives are formatted in NTFS. Then open the “Project Properties” dialog and use the HDV 1080/60i template from the drop down menu. Now you have two options, either pull all your scenes at once in the timeline to export, or export them one by one. The first method does not require your attendance, but it will produce one large file that will have no scene detection, while the second method will produce lots of per-scene files, but it will require that you be in front of your computer quite often to export the scenes one by one. Think hard of what your needs are, and make your choice. I would personally recommend you export the scenes one by one mostly because this way you can avoid the possibility of the audio and video getting out of sync (plus, MEncoder is known to not handle huge files too well either).

5. Once the clip(s) are on the timeline, hit “File” and “Render As”. Select .avi for the “Save as type”, and the “HDV 1080-60i intermediate” template. Then, hit “Custom”. On the first tab select “Best” quality. On the video tab leave everything as is except the video format, select there “Huffyuv v2.1.1″. Then, hit “Configure” and a new dialog pops up. There, make sure that “Predict median (best)” from the first drop down menu, and “<-- Convert to YUY2" from the second drop down menu are selected (leave unchecked the rest of the options there). Then click "ok" to take that new dialog away. Leave unchanged the "Audio" tab, and then hit "ok" in the "custom template" dialog. Then, you must give a name to your .avi file. If you chose the "one big file with no scene detection" method give it any name you want (as long as there are no spaces), but if you chose to export the scenes separately then use the same filenames as in their original AVCHD files, but with the .avi extension this time, and with no spaces in the filename. Export the files in the "input" folder you created inside the Mplayer folder.

6. After all the exporting is done, open a DOS prompt, navigate to the Mplayer folder that has the mencoder.exe file in it, and then run the following command, substituting each time the right input/output filenames with your own video filenames:
mencoder input/INPUT_FILENAME_001.avi -aspect 16:9 -fps 30000/1001 -oac pcm -vf detc,scale=1440:1080 -ofps 24000/1001 -ovc vfw -xvfwopts codec=lagarith.dll -o output/OUTPUT_FILENAME_001.avi
If you are proficient with DOS scripting, you can even write a script that will automatically read all the files on the “input” folder and export them one by one without requiring your attendance. Phoric wrote such a script and sent it to us (save it down and put it in the mplayer folder before you execute it). Thanks Phoric!

7. After MEncoder is done re-encoding all your files, you can choose to delete or move away the .m2t files on the “input” folder (so they don’t mix with video files you will place there in the future), while all the .avi files found on the “output” folder are now ready to edit! Windows Media Player won’t recognize these files as widescreen, but don’t worry, they are widescreen: Vegas will recognize them as such (if not, just set manually the clips’ aspect ratio to 1.3333). Create a new project in Vegas (or any other 24p-enabled video editor), select again the HDV 1080/60i template, but change the following this time: Field Order should be “progressive scan”, frame rate should be “23.976″ (type it if it’s not in the list), rendering quality “Best”, and de-interlacing method “none”. Then, edit as usual and enjoy true 24p!

NOTE: Trevor Marshall suggests an alternative method (not tested by me, might have an audio sync issue).

Mac OS X

1. Download, unzip and drop the MEncoder files for Mac OS X on a folder of your choice, e.g. on one that’s called “mplayer”. Create two folders in that folder, one called “input” and one called “output”. This action only needs to be done once for your system.

2. Use a Quicktime-enabled application (any will do, as long as it has access to Quicktime’s exporting dialogs) to export your AVCHD files as MJPEG/PhotoJPEG inside the “input” folder. MJPEG is not exactly a lossless codec, but it’s the only high quality near-lossless codec that comes out of Quicktime that MEncoder will support.

3. By using OSX’s Terminal.app, navigate to the mplayer folder (it requires basic understanding of Terminal usage), and then use the following MEncoder command line to remove pulldown and export in Huffyuv, like this:
./mencoder input/INPUT_FILENAME.mov -aspect 16:9 -fps 30000/1001 -oac pcm -vf detc,scale=1440:1080 -ofps 24000/1001 -ovc lavc -lavcopts vcodec=huffyuv:pred=0:format=422P:vstrict=-1:aspect=16/9 -o output/OUTPUT_FILENAME.avi
You need to manually replace the filenames for INPUT_FILENAME and OUTPUT_FILENAME for each of your files.

4. After all the encodings are done for all your files, you can safely delete the files inside the “input” folder. Your final, true 24p files to be used with editing can be found on the “output” folder.

5. Install the “Perian” utility which will enable Quicktime-enabled video editors to read and edit these created Huffyuv .avi files. This action only needs to be done once for your system.

If you are proficient with Bash scripting or AppleScript, you can write a script that will automatically read all the files on the “input” folder and export them one by one using MEncoder without requiring your attendance. If you write such a script, please send it to me to incorporate it in this tutorial and help others. Please note that iMovie and Final Cut Express don’t support true 24p editing, so if these are the only video editors you got, then either don’t bother removing pulldown, or buy a PC to do the job (it will be cheaper to buy a fast PC with 2 GB of RAM and Vegas Platinum and use that as a dedicated video station, than buying Final Cut Studio or After Effects for the Mac).

Linux

There is no way to apply this method under Linux because MEncoder crashes when you try to read an AVCHD file, while ffmpeg has a known bug in the reading of such files that results the video to export twice as long as it should. As of this writing, no Linux library or application can read AVCHD files properly.

Important Notes

1. Admittedly, this is a slow way of doing things. For 1 hour of footage, it will take between 8 and 10 hours to complete the various exports, depending on the speed of your computer. If time is money for you, buy Cineform. If not, let it run overnight. A trick you can do to speed up the various exports is to have the input and output files on different hard drives. For example, when exporting the AVCHD files in the beginning, have the AVCHD files on one drive, and export into the “input” folder of MEncoder on another drive. Then, while using MEncoder, encode the “output” files back to the first hard drive again. This can save up to an estimated 15% of time in the overall process because the hard drive’s head won’t jump like crazy back and forth to service both the input file reader and the exporting encoder, but instead each hard drive will dedicate itself to a single action.

2. You will need a lot of storage. We are talking about 180 GBs per 1 hour of footage, because there are two stages of Huffyuv/Lagarith encodings going on. After the export to the “output” folder is done, you can delete the files found on the “input” folder, in order to save some storage space. Always keep around the original AVCHD files though.

3. Editing Huffyuv or Lagarith files can be pretty slow, because their filesizes are so large. You can choose to edit them directly and be done with it, or export again in Cineform 1080/24p/progressive through Vegas/VMS’s .avi custom codec dialog, and then edit these Cineform files instead. It’s pretty fast to re-encode in Cineform, its format is fast to edit too, and because all these codecs are visually lossless you won’t see much of quality degradation after all these exports. But I leave this decision to you as to in which format you want to edit with, because exporting and re-exporting until you reach a fast codec can be nerve-wrecking.

4. Instead of exporting in Huffyuv out of your Windows video editor, you can choose to install the latest “nightly by clsid” ffdshow build and then export in the “FFv1″ lossless codec instead (you select FFdshow instead of Huffyuv in the .avi dialog and then you “configure” the FFdshow dialog to use the FFv1 422p codec). This codec creates much smaller files than Huffyuv does, but it’s twice as slow to export.

5. Vegas Platinum won’t export in full 1920×1080, so you will need this method to go around the problem and export in full 1080/24p after you edit your footage. If you are ultimately exporting for Vimeo’s glorious 720p HD web service, check my tutorials here.

The Avidemux failure

With the recent release of v2.4, Avidemux could have been one of the few apps that could support pulldown removal for PF24. I have been emailing its developers the past 6 months for over 10 times to fix two important bugs, but they ignored me. The bugs are:
1. If you use audio shifting of -222msec while you use pulldown removal filters for the video, the audio ends up being 220% longer than the video.
2. The h.264/AAC .mp4 files created by Avidemux don’t playback on Quicktime.

For the first bug, they ignored me because obviously it’s simply a hard engineering problem. They just don’t seem to want to work hard. They probably have a fucked up architecture, and they don’t want to touch it and potentially make it worse.

For the second bug, they replied “it’s Quicktime’s problem”, failing to understand that iTunes/QT has 80% of the market and it does not matter whose problem it is. If you can’t playback your videos what’s the fucking point of using Avidemux to encode them? The irony is that they could easily fix that on their end, they just don’t want to (apparently the bug is in their implementation of the MP4 container).

These open source guys really need to get a clue sometimes. I like and endorse the open source ideals for the benefit of the user, it’s just that I HATE its development model.

Vegas 8 Pro for $180

If you are new into videography but you need a more powerful video editor, check this great offer at B&H, Vegas Pro 8 for $180. You will have to buy the old Vegas 6 version and then buy the upgrade to v8, but overall, it’s just $180 instead of $600. That’s a great offer.

General computer stupidity

We are currently in Reno,NV and i only got with me the nokia n800 to use with the hotel’s wifi service. This blog post message is written with the n800 too, painfully slowly. So, while using the file manager, it automatically picked up smb connections from other users in the hotel. It didn’t ask me if i wanted to search for computers in the network, it just did it. There are a bunch of people with sharing on! I did not open their files but there were a lot of documents there that *obviously* belonged to the company that employs them (filenames). Such is the ignorance of some computer users. And this ignorance can put honest users into legal trouble, just because their device automatically connects to network shares. I hope nokia is listening and adds a checkbox preference for that feature or only search if someone hits the ’shared’ virtual folder - the same way mac and win do it.

And yes, even if these folders are shared, connecting to them it’s still considered ‘computer intrusion’ according to the law, because obviously this was not intended by these clueless users.

Nokia: over-promising, under-delivering

Nokia wrote on their feature-list of their Tablet OS2008 for the N800/N810 devices:

Supported video formats: 3GP, AVI, H.263, H.264, MP4, ASF, WMV, MPEG-1, MPEG-4, RV 7/8/9 (RealVideo)

I was shocked to find out that absolutely none of my h.264 files worked (.mov or .mp4), none of my DivX files worked, and none of my ASF & WMV8 files worked. I later tested mpeg2 (QVGA, always) and that didn’t work either. The only files that I managed to playback was 3GP, XViD, WMV9, Mpeg1 and *some* Mpeg4-SP files (not all). Given the fact that XViD and DivX are very similar, their decoder should have (or should have been made to) work with both MPEG4-ASP formats.

Last night, Sony had a firmware upgrade for their PS3 too. They promised DivX and WMV support. They both worked perfectly, and we also got XViD support and partial MPEG4-SP support for free too. If Sony was to add .mov container support for h.264, their solution is perfect for video viewing, beating even the AppleTV which was created for that reason alone.

I like the OS2008 upgrade for the rest of its features, but for video support, it sucks. It sucks less than OS2007, but it still sucks hard. Nokia needs to get their shit together. As a video person, that’s all I have to say.

Apple and filmmaker lock-in

If you start using Final Cut Studio or Pro/Express with a Mac, forget about interoperability with the PC world. There is not a single intermediate format that works out of the box between Apple’s video software products and the PC products. Apple has not made the effort to support some common intermediate .avi formats.

I put an ad on a filmmaking forum to help indie filmmakers with color grading, and we haven’t found a single lossless codec that can be read on the PC right off the bat (and that includes the PC version of Quicktime which can’t read the Apple Intermediate Codec while the Mac version can). Even the .mov uncompressed version someone sent me didn’t work (seems that the format has somewhat changed in the latest version of FCP).

There are few ways to do it: you either export in DVCProHD on the Mac and then you buy the Raylight decoder/encoder for $200 on Windows, or you buy Cineform on both platforms that costs much more than that (my personal preference would be Cineform if cost was not an issue). Another trick is to load the lossless video on the Mac version of After Effects and export again from there, but that costs another $1600 and it takes lots of time.

This would be a great opportunity for Lagarith to step in and port the codec as a Quicktime component for the Mac and part of ffmpeg on Linux. This way, the open source Lagarith codec would be truly useful and help in an area that right now is simply a no-no area. Heck, the guy who maintains that could even charge some money for it. That’s how big the need is right now.

Multicast

Video on the web has not seen it’s peak yet. And I am not talking about more people watching youtube, but about having all major TV networks streaming their line up in real time in an efficient manner. For TV on the web to take over the traditional cable/sat/aerial, multicasting is needed.

IP multicast allows to share the bandwidth needed to stream video on the web between “nodes”. Right now, if 1 million people request a specific video on a server somewhere, that video will be served 1 million times from that server. This is very expensive bandwidth-wise, and obviously more clever solutions are needed. Multicast allows to share the load with ISPs. The ISP will receive the stream and then share it in real time to the customers who request it, instead of hitting the main server over and over again. It is like a cache, but a cache that updates all the time.

We are years away before multicasting becomes common. I’d say anywhere between 5 and 8 years. In fact, 2015 sounds like a good year… The problem is that it requires the ISPs to support multicasting. I don’t think Comcast does (or that it wants to support it). Operating systems will need to be updated too, Vista has support for it, Leopard doesn’t. And the most difficult change of all: it requires new features on people’s routers/firewalls. Only few router models support “IGMP” right now, and the ones that do, are usually ridden with problems. If you are in the UK and you have the right router/ISP, then you can try BBC’s multicasting.

But eventually, the situation will straighten out. And then video on the web will be really cheap, which means that most will jump on streaming HD video right off the bat. And then it will flourish for good and cable-TV companies will go the way of the dodo.

Exporting with Avid Xpress in 720p

Special thanks to Costas Nikolakakis for sending us over his tutorial on how to de-interlace and export in 720p h.264 using Avid Xpress’ tools. As always, do not de-interlace if your footage is not interlaced, and make sure you pick the right frame rate.

From 4:3 to 16:9 with Sony Vegas

Sony Vegas offers a preset of how to transform your 4:3 footage to a 16:9 one (you use that if you shot in 4:3 but then you decide you want a widescreen DVD instead). Basically, what this preset does is butchering down your footage by removing large parts of the top and bottom of your image. Some directors don’t like that, and so sometimes they either stretch the image to fill the screen (looks unnatural), or they use vertical letterbox (”old”).

However, there is another way of doing all this, which is the average of all techniques. It involves some cropping and some stretching. This technique is used by Sharp HDTVs. Sharp calls this “smart stretch”, and having looked at a number of TVs and how they go about the problem, it is a much better solution to the completely unnatural look of let’s say, the Mitsubishi HDTVs. So, we are going to apply the trick below using Sony Vegas.

Open Sony Vegas and create a widescreen NTSC or PAL project. Click on each and every clip on your timeline, right click on them and select “Video Event Pan/Crop” and make it look like the picture below. Make sure all the icons and options are selected/unselected as in my picture. For PAL users, the “width” number should be around “900″ and the height should be “576″. After you do that, your video will have smaller letterboxing left and right.

Now, click the “track motion” icon on the left of each and every of your video tracks, and change the following for NTSC: width “790″ and height “520″. For PAL use “830″ and “650″ respectively. Make sure the “lock aspect ratio” icon is not selected in the Track Motion toolbar. Then edit as usual and at the end, export using the widescreen DVD template.

Using the suggested technique the aspect ratio is a bit off, but it’s hardly noticeable, and it allows for more visible area. Here are the results of each technique, side by side:

And another sample, showing a real person. A similar technique can be used to export 1920×1080p HD source footage for 2k cinema theaters (2048×1024), for those lucky ones that their indie film was picked up for theater release.

Proxy Editing with Sony Vegas

You know these new digirecorders (e.g. Sanyo Xacti, Aiptek HD) and digicam HD (e.g. Kodak HD) video that’s been around lately? The Mpeg4 video these devices are recording is very slow to edit on Vegas. Truth is, Vegas is not optimized for either .mov or mpeg4-SP editing — at least not yet. When editing becomes unbearably slow, you have to use what it’s called “proxy files”. Proxies are low resolution, low bitrate copies of your source footage in a format that it’s easier editable (e.g. mpeg2). When you are done editing your masterpiece using this low-res footage, you switch to your high resolution source footage, and you render out in full quality. Here’s how to do it, step by step. This workflow should be similar for other video editors too. The only weak point this proxy method has is that it doesn’t support the creation of proxy files for AVCHD, because the open source community doesn’t support AVCHD files yet, so the utilities suggested below can’t deal with such files.

1. Save your HD footage on a new folder, e.g. C:\Documents and Settings\YOUR_USERNAME\Desktop\HDVideo\Source\
Create a new folder called C:\Documents and Settings\YOUR_USERNAME\Desktop\HDVideo\Proxies\

2. Download and install SUPER (it’s a bit difficult to spot the actual download link on this guy’s messy web page, but look around — alternative download server here). Once loaded, right click on the SUPER window and select “Output File Saving Management” and instruct the application to set its exports to the C:\Documents and Settings\YOUR_USERNAME\Desktop\HDVideo\Proxies\ folder.

3. Modify SUPER to look exactly like this. The only things you might have to change is the frame rate (depending if you are on PAL or NTSC, or if you shot in 24p), and enabling de-interlacing or not depending if your source footage is interlaced or not. If you don’t know if your footage is interlaced or not, load it on Vegas’ “project media” window, select the clip, and read the status bar if it says “(none) progressive scan” or “lower/upper field first”. If it says “(none) progressive scan”, then you don’t need to de-interlace via SUPER. So, after you have it all setup, drag-n-drop your files onto SUPER, and press “encode”. Encoding in mpeg2 won’t take that long.

4. After the conversion is done, close down SUPER. Download and install the open source utility Rename-It. Load Rename-It, click its “Rename” menu option and select “Filename with Extension”. Click “Add filter” and “Search and replace”. In the “find what” input box type (without the quotes, but with the stop character) “.MPG”. In the “Replace with” input box, do not type anything (leave blank). Click “Ok”.

5. In the main Rename-It window, click “Add files”, navigate to the folder where your proxies are, and select all the .MPG files there (by click-n-dragging, or by using the SHIFT key so you can select multiple files). Now, you can see a “before” and “after” preview, e.g. “myvideo.m2t.mpg” now becomes “myvideo.m2t” (or similar, depending what your source footage’s extension is). Click “Rename Files”. When the renaming is done, close down Rename-It.

6. Open Vegas (Pro or Platinum). Load the proxy files through its “project media” tab. Open the File/”Project Properties” dialog and click its “Match Media” yellow icon. Through there, select a file from the C:\Documents and Settings\YOUR_USERNAME\Desktop\HDVideo\Source\ folder. Change the de-interlacing method to “interpolate”, and the quality to “best”. Now the project properties will reflect the properties of your original HD files. Click “ok”. Right Click on the preview window and make sure that: Simulate Device Aspect Ratio is ON, Scale Video to fit preview window is OFF, and the “Preview” quality in the preview toolbar is set on preview(”auto”). Then, edit your proxy files as usual. Save and exit Vegas.

7. Using Windows Explorer, rename your ~\Desktop\HDVideo\Proxies\ folder to ~\Desktop\HDVideo\Proxies-OLD\. Then, rename your ~\Desktop\HDVideo\Source\ folder as ~\Desktop\HDVideo\Proxies\. Open Vegas again using the edited project. It will take some time to re-read the HD versions of your footage, but the project will remain intact, and all the editing you did will be in place. Now, export in progressive mode, in high quality! That’s it!

website page counter