fix the command method and add a example

git-svn-id: svn://127.0.0.1/Perl/FFmpeg-Stream-Helper/trunk@929 0c1c3402-1be1-de11-8092-0022686faf23
This commit is contained in:
Zane C. B-H 2016-05-21 10:49:51 +00:00
parent ae3227e6a5
commit 4bd91f2c3a
4 changed files with 78 additions and 4 deletions

View File

@ -1,5 +1,9 @@
Revision history for FFmpeg-Stream-Helper
0.1.0 2016-05-21/06:00
-Misc. fixes to the command method and webm now really works.
-Add a example script.
0.1.0 2016-05-21/04:30
-Now properly does webm and make webm the default.

View File

@ -7,3 +7,5 @@ t/00-load.t
t/manifest.t
t/pod-coverage.t
t/pod.t
example/stream.pl

View File

@ -0,0 +1,68 @@
use FFmpeg::Stream::Helper;
use Mojolicious::Lite;
use Mojo::IOLoop::ReadWriteFork;
get '/' => sub {
my $c = shift;
$c->render(template=>'root');
};
get '/video.webm' => sub {
my $self = shift->render_later;
#$self->res->headers->content_length('*');
my $fork = Mojo::IOLoop::ReadWriteFork->new;
my $fsh=FFmpeg::Stream::Helper->new;
my $command=$fsh->command('/arc/video/movies/Fear and Loathing in Las Vegas.avi');
$self->stash(fork => $fork);
my $tx = $self->tx;
$self->on(finish => sub {
my $self = shift;
my $fork = $self->stash('fork') or return;
app->log->debug("Ending ffmpeg process");
$fork->kill;
undef $tx;
});
$fork->on(read => sub {
my($fork, $buffer) = @_;
$self->write_chunk($buffer);
});
warn ($command);
$fork->start(program => $command);
};
app->start;
__DATA__
@@ root.html.ep
<!DOCTYPE html>
<html>
<head>
<link href="//vjs.zencdn.net/5.8/video-js.min.css" rel="stylesheet">
<script src="//vjs.zencdn.net/5.8/video.min.js"></script>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</head>
<body>
<div style="text-align:center">
<video id="video0" autoplay class="video-js vjs-default-skin" controls preload="none" >
<source src="video.webm" type="video/webm">
Your browser does not support HTML5 video.
</video>
</div>
</body>
</html>

View File

@ -12,11 +12,11 @@ FFmpeg::Stream::Helper - Helper for streaming and transcoding using ffmpeg.
=head1 VERSION
Version 0.1.0
Version 0.1.1
=cut
our $VERSION = '0.1.0';
our $VERSION = '0.1.1';
=head1 SYNOPSIS
@ -283,11 +283,11 @@ sub command{
my $command='';
if ( $command eq 'webm' ){
if ( $self->{format} eq 'webm' ){
$command='ffmpeg -i '.shell_quote($file).
' -loglevel '.shell_quote($self->{loglevel}).
$bound.
'-f webm -c:v libvpx -maxrate '.$self->{kbps}.'k -preset superfast -threads 0'.
' -f webm -c:v libvpx -maxrate '.$self->{kbps}.'k -preset superfast -threads 0'.
' '.shell_quote($self->{output});
}else{
# ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -vcodec libx264 -preset superfast -threads 0 -