headspin
Regular Member
- Jun 3, 2008
- 237
- 155
I've been busy the last week or so building an app to download a set of videos of youtube, watermark, and re-upload with given title, description, etc.
Surprisingly, it's not that hard once you know what APIs to use. In case anyone else wants to try the same thing, here's how the process goes for one video (how to adapt it for several is obvious):
1) Download video: This is easy. It's just about replacing some stuff in the URL. Google "vb .net download youtube video" and you'll see just how easy this is. If you look on planet-source-code.com, some guy even posted a full working version of a youtube downloader which I copied and used.
2) Decoding FLV: ffmpeg works wonders, even under Windows. Find the version that's compiled into one 6MB exe file with no external dependencies. Again, Google "download ffmpeg.exe" and it should come up.
3) Watermarking FLV: This took me a while because ffmpeg's vhook is a pain in the a$$ to get working with cygwin. So I gave up on it and chose to use AviSynth instead. I kicked myself when I realized how easy it was to create an AVS file and dynamically modify it in runtime. And you can feed the AVS file directly to ffmpeg to convert the unwatermarked file to a watermarked video.
Note: On my machine this whole thing will only work if you encode the FLV to WMV format. MPG leaves out the sound and AVI crashes ffmpeg. I still have no idea why and I don't care since WMV works just as well.
4) Re-uploading: Use the Y0utube Data API. It's VERY straightforward to use, although you have to be careful with all the formatting requirements for the description and keyword tags (especially keywords) or you'll get some very frustrating 400 errors.
The great thing about the Y0utube Data API is that you can also use it to search for videos by keyword and order by most viewed etc, so you can automatically select which videos to download, which saves a lot of time.
.NET also makes it easy to switch between proxies , although I haven't coded this yet because there's nothing bannable about my videos (apart from the blatant copyright infringement
).
Surprisingly, it's not that hard once you know what APIs to use. In case anyone else wants to try the same thing, here's how the process goes for one video (how to adapt it for several is obvious):
1) Download video: This is easy. It's just about replacing some stuff in the URL. Google "vb .net download youtube video" and you'll see just how easy this is. If you look on planet-source-code.com, some guy even posted a full working version of a youtube downloader which I copied and used.
2) Decoding FLV: ffmpeg works wonders, even under Windows. Find the version that's compiled into one 6MB exe file with no external dependencies. Again, Google "download ffmpeg.exe" and it should come up.
3) Watermarking FLV: This took me a while because ffmpeg's vhook is a pain in the a$$ to get working with cygwin. So I gave up on it and chose to use AviSynth instead. I kicked myself when I realized how easy it was to create an AVS file and dynamically modify it in runtime. And you can feed the AVS file directly to ffmpeg to convert the unwatermarked file to a watermarked video.
Note: On my machine this whole thing will only work if you encode the FLV to WMV format. MPG leaves out the sound and AVI crashes ffmpeg. I still have no idea why and I don't care since WMV works just as well.
4) Re-uploading: Use the Y0utube Data API. It's VERY straightforward to use, although you have to be careful with all the formatting requirements for the description and keyword tags (especially keywords) or you'll get some very frustrating 400 errors.
The great thing about the Y0utube Data API is that you can also use it to search for videos by keyword and order by most viewed etc, so you can automatically select which videos to download, which saves a lot of time.
.NET also makes it easy to switch between proxies , although I haven't coded this yet because there's nothing bannable about my videos (apart from the blatant copyright infringement