Provide state-of-the-art image capture, screen capture, video capture and audio capture software
Home     Download     Purchase     Support     Contact     View my shopping cart
You are here: ACASystems » ACA WebThumb ActiveX Control » FAQ » Convert YouTube video webpage to image

How to convert YouTube Flash video webpage to image

If you are a developer and looking for a solution to convert web page to image in your desktop program or web application, ACA WebThumb ActiveX may be one of the best choice for you. It help you covnert web page to image With a few function calls, It can be used with many programming languages and popular server side script languages like Visual C++, Visual Basic, Delphi, C#, Java, PHP, ASP, Perl etc..

Some developers may want to convert YouTube video page to image in there applications. However, the YouTube webpage includes the JavaScript and Flash elements. when the webpage document has been completed, the Flash is still loading. If you take screenshot at this time, the video area is black, like following:

Convert YouTube video webpage to image: black video screen

* From: http://www.youtube.com/watch?v=4Ifma_3ZB24

How to solve this problem? There is a fuction: SetDelayTime.

SetDelayTime

Specifies the delay time value for StartSnap function, in milliseconds.

  • Syntax
  • void SetDelayTime(
      long pi_lDelayTime
      );
    
  • Parameters
  • pi_lDelayTime

      [in] A long integer that specifies the delay time in milliseconds.
  • Remarks
  • The default delay time value is zero.

Call SetDelayTime() to specify the delay time value for loading the Flash video, in milliseconds. You should call this function before calling StartSnap(). The correct converted image:

Convert YouTube video webpage to image: including flash video screen

Free Trial ACA WebThumb ActiveX Now

Example code: Convert YouTube video webpage to image

1. Java Codes: Convert YouTube video webpage to image

JNIEXPORT void JNICALL 
Java_Snap_Start(JNIEnv *pEnv, jobject, jstring pi_strUrl, jstring pi_strFileName)
{
  CoInitialize(NULL);
  _bstr_t t_strUrl = pEnv->GetStringUTFChars(pi_strUrl, 0);
  _bstr_t t_strFileName = pEnv->GetStringUTFChars(pi_strFileName, 0);	
  IThumbMakerPtr HTML_Converter = NULL;
  HRESULT hr = HTML_Converter.CreateInstance(L"ACAWebThumb.ThumbMaker");	
  if (SUCCEEDED(hr))
  { 
    HTML_Converter->SetURL(t_strUrl);

    HTML_Converter->SetActiveXEnabled(TRUE); // Enablue ActiveX
    HTML_Converter->SetJavaEnabled(TRUE); // Enablue Javascript
    HTML_Converter->SetJScriptEnabled(TRUE); // Enablue Java
    // Set the delay time value for loading the Flash video, in milliseconds
    HTML_Converter->SetDelayTime(5000); 

    if ( 0 == HTML_Converter->StartSnap() )
      HTML_Converter->SaveImage(t_strFileName);
  }
  if (HTML_Converter)
    HTML_Converter.Release();

  CoUninitialize();    	  	
}

Note: You can find this Java sample project in the folder {Install-folder}/sample/java/SnapYouTube.java. Launch build_youtube.bat to compile and run it.

2. PHP codes: Convert YouTube video webpage to image

<?
  // This script shows how to convert the YouTube video webpage to a PNG image file using PHP.
  $WebThumb_Maker = new COM('ACAWebThumb.ThumbMaker')
    or die("Start ACAWebThumb.ThumbMakerfailed");

  $WebThumb_Maker->SetURL("http://www.youtube.com/watch?v=4Ifma_3ZB24"); // Set URL
  $WebThumb_Maker->SetActiveXEnabled(TRUE); // Enablue ActiveX
  $WebThumb_Maker->SetJavaEnabled(TRUE); // Enablue Java applet
  $WebThumb_Maker->SetJScriptEnabled(TRUE); // Enablue Java
  // Set the delay time value for loading the Flash video, in milliseconds
  $WebThumb_Maker->SetDelayTime(5000); 
  // Take snapshot successful, save the image as a PNG file.
  if ( 0 == $WebThumb_Maker->StartSnap() )
    $WebThumb_Maker->SaveImage("youtube.png"); 
?>

3. ASP Codes: Convert YouTube video webpage to image

