3
If you have in hand the current time information from video to mouse over the video duration progress bar, you could send this information to the server with Ajax and use ffmpeg to capture Thumb with the current video time.
Example:
$video = 'path/to/video.flv';
$thumbnail = 'path/to/thumbnail.jpg';
$currentTime = isset($_POST['current_time']) ? $_POST['current_time'] : '00:00:01';
shell_exec("ffmpeg -i $video -deinterlace -an -ss 1 -t {$currentTime} -r 1 -y -vcodec mjpeg -f mjpeg $thumbnail 2>&1")
Code excerpt from the SOEN reply: How can I get a thumbnail from a video that a user has uploaded to my server?
Updating
There is a library called PHP-Ffmpeg that facilitates the handling of video formats in PHP. With it it is also possible to extract images from a given stretch.
For example:
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open('video.mpg');
$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(42));
$frame->save('image.jpg');
In the above example, the frame 42
video will be captured and saved in format jpg
. Therefore, you can also use this feature to provide a temporary image of the video.
Speaking specifically of youtube, it is not possible to do this using the v3 API. Most likely they are created in the first use and saved for the next. Like, when you hover your mouse and you see a low-resolution preview, then you switch to a better-resolution one. How do I do not know, but if I were to invent something like this, I would probably upload a reduced/compressed version of the video in that frame and save jpg.
– Ricardo Moraleida
Is Xuxa in the video? kkkk
– Wallace Maxters
Yeah, I just opened the first video that came on youtube kk
– Leo Letto