I found a way to remove the 24P pulldown on all the AVCHD files generated by my Canon HF11.
[
Note: the method described in this post is being superceded by the easier/faster "pu-avchd" script explained in message #158 below]
Unfortunately, one has to play each file for about 10-15 seconds to determine on which frame it starts in the 3:2 pulldown cadence. Then one moves the file into a corresponding directory, before it can be batch encoded. Eventually, these two manual steps will probably be eliminated/automated.
The below procedure works for Linux, Unix and probably OSX, as long as the versions of mencoder and ffmpeg are recent. The process is simpler than it looks.
Enjoy!
-Dale
=============
PULLDOWN REMOVAL FOR CANON 24P AVCHD FOOTAGE, USING MENCODER AND FFMPEG IN LINUX/UNIX/OSX
WHEN SHOOTING:
- Upon pressing the camera's start button, swipe your hand side-to-side in front of the lens for one second, or pan back-and-forth for one second. This movement will make it much easier to determine which frame of the 3:2 pulldown cadence starts the file (especially when the subject is standing still).
PREPARE YOUR ENCODING DIRECTORIES:
- Put all of the AVCHD files into the desired directory for your project, and, in that directory, create five sub-directories labeled "0", "1", "2", "3" and "4".
DETERMINE EACH FILE'S STARTING FRAME AND MOVE THE FILES TO THEIR CORRESPONDING DIRECTORY:
- Open a terminal, and "CD" to the directory that contains the AVCHD files.
- To play an AVCHD file one-frame-at-a-time, use the command, "mplayer -demuxer lavf -vc ffh264 your_avchd_file.mts". Press the spacebar immediately after pressing "enter" on this mplayer command, which will pause the video on the first or second frame (you can see on which frame it stops). To advance one-frame-at-a-time, press the period (".") key. This method allows you to count through the cadence and determine on which frame the video starts. Once you get the hang of this procedure, it should take about 10-15 seconds to determine the starting frame.
- Here are the five different pulldown cadence patterns ("P"=progressive frame and "I"=interlaced frame):
PPPII -- starts on frame #0
PPIIP -- starts on frame #1
PIIPP -- starts on frame #2
IIPPP -- starts on frame #3
IPPPI -- starts on frame #4
- When you determine on which frame the file's 3:2 cadence starts, move that file to the corresponding sub-directory.
- Repeat this "starting-frame-discovery" procedure on each file, until all the files are moved to their corresponding directories.
- By the way, you could put all files starting on frames #0, #1 and #2 into one directory, because they use the same pulldown removal filter. However, it is probably good to keep each type of file in a separate directory, so that you can recover easily just in case you uniformly miscount/mis-designate every file in a directory (e.g. all the files you designated to be #1 are actually #3 files).
ENCODE THE FILES:
- Get the three mffpeger scripts: mffpeger012; mffpeger3; and mffpeger4. I have put them here:
http://marks.org/avchd/mffpeger/
- In your terminal, "CD" to each subdirectory and use the corresponding mffpeger script (mffpeger012 for sub-directories "0", "1" and "2"; mffpeger3 for sub-directory "3"; and mffpeger4 for sub-directory "4").
- Because the mffpeger script is not interactive (it does not use switches/flags to change settings on the command line), it is probably best to put a copy of the script into each subdirectory and use that script, rather than running the script globally (for instance, from within /usr/local/bin). This way, changes to the settings can be made within the script, and they won't affect the script's use elsewhere. Of course, to use a script in the current directory, one merely types "./name_of_script" at the terminal prompt, and then presses "enter".
- If you continually get skipped/dropped frame errors during the mencoder stage, try using one of the other two scripts on the file. By the way, after the pulldown has been removed, there should be no duplicate frames -- you can see duplicate frames by advancing through the footage one-frame-at-a-time in mplayer.
- The mffpeger default file format is Quicktime files (.mov), to use in Final Cut Pro. If you have a Mac computer and these files don't play in Quicktime or FCP, try installing the free Perian utility:
http://perian.org/ and then try to play the footage.
TO DO:
1. Find a way to adjust the settings on one of mencoder's fancy, pulldown removal filters, so that a single script can remove the pulldown on all of the files, regardless of the starting frame.
2. Make the script interactive, so that settings (such as frame rate, pulldown removal, file paths, deinterlacing, frame rates, etc.) can be specified on the command line.
3. Explore streaming raw video during encoding. It might be faster/better to pipe a raw video stream out of mencoder and into ffmpeg, but I am not sure how to do that. I have seen scripts that pipe a raw video stream from mplayer into ffmpeg, but this method seems to necessitate that the audio be encoded/copied on a separate pass.
4. Convert the mffpeger script to work in Windows.
I could definitely use some help with these tasks. I am a novice, so it will probably take a lot of time/effort for me to find these command/script settings on my own, merely poking-around by trial-and-error.