SReview::Video::ProfileFactory(3pm) | User Contributed Perl Documentation | SReview::Video::ProfileFactory(3pm) |
SReview::Video::ProfileFactory - Create an output profile from an input video.
use SReview::Video; use SReview::Videopipe; use SReview::Video::ProfileFactory; package SReview::Video::Profile::myprofile; use Moose; extends SReview::Video::Profile::webm; has '+audio_samplerate' => ( builder => '_probe_my_audiorate', ); has '+audio_codec' => ( default => 'vorbis', ); sub _probe_exten { return 'my.webm', } 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();
"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:
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 new profile, one can use the "extra_profiles" configuration setting; however, profiles created in this manner can only hardcode values, and cannot vary any parameters based on the input file. To create a profile that can do so, when the new profile 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).
The following profiles are defined by "SReview::Video::ProfileFactory":
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.
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.
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"
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.
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.
SReview::Video
2021-01-31 | perl v5.32.0 |