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 | |