Saturday, March 24, 2012

Windows CMD string concatenation

To update a variable in a for loop in Windows batch script we need to call subroutines. Here is an example script that concatenates all .txt filenames to a variable using Windows CMD.


@echo off
rem List and concatenate all .txt filenames to a variable
set files=
for /f %%F in ('dir /B *.txt') do call :concat %%F
echo %files%
goto :eof


:concat
set files=%files% %1
goto :eof

See more at: http://ss64.com/nt/ and http://stackoverflow.com/questions/2027070/batch-file-string-concatenation

Friday, March 09, 2012

Videolectures.net RTMP streaming URL


Videolectures.net is a great website that provides videos and slides of several lectures and talks. Due to some technical reasons, they have not provided links to download their videos yet. If you want to download the video, you will need to get the streaming URL yourself. Here is how.

Videolectures.net uses Flowplayer to stream video using RTMP protocol. The streaming URL of a video on their website comprises of three parts:
Streaming URL = clip.netConnectionUrl + sub_folder + clip.url
where
sub_folder is the folder that contains the lecture page.
clip.url is the relative URL to the video.
clip.netConnectionUrl is the base URL pointing to the RTMP streaming server.

You can easily find out sub_folder in the URL of the webpage that contains the lecture you are viewing. You can look for the value of clip.url and clip.netConnectionUrl in the source code of the webpage.

For example, suppose you are browsing for the lecture at http://videolectures.net/cvpr2010_ecker_psfs/. Then we have:
sub_folder : cvpr2010_ecker_psfs
clip.url   : flv:v001/bb/xo3o537fdbo7kpfidhxsfu6ecc5rn2rj
clip.netConnectionUrl : rtmp://oxy.videolectures.net/video

Concatenating the above strings, the RTMP streaming URL is
rtmp://oxy.videolectures.net/video/cvpr2010_ecker_psfs/flv:v001/bb/xo3o537fdbo7kpfidhxsfu6ecc5rn2rj/

You can now use ffmpeg or VLC to stream and save the video to your PC. For example, simply try
ffmpeg -i <input URL> <output file>