Forum Archive Home -> Editing -> mass deshaker script
mass deshaker script | ||
| takbal posted 2009 Oct 15 13:36 | ||
| Mass Deshaker script v1.0
------------------------------ Download it from here: mass_deshaker1.0.zip PROBLEM: HD camcorders became widespread recently. However, as probably all owners of these cameras have already realized, viewing HD footage shot without a tripod is at least tiresome or dizzying in the extreme because of the shaking. The increased detail magnifies the negative effect of tremors in hand shake, camera movement and zoom. Until manufacturers improve their hardware stabilization up to a point where shaking is not an issue anymore (which I hardly believe anytime will come) post-processing the footage may help. Recently I reviewed available deshaking software solutions I could find, plugins to NLEs, standalone tools, and I found that far best is Gunnar Thalin's free (but not open source) Deshaker plugin to VirtualDub. Check what it is capable of on youtube. The problem with Deshaker that it is quite hard to use. One need to setup VirtualDub for its two phases for each clip, the parameters are not trivial, and it also introduces an audio shift when using future frames for filling up the missing borders. It is beyond the reach of people who can use their favourite NLE, but do not have experience with VirtualDub and advanced video editing, and it is definitely hard to mass-deshake a series of footage with it. SOLUTION: I wrote a simple shell script which I use to mass-deshake HD video footage with Deshaker for further video processing in an NLE. Installation is a bit complicated, but after that it is just moving files into directories and clicking on deshake.bat. Practically I filter all my HD shots through it. As I want to edit the clips later, the output is generated with the Lagarith lossless codec to minimize recompression artifacts. I found Lagarith to be the best for this purpose (and it is also free to use). WHAT DO YOU NEED? Thats the bad news: you will need lots of things for it to work. 1. First of all, patience and a computer which is powerful enough. Deshaking an average footage of 5-10GB can take 1-3 days to finish in my i7 920 2.66GHz. I prefer running through nights, but VirtualDub runs with low priority, one core and minimized, so it is fine to do other things while deshaking runs in the background. 2. Plenty of HDD space. Lagarith is a lossless codec and the output can be huge in size. As a rule of thumb my 13Mbps Panasonic AVCHD videos will grow to 20x the size, so you need about 200-300GB of free space for the above mentioned "average" shot. Playing back these clips smoothly is hard because of their size, so I recommend using an NLE which can use proxy files (like VideoStudio or Vegas with the ProxyStream script). 3. Input format: the script uses avisynth's DirectShowSource() function to import the source material, so you should check that you are able to play your clips through DirectShow. In general, if you are able to play the clip in Windows Media Player you should be able to process it. Containers or file extensions do not matter, it works with .mts, .m2ts, .avi, .mpg or whatever mix you have. 4. You need to install: a/ VirtualDub: http://www.virtualdub.org/ I am using 1.8.8 build 30091. Should work with other versions, too. b/ cygwin: http://www.cygwin.com/ I used unix shell scripting as my windows scripting knowledge is even more inferior to the unix one. During setup find the package called 'bc', its in the 'Math' subsection and install it. You should have bash, sed and bc at least. Cygwin's bin/ directory must be in the system PATH variable. c/ avisynth: http://avisynth.org/mediawiki/Main_Page 2.5.8 is tested. d/ Gunnar's SmoothDeinterlace plugin, ported by Xesdeeni for avisynth: http://www.guthspot.se/video/AVSPorts/SmoothDeinterlacer/ I use it for deinterlacing if necessary. Copy SmoothDeinterlacer.dll into AviSynth's plugin directory (Program Files\AviSynth 2.5\plugins). e/ Lagarith lossless codec: http://lags.leetcode.net/codec.html f/ and of course Deshaker: http://www.guthspot.se/video/deshaker.htm Tested with 2.4. Copy deshaker.vdf into VirtualDub's plugin directory. WHAT DOES IT DO? The script works on the files put in the source/* directories. Each file is deshaked with a Deshaker setting depending on the directory. The results are generated in the clips/ directory in .avi, and finished clips are moved into the finished/ directory. You can interrupt the script anytime and restart it to finish the processing later, it will continue from where it was stopped. Clips are processed in 3 phases: the first two run Deshaker on the (optionally de-interlaced) clips, and the audio is delayed to match the video according to the fps of the shot. The third pass removes the first 30 frames added by Deshaker, and optionally rescales the video and trims the beginning and the end if necessary (I added this due to a Sony camcorder for which some reason playback missed 1 sec of audio from the end of each clip). Script parameters (all are optional): deshake.sh -p -x integer -y integer -d directory -b integer -e integer -p: do not perform de-interlacing (for example you are having progressive material like 1080p/24). -x, -y: output x and y size of the video (integers, default is 1920, 1080). Output is resized and the aspect ratio is changed. -d: directory of VirtualDub.exe in cygwin format (/cygdrive/drive_letter/dir, use \ to escape whitespaces). Default is /cygdrive/c/Program Files/VirtualDub or /cygdrive/c/Program Files (x86)/VirtualDub. -b, -e: additional msecs to trim from the beginning and the end of each clip (default is 0, 0). You can edit these options in deshaker.bat. You can also create a shortcut to the batch file. DESHAKER SETTINGS AND GUIDE: There are 4 basic settings: 1. no_deshake: it simply converts the clips to the overall output format (using the size, trimming and deinterlacing parameters with Lagarith). It is included to simplify the workflow if you wish to work on the same format for all clips later. 2. blend: Large borders, "soft borders" option turned on. *RECOMMENDATION: I use it if there is movement in the edge of the take. 3. sharp: Large borders, "soft borders" option turned off. *RECOMMENDATION: I use it if the edge of the shot is static, that is, there is no movement which crosses the edge. 4. zoom: Zoom in to remove borders. *RECOMMENDATION: I use it if the subject is well constrained to the middle of the shot, like a bird walking in the grass, and the shot is not hurt by cropping the edge. All of these (except the no_deshake) come in two flavors: "weak" and "strong". - *RECOMMENDATION: I use "weak" if the camera is moving in the scene (e.g. panning), and the background is not steady. - *RECOMMENDATION: I use "strong" when I judge that the background should be absolutely steady. Probably even the weak setting will be too strong for many people, but thats how I like it. It is also a matter of taste, but I prefer having blended edges to a change in the composition by zooming in and loosing information in the screen edge, so 80% of my shots go into the blend_weak folder. But it is up to you. You can change the parameters in the .vcf files. CREDITS, LEGAL AND DISCLAIMER: You are free to modify this script whatever way you like, but if you distribute it please mention me. Thanks to Gunnar Thalin for the amazing deshaker and the de-interlace plugin. The script is provided as is, no guarantees. It is moving around files, it is deleting files, so it can be potentially harmful, although I had no problems so far. So use it carefully and keep copies of your source somewhere else. I am not a unix script expert, so it is probably lame in many places. You can send improvements or comments to the PM here or to the mail address in the README.txt. Thanks! | ||
| creamyhorror posted 2009 Oct 16 05:19 | ||
| Great stuff, thanks for creating this and putting such a comprehensive post up. I'll definitely look into this when I need to do mass deshaking. | ||
| MJ Peg posted 2009 Oct 16 05:45 | ||
| Sounds interesting, but I'll stick to my simple version thanks :)
http://forums.virtualdub.org/index.php?act=ST&f=5&t=17772 ... 28&hl= | ||
| mrowkapj posted 2009 Oct 29 11:24 | ||
| Hello,
I did exactly what you advised and I ended up with the following error: ./deshake.sh: line 170: bc: command not found Avi file is not finished and can be found in temp folder while it should go to finished/ directory. Any idea what is wrong? | ||
| zoobie posted 2009 Oct 29 19:25 | ||
| I used Gunnar's Deshaker...It's pretty good when you figure out the settings.
However, using deshakers is like a doctor mindlessly writing prescriptions rather than telling you how to prevent illness in the first place. I remember reading up on HD technique years ago...The first thing it mentioned is how important it was to use a tripod. Fortunately, this was already second nature to me yet still an inconvenient truth to rank amateurs. When it comes to shooting, it's like separating the men from the boys. I find myself carrying a 50 pound tripod with a little 1 pound camera attached. What you may want to do is simplify rather than complicate. | ||
| MJ Peg posted 2009 Oct 30 05:34 | ||
| I agree that if you set out to film something then it's really showing a lack of commitment to not use a tripod.
But, sometimes we just don't want to carry a tripod. Not all filming sorties are pre planned. Sometimes we just take a camera just in case, and make do with whatever support is available. Sometimes we have footage that is perfectly usable once deshaken.... so why not? | ||
| takbal posted 2009 Oct 30 21:38 | ||
| Sorry, it looks like bc was not in cygwin's default, I added it later. I have modified the text of the initial post.
You should run the cygwin install again (it is not necessary to remove anything), and find the package called 'bc: the GNU numeric processing language and reverse polish calculator' in the list under the 'Math' section and click on it until you see 'Install', then continue with the installation. Also make sure that you have the "Unix/binary" set as the default text file type.
| ||
| takbal posted 2009 Oct 30 22:21 | ||
| If you believe carrying around a 50 pound tripod is simplifying, then let me stay the pitiful amateur I am... :D Home video is not low-cost movie making. It never was.
Btw tripods are for sissies. The really dedicated guys lay tracks for the camera dolly. :P | ||
| zoobie posted 2009 Oct 31 02:51 | ||
sure man...no problem :lol: |
Login/Register to our forum to be able to post here.
