NAME
SReview::Video::ProfileFactory - Create an output profile from an input video.
SYNOPSIS
use SReview::Video;
use SReview::Videopipe;
use SReview::Video::ProfileFactory;
package SReview::Video::Profile::myprofile;
use Moose;
extends SReview::Video::Profile::webm;
has '+exten' => (
default => 'my.webm',
);
has '+audio_samplerate' => (
builder => '_probe_my_audiorate',
);
has '+audio_codec' => (
default => 'vorbis',
);
sub _probe_my_audiorate {
my $self = shift;
return $self->reference->audio_samplerate / 2;
}
no Moose;
package main;
my $input = SReview::Video->new(url => "foo.mp4");
my $profile = SReview::Video::ProfileFactory->create("myprofile", $input);
my $output = SReview::Video->new(url => "foo." . $profile->exten, reference => $profile);
SReview::Videopipe->new(inputs => [$input], output => $output)->run();
DESCRIPTION
SReview::Video::Profile::Base
is a subclass of SReview::Video, but with a number of the probing methods overridden so that they return values that are not in line with the reference of the given video.
The SReview::Video::ProfileFactory
's create
method is a simple helper to:
ensure that the relevant
SReview::Video::Profile::profile
module has been loadedcreate an
SReview::Video
subclass of the right type, with reference set to the passed inputSReview::Video
object.
CREATING NEW PROFILES
It is possible to create a new profile by extending an existing one. The myprofile
profile in the above example shows how to do so. Any property that is known by SReview::Video can be overridden in the manner given.
To create a profile that just changes a minor detail of an existing profile, extend that profile and change the detail which you want to change. To create a new profile from scratch, extend the Base
profile (see below).
PRE-EXISTING PROFILES
The following profiles are defined by SReview::Video::ProfileFactory
:
Base
This profile serves as a base class for the other profiles. It should not be used directly.
It adds the extension, and defaults the pixel format to yuv420p.
vp9
Produces a video in WebM/VP9 format, using the quality/bitrate settings recommended by Google on https://developers.google.com/media/vp9/, and with OPUS audio. Produces files with the vp9.webm
extension.
Audio settings are hardcoded to 48KHz sampling rate, 128k bits per second.
vp8
Produces a video in WebM/VP8 format. Since no similar recommendations for VP8 exist as do for VP9, no explicit quality or bitrate settings are configured in this profile. The libvpx video codec is selected, and the libvorbis one for audio.
The audio bitrate is explicitly left to ffmpeg defaults; the extension is set to vp8.webm
webm
This profile subclasses from the vp9
profile, and only changes the extension to plain webm
instead of vp9.webm
.
Additionally, if a future version of WebM is ever defined, then when SReview gains support for that version of WebM, this class will become a subclass of that class instead.
vp8_lq
This profile subclasses from the vp8
profile. The extension is set to lq.webm
. In addition to the changes made by the vp8
profile, this profile also rescales the video to a fraction of the original; that is, the height and width of the video are both divided by 8.