<%
  ' This ASP script shows how to convert YouTube video page to image.

  ' Create instance ACAWebThumb.ThumbMaker
  set WebPage_Snapor = server.createobject("ACAWebThumb.ThumbMaker")

  WebPage_Snapor.SetURL("http://www.youtube.com/watch?v=4Ifma_3ZB24") ' Set URL
  WebPage_Snapor.SetActiveXEnabled(True) ' Enablue ActiveX
  WebPage_Snapor.SetJavaEnabled(True) ' Enablue Java applet
  WebPage_Snapor.SetJScriptEnabled(True) ' Enablue Java
  ' Set the delay time value for loading the Flash video, in milliseconds
  WebPage_Snapor.SetDelayTime(5000) 
 
  WebPage_Snapor.StartSnap()
  WebPage_Snapor.SaveImage("youtube.png") ' Save the image with full size
%>

4. C#(C-Sharp) Codes: Convert YouTube video webpage to image

// Convert YouTube video page to image in C#(C-Sharp)
ThumbMakerClass Thumb_Maker = new ACAWebThumbLib.ThumbMakerClass(); // Create instance

Thumb_Maker.SetURL("http://www.youtube.com/watch?v=4Ifma_3ZB24"); // Set URL
Thumb_Maker.SetActiveXEnabled(True); // Enablue ActiveX
Thumb_Maker.SetJavaEnabled(True); // Enablue Java applet
Thumb_Maker.SetJScriptEnabled(True); // Enablue Java
// Set the delay time value for loading the Flash video, in milliseconds
Thumb_Maker.SetDelayTime(5000); 

Thumb_Maker.StartSnap();
Thumb_Maker.SaveImage("youtube.png"); // Save the image with full size in C#

5. Perl codes: Convert YouTube video webpage to image

# NOTE:
# Note: To launch this sample, please install ActivePerl on your Windows:
#      http://www.activestate.com/Products/ActivePerl
# Remark: This script shows how to make a web thumbnail from Youtube video webpage using Perl.

use Win32::OLE;
$WebPage_Converter = Win32::OLE->new('ACAWebThumb.ThumbMaker');

$WebPage_Converter->SetURL("http://www.youtube.com/watch?v=4Ifma_3ZB24"); # Set URL
$WebPage_Converter->SetActiveXEnabled(1); # Enablue ActiveX
$WebPage_Converter->SetJavaEnabled(1); # Enablue Java applet
$WebPage_Converter->SetJScriptEnabled(1); # Enablue Java
# Set the delay time value for loading the Flash video in milliseconds
$WebPage_Converter->SetDelayTime(5000);

$WebPage_Converter->StartSnap();
$WebPage_Converter->SaveImage("youtube.png");

6. VC++ Code: Convert YouTube video page to image

  // Initializes the COM library on the current thread
  CoInitialize(NULL); 
    
  HRESULT hr;
  IThumbMaker * t_xpMaker = NULL;
  hr = CoCreateInstance(
    __uuidof(ThumbMaker), NULL, CLSCTX_INPROC_SERVER, 
    __uuidof(IThumbMaker), (void**)&t_xpMaker
    );
  if ( SUCCEEDED(hr)  )
  {
    t_xpMaker->SetURL("http://www.youtube.com/watch?v=4Ifma_3ZB24"); // Set URL
    t_xpMaker->SetActiveXEnabled(TRUE); // Enablue ActiveX
    t_xpMaker->SetJavaEnabled(TRUE); // Enablue Java applet
    t_xpMaker->SetJScriptEnabled(TRUE); // Enablue Java
    // Set the delay time value for loading the Flash video in milliseconds
    t_xpMaker->SetDelayTime(5000); 
    t_xpMaker->StartSnap();
    t_xpMaker->SaveImage( _T("youtube.png") );
    t_xpMaker->Release();
  }
  CoUninitialize();  

7. VB Code: Convert YouTube video page to image

  Dim Thumb_Maker As New ACAWebThumbLib.ThumbMaker

  Thumb_Maker.SetURL ("http://www.youtube.com/watch?v=4Ifma_3ZB24")
  Thumb_Maker.SetActiveXEnabled(True) // Enablue ActiveX
  Thumb_Maker.SetJavaEnabled(True) // Enablue Java applet
  Thumb_Maker.SetJScriptEnabled(True) // Enablue Java
  // Set the delay time value for loading the Flash video in milliseconds
  Thumb_Maker.SetDelayTime(True) 

  t_xThumbMaker.StartSnap()
  t_xThumbMaker.SaveImage("youtube-video.png")

Free Trial ACA WebThumb ActiveX Now

Other resource about Converting webpage to image:


Get discount alerts, new product information and technical articles:
Name:
Email:
* Get 10% off your first order by joining our mailing list!
* You may safely unsubscribe at any time!