[mythtv-commits] Ticket #8017: Fix mythweb flash streaming to behave like a progressive download

MythTV mythtv at cvs.mythtv.org
Thu Feb 18 03:39:31 UTC 2010


#8017: Fix mythweb flash streaming to behave like a progressive download
---------------------------------------+------------------------------------
 Reporter:  justin.johnson3@…          |       Owner:  kormoc 
     Type:  enhancement                |      Status:  new    
 Priority:  minor                      |   Milestone:  unknown
Component:  Plugin - MythWeb           |     Version:  unknown
 Severity:  medium                     |     Mlocked:  0      
---------------------------------------+------------------------------------

Comment(by scottadmi@…):

 I found a work around which doesn't require changes to ffmpeg. Its very
 rough code (as perl is not a language I work with much), but it works. The
 gist of it, is simply writing the duration data directly to the output
 stream at the appropriate place in the flv export (effectively overwriting
 the location which has a zero generated by ffmpeg).

 This code snippet replaces the end of stream_flv.pl

 {{{
     # Guess the filesize based on duration and bitrate. This allows for
 progressive download behavior
     my $lengthSec;
     $dur = `ffmpeg -i $filename 2>&1 | grep "Duration" | cut -d ' ' -f 4 |
 sed s/,//`;
     if ($dur && $dur =~ /\d*:\d*:.*/) {
         @times = split(':',$dur);
         $lengthSec = $times[0]*3600+$times[1]*60+$times[2];
         $size = int($lengthSec*($vbitrate*1000+$abitrate*1000)/8);
         print header(-type => 'video/x-flv','Content-Length' => $size);
     } else {
         print header(-type => 'video/x-flv');
     }

     my $buffer;
     if (read DATA, $buffer, 53) {
         print $buffer;
         read DATA, $buffer, 8;
         $durPrint = reverse pack("d",$lengthSec); // change endian
         print $durPrint;
         while (read DATA, $buffer, 262144) {
             print $buffer;
         }
     }
     close DATA;

 }}}

 This could certainly be made cleaner, but it works well for now.

-- 
Ticket URL: <http://svn.mythtv.org/trac/ticket/8017#comment:4>
MythTV <http://www.mythtv.org/>
MythTV


More information about the mythtv-commits mailing list