views:

54

answers:

1

How do I link to snapshots of embedded flash videos instead of the actual flash videos to reduce loading times of a site?

+4  A: 

Yes, and in fact this is a method that is often employed. You start with an image with a play button overlay. When it's clicked, the image element is replaced with a flash element that plays the video.

Perhaps something like the following:

<script>
$(function () {
    $("img.thumbnail").click(function (e) {
        $(e.parentNode).addClass("play");
    });
});
</script>

<style>
.toggler .player { display: none; }
.toggler.play .player { display: block }
.toggler.play .thumbnail { display: none }
</style>

<div class="toggler">
    <img class="thumbnail" src="thumbnail.jpg">
    <div class="player">
        <!-- embed your player here -->
    </div>
</div>
Ates Goral
Yes, what is the method for doing that? :)
Absolute0
You could use ffmpeg to extract a single frame from the source video. I would use jQuery for DOM manipulation. Are you looking for code?
Ates Goral
Yes a code example would be great.
Absolute0
How do you make the screenshot be an actual frame from the video?Something mid-video would be great!
Absolute0
With ffmpeg, you can use the arguments -ss 1 -vframes 1 -r 1 to extract the frame at the first second into the movie.
Ates Goral
You can either generate the thumbnail manually, ahead of time, or by calling ffmpeg at the backend to generate it on demand. See http://github.com/atesgoral/instaflavor for a PHP example.
Ates Goral