LongTail Video is now JW Player - New Name, Same Passion For Video

Close

JW Player Forums

CATEGORY:

/

How to add image FLV Video player playlist?

8 replies [Last post]

Hi,i want to add image thumbnail with each video in my list,like if there are 10 songs in my list,i wan to display image of each video shud view alongwith each video name,how can i do that,my videos are playing perfectly,but only problem is how to show image or view of all videos in my list,it only show names of videos. plz help

Add an image element to each track element.<image>http://my.domain.com/path/image.jpg</image>
The default for the v3.16 player is thumbsinplaylist, so you shuldn't have to add to or change your player code.

See this tutorial for a more detailed explanation: http://www.jeroenwijering.com/?item=Supported_Playlists

Thanks for reply, let me explain you my problem in more detail, i dont want to add <image> tag in ,it needs image file to add to thumbanail. what i want is that when i add video in my playlist how can i see the video thumbail alongwith with each video name in video list, what i thought that FLV player ,do i need to make a image from my video and then add <image> tag and add thumbnail with that video,plz help?

You need an image element in each track of your playlist if you want to display thumbnails.

The image can be a static image that is stored on your server or it can be generated on-the-fly by a request to a PHP script that uses ffmpeg to extract the image from the video file.

To see how that works, copy and paste this URI in your browser, change the time to get different images.

http://willswonders.myip.org:8085/php/ffmpeg_image.php?file=video.flv&time=00:00:05&browser=true

Thanks again,ur URL is working great,i think i get some idea regarding thumbnails now, i was searching on "ffmpeg", actually i work in "java" so no knowledge of PHP,if you know whow can i use "ffmpeg" in java to create thumbnails it will be realy a great help for me.

The php code is quite simple, so you can probably write the same thing in Java.

1) get some variables,
    a) file
    b) time (into the video file)

2) cleanup/reformat
    a) time format into 00:00:00 (or convert % into video, to time format 00:00:00)
    b) create image name

3) run ffmpeg

You don't need the logging code in this code, so ignore that. And if you want to keep it simple, don't implement the % into the file method. There is an alternate method for jpg images commented out. Also, note the *nix method in the comments at the bottom of the code.

<?php

// generate a preview image from an FLV file on-the-fly, or to save
// Will - 10-16-07
// call with: ffmpeg_image.php?file=video.flv&time=00:00:05&browser=true
// call with: ffmpeg_image.php?file=video.flv&percent=75.3&browser=true
// no time defaults to "00:00:01" (one second), no browser defaults to "true"

$videofile = (isset($_GET['file'])) ? strval($_GET['file']) : 'video.flv';
$image = substr($videofile, 0, strlen($videofile) - 4);
$time = (isset($_GET['time'])) ? strval($_GET['time']) : '00:00:01';

// debug ("    File: ", $videofile);
// debug ("   Image: ", $image);
// debug ("    Time: ", $time);
// print "/usr/bin/ffmpeg -vcodec png -i \"" . $videofile . "\" -ss " . $time . " -vframes 1 -f image2 -";
// exit;
// debug

// check time format
if (!preg_match('/\d\d:\d\d:\d\d/', $time))
{
  $time = "00:00:00";
}

// debug ("    Time: ", $time);

if (isset($_GET['percent']))
{
  $percent = $_GET['percent'];

  // debug (" Percent: ", $percent);

  ob_start();
  passthru("ffmpeg-10141.exe -i \"". $videofile . "\" 2>&1");
  $duration = ob_get_contents();
  ob_end_clean();

  // debug ("Duration: ", $duration);

  preg_match('/Duration: (.*?),/', $duration, $matches);
  $duration = $matches[1];

  // debug ("Duration: ", $duration);

  $duration_array = split(':', $duration);
  $duration = $duration_array[0] * 3600 + $duration_array[1] * 60 + $duration_array[2];
  $time = $duration * $percent / 100;

  // debug ("    Time: ", $time);

  $time = intval($time/3600) . ":" . intval(($time-(intval($time/3600)*3600))/60) . ":" . sprintf("%01.3f", ($time-(intval($time/60)*60)));

  // debug ("    Time: ", $time);

}

$browser = (isset($_GET['browser'])) ? strval($_GET['browser']) : 'true';

// debug (" Browser: ", $browser);

