How to effectively implement Youtube thumbnail preview function?

I am trying to implement the Youtube thumbnail preview function for my Simple video player. Here's the snap for it:

enter image description here  

The good thing : it runs smoothly as soon as Player receives all thumbnail previews from the HTTP server.

The bad thing : taking all Thumbnail previews takes a long time (20-30 seconds). (For a video (.mp4 file) equal to 14 minutes (~ 110 MB), there are approximately 550 thumbnails (160x120))

What I do is this . When the user starts playing the video, I will make an HTTP request "total_thumbnails" to the server to get all of them.

Also note :

  • HTTP- Async Task.
  • , , , .
  • "total_thumbnails" HTTP- , .

. HTTP (lighttpd), , .mp4 . , .mp4 HTTP.

: , , ( , , , ):

enter image description here

. ( ) , ( ) , ?

> YouTube, ( ), ( , , ).

?

- ?

+4
3
  • . canvas ( JS, , ), . , , youtube. (, ).
  • . jpeg (~ q = 70). .
  • . , 2:55:
    • 8 , : 0:00, 0:25, 0:50, 1:15, 1:40, 2:05, 2:30, 2:55. " " .
    • 4 32 , , : 0:00, 0:06, 0:11, 0:17,...
    • - .
+1

( .mp4), 14 (~ 110 ), 550 (160x120).

, , , 550 HTTP-. , : k, , k + 1. , HTTP- , k .

1

550 550 .

, , . Tar , , , , (1) , , (.. k- ) (2) 512 .

, . - :

  • 4 n, ;
  • 4 × n ;
  • , .

2

HTTP- - HTTP/1.1, (, 550), . , , .

.

-, HTTP- HTTP. , , Python . , , , , libcurl ( CURLMOPT_PIPELINING CURLMOPT_MAX_PIPELINE_LENGTH). libcurl .

-, Lighttpd. server.max-keep-alive-requests 16, , 17 , . , , .

( ) , , , . , .

, - HTTP- (, ), HTTP.

. Lighttpd 1.4.31 550 ( 4.2M), server.max-keep-alive-requests = 600, . . 10 .

0

, , , html. , , . base64, .

eg. {base64_encoded_image},{time},..., extract this into image / time tuples, and then display it. HTML pages can display base64 encoded images by default, so further processing on the client is not required.

NOTE . I must warn you that base64 will be approximately 37% larger. Gziped will be comparable, however the Gziped binary will still be smaller. Since base64 uses 6 bits for every 8 bits. binary uses all 8 bits.

0
source

All Articles