Ticket #8017: flv_stream.diff

File flv_stream.diff, 1.3 KB (added by justin.johnson3@…, 10 years ago)

new patch with new fix

  • mythplugins/mythweb/modules/stream/stream_flv.pl

     
    8383                "Can't do ffmpeg: $!\n${ffmpeg_command}";
    8484        exit;
    8585    }
    86     print header(-type => 'video/x-flv');
     86    # Guess the filesize based on duration and bitrate. This allows for progressive download behavior
     87    my $lengthSec;
     88    $dur = `ffmpeg -i $filename 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,//`;
     89    if ($dur && $dur =~ /\d*:\d*:.*/) {
     90        @times = split(':',$dur);
     91        $lengthSec = $times[0]*3600+$times[1]*60+$times[2];
     92        $size = int($lengthSec*($vbitrate*1000+$abitrate*1000)/8);
     93        print header(-type => 'video/x-flv','Content-Length' => $size);
     94    } else {
     95        print header(-type => 'video/x-flv');
     96    }
     97
    8798    my $buffer;
    88     while (read DATA, $buffer, 262144) {
     99    if (read DATA, $buffer, 53) {
    89100        print $buffer;
     101        read DATA, $buffer, 8;
     102        $durPrint = reverse pack("d",$lengthSec);
     103        print $durPrint;
     104        while (read DATA, $buffer, 262144) {
     105            print $buffer;
     106        }
    90107    }
    91108    close DATA;
    92109