if ($browser == "true")
{
  header('Content-Type: image/png');
  passthru("ffmpeg-10141.exe -vcodec png -i \"" . $videofile . "\" -ss " . $time . " -vframes 1 -f image2 -");
  // header('Content-Type: image/jpeg');
  // passthru("\"C:/Program Files/Riva/Riva FLV Encoder 2.0/ffmpeg-NOT_OK06.exe\" -vcodec mjpeg -i " . $videofile . " -ss " . $time . " -vframes 1 -f image2 -");
}
else
{
  passthru("ffmpeg-10141.exe -vcodec png -i \"" . $videofile . "\" -ss " . $time . " -vframes 1 -f image2 \"" . $image . "\"%d.png");
  // passthru("\"C:/Program Files/Riva/Riva FLV Encoder 2.0/ffmpeg-NOT_OK06.exe\" -vcodec mjpeg -i " . $videofile . " -ss " . $time . " -vframes 1 -f image2 " . $image . "%d.jpg");
}

function debug($text1, $text2)
{
  print "<pre>\n";
  print $text1 . $text2 . "\n";
  print "</pre>\n";
}

/*
 * *nix version
 */
 
/*

<?php

// generate a preview image from an FLV file on-the-fly, or to save
// call with: ffmpeg_image.php?file=video.flv&time=00:00:05&browser=true
// call with: ffmpeg_image.php?file=video.flv&percent=75.3&browser=true
// no time defaults to "00:00:01" (one second), no browser defaults to "true"

$videofile = (isset($_GET['file'])) ? strval($_GET['file']) : 'video.flv';
$image = substr($videofile, 0, strlen($videofile) - 4);
$time = (isset($_GET['time'])) ? strval($_GET['time']) : '00:00:01';

// debug ("  File: ", $videofile);
// debug (" Image: ", $image);
// debug ("  Time: ", $time);

// check time format
if (!preg_match('/\d\d:\d\d:\d\d/', $time))
{
  $time = "00:00:00";
}

if (isset($_GET['percent']))
{
  $percent = $_GET['percent'];

// debug (" Percent: ", $percent);

  ob_start();
  exec("/usr/bin/ffmpeg -i \"". $videofile . "\" 2>&1");
  $duration = ob_get_contents();
  ob_end_clean();

  // debug ("Duration: ", $duration);

  preg_match('/Duration: (.*?),/', $duration, $matches);
  $duration = $matches[1];

// debug ("Duration: ", $duration);

  $duration_array = split(':', $duration);
  $duration = $duration_array[0] * 3600 + $duration_array[1] * 60 + $duration_array[2];
  $time = $duration * $percent / 100;

// debug (" Time: ", $time);

  $time = intval($time/3600) . ":" . intval(($time-(intval($time/3600)*3600))/60) . ":" . sprintf("%01.3f", ($time-(intval($time/60)*60)));

// debug (" Time: ", $time);

}

$browser = (isset($_GET['browser'])) ? strval($_GET['browser']) : 'true';

// debug (" Browser: ", $browser);

if ($browser == "true")
{
  header('Content-Type: image/png');
  exec("/usr/bin/ffmpeg -vcodec png -i \"" . $videofile . "\" -ss " . $time . " -vframes 1 -f image2 -");
//header('Content-Type: image/jpeg');
//exec("/usr/bin/ffmpeg -vcodec mjpeg -i \"" . $videofile . "\" -ss " . $time . " -vframes 1 -f image2 -");
}
else
{
  exec("/usr/bin/ffmpeg -vcodec png -i \"" . $videofile . "\" -ss " . $time . " -vframes 1 -f image2 \"" . $image . "\"%d.png");
//exec("/usr/bin/ffmpeg -vcodec mjpeg -i \"" . $videofile . "\" -ss " . $time . " -vframes 1 -f image2 \"" . $image . "\"%d.jpg");
}

?>

*/

?>

Thanks a lot,surely i'l try to implement same technique in java,and tell u :)

anyone collecting any of these snippets of pearls of wisdom???

come post them here

http://expatsworld.sytes.net/

I need to know how to place an image at the start of flv file so that the image shows up first, then you click the image and it takes you to the movie. When the movie is finished it goes back to the image again. Can you please tell a first time who is using flash how to do this without embedding the flv file.

Still don't have the new JW Player? Get It Here