check out Tversity media server. It performs real time transcoding according to the device requesting the file. Serviio does the same I believe, and works in more environments (tversity was windows only when I started using it at home and haven't bothered to switch yet because it does a great job). Anyway; the way that it would work, would be that you'd have a library of all of the videos, format doesn't matter, and you'd make that your library for tversity. Then you'd store the urls in the database, like....'http://serverip:41952/folder/adverts/1234.swf" or whatever. When they go to that address, it will start playing for their device. I'd suggest including it in another page of course to hide the url etc but I think it would work for you.