Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: fix-handling-options
...
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 11 files changed
  • 0 commit comments
  • 2 contributors
View
1  .gitignore
@@ -3,3 +3,4 @@ MYMETA.yml
Makefile
blib
pm_to_blib
+*.bak
View
5 Changes
@@ -1,5 +1,10 @@
Revision history for FFmpeg-Command
+0.19 Fri Jun 7
+ Support for avconv
+ https://github.com/mizzy/FFmpeg-Command/pull/8
+ Thanks to @espizo!
+
0.18 Tue Apr 17
Current version of ffmpeg has global, infile and outfile options.
So fix how to handling options.
View
11 MANIFEST
@@ -1,11 +1,16 @@
Changes
-MANIFEST
-META.yml # Will be created by "make dist"
+lib/FFmpeg/Command.pm
Makefile.PL
+MANIFEST
+META.yml # Will be created by "make dist"
README
-lib/FFmpeg/Command.pm
t/00-load.t
t/01-coderef.t
+t/02-option_a.t
+t/03-option_b.t
+t/04-option_c.t
+t/05-option_d.t
+t/06-output_options.t
t/boilerplate.t
t/pod-coverage.t
t/pod.t
View
32 lib/FFmpeg/Command.pm
@@ -2,7 +2,7 @@ package FFmpeg::Command;
use warnings;
use strict;
-our $VERSION = '0.18';
+our $VERSION = '0.19';
use base qw( Class::Accessor::Fast Class::ErrorHandler );
__PACKAGE__->mk_accessors(qw/
@@ -43,8 +43,24 @@ our %metadata = (
sub new {
my $class = shift;
+
+ my $command;
+
+ for my $cmd ( shift || 'ffmpeg', 'avconv' ) {
+ system("$cmd -version > /dev/null 2>&1");
+ my $ret = $? >> 8;
+ if ( $ret == 0 || $ret == 1 ) {
+ $command = $cmd;
+ last;
+ }
+ }
+ unless ( $command ) {
+ carp "Can't find ffmpeg/avconv command.";
+ exit 0;
+ }
+
my $self = {
- ffmpeg => shift || 'ffmpeg',
+ ffmpeg => $command,
options => [],
global_options => [],
infile_options => [],
@@ -54,13 +70,6 @@ sub new {
timeout => 0,
};
- system("$self->{ffmpeg} -version > /dev/null 2>&1");
- my $ret = $? >> 8;
- if ( $ret != 0 and $ret != 1 ) {
- carp "Can't find ffmpeg command.";
- exit 0;
- }
-
bless $self, $class;
}
@@ -180,11 +189,12 @@ __END__
=head1 NAME
-FFmpeg::Command - A wrapper class for ffmpeg command line utility.
+FFmpeg::Command - A wrapper class for ffmpeg/avconv command line utility.
=head1 DESCRIPTION
-A simple interface for using ffmpeg command line utility.
+A simple interface for using ffmpeg command line utility with fallback to use
+the newer avconv utility if ffmpeg is not installed.
=head1 SYNOPSIS
View
3  t/00-load.t
@@ -15,4 +15,5 @@ my $ff = FFmpeg::Command->new();
$ff->options( [ '-version' ] );
$ff->exec();
my $out = $ff->stderr || $ff->stdout;
-like $out, qr/^FFmpeg version/i;
+my $expected = $ff->ffmpeg . ' version';
+like $out, qr/^$expected/i;
View
3  t/01-coderef.t
@@ -22,4 +22,5 @@ $ff->exec();
my $out = $stderr || $stdout;
-like $out, qr/^FFmpeg version/i;
+my $expected = $ff->ffmpeg . ' version';
+like $out, qr/^$expected/i;
View
2  t/02-option_a.t
@@ -17,5 +17,5 @@ my $cmd = $ffmpeg->_compose_command;
is(
join(' ', @$cmd),
- 'ffmpeg -y -ga -gb -ia -ib -i filename1 -oa -ob output_file'
+ $ffmpeg->ffmpeg . ' -y -ga -gb -ia -ib -i filename1 -oa -ob output_file'
);
View
2  t/03-option_b.t
@@ -15,5 +15,5 @@ my $cmd = $ffmpeg->_compose_command;
is(
join(' ', @$cmd),
- 'ffmpeg -y -i filename1 -ga -gb -ia -ib -oa -ob output_file'
+ $ffmpeg->ffmpeg . ' -y -i filename1 -ga -gb -ia -ib -oa -ob output_file'
);
View
2  t/04-option_c.t
@@ -17,5 +17,5 @@ my $cmd = $ffmpeg->_compose_command;
is(
join(' ', @$cmd),
- 'ffmpeg -y -ga -gb -ia -ib -i filename1 -ia -ib -i filename2 -oa -ob output_file'
+ $ffmpeg->ffmpeg . ' -y -ga -gb -ia -ib -i filename1 -ia -ib -i filename2 -oa -ob output_file'
);
View
2  t/05-option_d.t
@@ -13,5 +13,5 @@ my $cmd = $ffmpeg->_compose_command;
is(
join(' ', @$cmd),
- 'ffmpeg -y -ga -gb -ia1 -ib1 -i filename1 -ia2 -ib2 -i filename2 -oa -ob output_file',
+ $ffmpeg->ffmpeg . ' -y -ga -gb -ia1 -ib1 -i filename1 -ia2 -ib2 -i filename2 -oa -ob output_file',
);
View
4 t/06-output_options.t
@@ -24,7 +24,7 @@ my $cmd = $ffmpeg->_compose_command;
is(
join(' ', @$cmd),
- 'ffmpeg -y -i in.mp4 -acodec libaac -b 600 -f mp4 -vcodec mpeg4 -ar 48000 -s 320x240 -ab 64 out.mp4'
+ $ffmpeg->ffmpeg . ' -y -i in.mp4 -acodec libaac -b 600 -f mp4 -vcodec mpeg4 -ar 48000 -s 320x240 -ab 64 out.mp4'
);
$ffmpeg = FFmpeg::Command->new;
@@ -37,5 +37,5 @@ $ffmpeg->output_options({
$cmd = $ffmpeg->_compose_command;
is(
join(' ', @$cmd),
- 'ffmpeg -y -i in.mp4 -b 600 -acodec libfaac -f mp4 -vcodec mpeg4 -ar 48000 -s 320x240 -ab 64 out.mp4'
+ $ffmpeg->ffmpeg . ' -y -i in.mp4 -b 600 -acodec libfaac -f mp4 -vcodec mpeg4 -ar 48000 -s 320x240 -ab 64 out.mp4'
);

No commit comments for this range

Something went wrong with that request. Please try again.