Created
January 27, 2012 14:12
-
-
Save pcalcado/1688957 to your computer and use it in GitHub Desktop.
Genetic Algorithms, Videos and VBScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Posted on January 22, 2009 by admin | |
Carlo "Zed" Caputo already commented on the use of Genetic Algorithms | |
to improve the quality of the videos here on globo.com, work that | |
yields good results when searching for profiles that combine size, | |
quality and encoding time. When working with H.264 profiles we | |
discovered an interesting thing: Not all profiles played on the | |
iPhone. There was apparently no rule to generate a "universal" | |
profile, so some more "hardcore" testing procedure was required: | |
- Drag the video to iTunes and check if the same was accepted or | |
rejected by the device; a task which, when done manually, is | |
boring. How to automate this? | |
I remembered that many programs in the Windows world have a COM | |
interface that can be invoked by vbscript or C#. I had to use this | |
when I was required to use some very "exotic" testing tool and decided | |
to automate the manual steps the tool required, building something | |
like Selenium for that tool, with a tip from the book ".NET Test | |
Automation Recipes: A Problem-Solution Approach". Our friend Google | |
helped find a proof of concept to make the search for "itunes | |
vbscript" | |
ICAM, iPod, iScripted: Scripting iTunes | |
It was what I needed. | |
Set objApp = CreateObject ("iTunes.Application") | |
Wscript.Echo "Version:" & objApp.Version | |
As you can see, is very simple. There is a SDK developed by Apple to | |
work with iTunes which is very well documented and helped me a | |
lot. Now it was a matter of detecting when the video was rejected or | |
not. | |
Details aside, when faced with this kind of challenge we need to think | |
in terms of code maintenance: how to create a script that is not a | |
one-off? I decided to use the most common technologies and be as clear | |
as possible (hence vbscript, which is not THAT horrendous). | |
The integration with the genetic algorithm was done using an | |
asynchronous service whose integration was made through the | |
filesystem: just copy a file to a directory that .bat script would | |
detect it and fire up the vbscript. It took several attempts to reach | |
an acceptable stability, given that many interesting things happen | |
when you access an application via COM, especially when a device is | |
connected to the USB and you repeat the same task many times. As the | |
services were asynchronous I could parallelize tasks and, if required, | |
we could scale and test two or more devices just by writing a suitable | |
lock (so that two scripts do not try to move the same file). | |
Despite the fact that I had to do some non-canonical stuff (like using | |
ping to localhost to simulate a sleep), it was fun. | |
This strategy can be used in many things from the Windows world, there | |
are many examples for google and besides, if you want something more | |
professional just use Visual Studio and in a decent language which | |
compiles and has unit test frameworks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment