Video has seen a massive surgance on the internet with the launch of YouTube and other video sharing web sites. This raises some interesting challenges beyond simple scripting in VuGen; with a combination of Javascript, Adobe Flash and HTTP partial download support.

This article will show you how to play a video, and save it to your hard drive.

Okay, first step. Old style web video basically streams web video to the user on a “best-effort” basis…this sort of video can be recorded using the Media Player (MMS) protocol in VuGen. However Flash Video is comprised of an embedded flash SWF file which downloads a FLV video file over standard HTTP.

The steps within this example script for this tech tip are:

  1. Go to the video page (e.g.—aiyznGQ)
  2. Play the Video. Capturing the FLV file to your local disk.

For obvious reasons, we are removing any advertisting requests. The aim is to capture the YouTube video and save it to the local hard drive.

Getting Started
The first step is to create a new script using the standard Web (HTTP/HTML) protocol. After doing that, add the following three lines to your script.

web_set_timeout("RECEIVE", "300");
web_set_timeout("STEP", "300");

These lines increase the parameter length limit to 50MB (for storing our video data), and increase the download timeout to 5 minutes (you may need to increase this further if you’re running on a slow connection.

The next step is to navigate to the Video. I’ve included the famous “Keyboard Cat” video, but I suggest that you parameterize this and navigate to any YouTube video.

web_reg_save_param("videoid", "LB=\"video_id\": \"", "RB=\"", "Ord=1", LAST);
web_reg_save_param("t", "LB=\"t\": \"", "RB=%3D\"", "Ord=1", LAST);
web_reg_save_param("fmt", "LB=fmt_url_map\": \"", "RB=%7", "Ord=1", LAST);
web_reg_save_param("swfplayer", "LB=canPlayV9Swf() ? \"", "RB=.swf", "Ord=1", "NotFound=Error", LAST);
web_reg_save_param("playbackhost", "LB=%7Chttp%3A%2F%2F", "RB=%", "Ord=1", "NotFound=Error", LAST);
web_reg_save_param("itag", "LB=itag%3D", "RB=%", "Ord=1", "NotFound=Error", LAST);
web_reg_save_param("ipbits", "LB=ipbits%3D", "RB=%", "Ord=1", "NotFound=Error", LAST);
web_reg_save_param("signature", "LB=signature%3D", "RB=%", "Ord=1", "NotFound=Error", LAST);
web_reg_save_param("sver", "LB=sver%3D", "RB=%", "Ord=1", "NotFound=Error", LAST);
web_reg_save_param("expire", "LB=expire%3D", "RB=%", "Ord=1", "NotFound=Error", LAST);
web_reg_save_param("key", "LB=key%3D", "RB=%", "Ord=1", "NotFound=Error", LAST);
web_reg_save_param("factor", "LB=factor%3D", "RB=%", "Ord=1", "NotFound=Error", LAST);
web_reg_save_param("burst", "LB=burst%3D", "RB=%", "Ord=1", "NotFound=Error", LAST);
web_reg_save_param("id", "LB=%26id%3D", "RB=%", "Ord=1", "NotFound=Error", LAST);


Next we download the Flash player file and send a get_video request. The get_video request doesn’t actually return any content, but is part of how YouTube operates.



The last step is to download the FLV file.
We use the code snippet from to save the downloaded FLV to our local disk.

web_add_header("x-flash-version", "10,0,32,18");
web_add_header("UA-CPU", "x86");

web_reg_save_param("FLVContents", "LB=", "RB=", "Search=Body", LAST);

size = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
jds_save_file(lr_eval_string("Keyboard Cat.flv"), lr_eval_string("{FLVContents}"), size);

That’s it !!!!

Just a word of caution. I don’t provide this script with the intention that you actually run Load Tests against YouTube…that would be a very bad idea. This is technical example for interest purposes only.


Hi Anees,

Yes, I suspect that scripting a website such as YouTube is subject to frequent updates that will probably break scripts.

This article was intended as a technical example, although I’ll try to update it shortly to reflect any site changes.


I tried to run this script, but NOT getting the parameter value for “swfplayer” the LB value: canPlayV9Swf() ? ” is not present the replay log.

Maybe the youtube website has been updated