Media:...Factory(3pm)

πŸ“¦
version 1.5.2 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– Media:...Factory(3pm) β€” bestie's guide to Media::Convert::Asset::ProfileFactory πŸ’–

okay so welcome to the User Contributed Perl Documentation page for Media::Convert::Asset::ProfileFactory, aka the manual page Media:...Factory(3pm). pull up a chair, we're making output profiles πŸŽ€


✨ NAME ✨

Media::Convert::Asset::ProfileFactory β€” Create an output profile from an input video. that's it, that's the whole vibe. it takes your input video and spins you up a profile. iconic πŸ¦‹


🌸 SYNOPSIS 🌸

like, here's the whole thing in action, no notes:

use Media::Convert::Asset;
use Media::Convert::Pipe;
use Media::Convert::Asset::ProfileFactory;

package Media::Convert::Asset::Profile::myprofile;
use Moose;
extends Media::Convert::Asset::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 = Media::Convert::Asset->new(url => "foo.mp4");
my $profile = Media::Convert::Asset::ProfileFactory->create("myprofile", $input);
my $output = Media::Convert::Asset->new(url => "foo." . $profile->exten, reference => $profile);
Media::Convert::Pipe->new(inputs => [$input], output => $output)->run();

# Or using an ad-hoc profile:
$profile = Media::Convert::Asset::ProfileFactory->create("extraprofile", $input,
    {
        extraprofile => {
            parent => "webm",
            settings => { audio_codec => "vorbis", quality => 10 },
        }
    });
# After this, using the profile happens exactly the same way.

no cap, that last comment is literally the tea β€” once the profile exists, you use it the exact same way. periodt πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

so Media::Convert::Asset::Profile::Base is a subclass of Media::Convert::Asset, right? but plot twist: a bunch of the probing methods are overridden so they return values that are not in line with the reference of the given video. it's giving "main character who lies about their stats" but, like, on purpose 😭

and the create method of Media::Convert::Asset::ProfileFactory is just a lil helper that does three things:

  • ensures the relevant Media::Convert::Asset::Profile::profile module has actually been loaded (that's the module for the parent attribute of the ad-hoc profile, if you picked one) 🫢
  • creates a Media::Convert::Asset subclass of the right type, with reference set to the input Media::Convert::Asset object you passed in ✨
  • if you went the ad-hoc route, it makes sure the relevant attributes on the resulting object get set to the values in the settings key of the ad-hoc profile's settings πŸ’–

πŸ¦‹ CREATING NEW PROFILES πŸ¦‹

you can make a whole new profile by extending an existing one. the myprofile profile up in the example above is the demo of exactly how. any property that Media::Convert::Asset knows about can be overridden this way. slay.

<b>or</b>, you can create new profiles in the ad-hoc manner. it's easier, because it only needs an extra parameter passed to the create function. but β€” and this is the important part β€” profiles made this way can only hardcode values, and can't vary any parameters based on the input file. πŸ™ˆ

so if you want a profile that can vary stuff based on the input, and the new profile just changes a minor detail of an existing profile: extend that profile and change the detail you wanna change. and if you want a brand-new profile from scratch: extend the Base profile (see below). πŸ’…


🌈 PRE-EXISTING PROFILES 🌈

these are all defined by Media::Convert::Asset::ProfileFactory, and they're just sitting there waiting for you:

🌟 Base

this one is the base class for the other profiles. do not use it directly. i'm serious, bestie.

it adds the extension, and defaults the pixel format to yuv420p. cute.

🌟 vp9

produces a video in WebM/VP9 format, using the quality/bitrate settings that Google recommends 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. no vibes-based tuning here, it's just set.

🌟 vp8

produces a video in WebM/VP8 format. since no similar recommendations for VP8 exist the way they do for VP9, no explicit quality or bitrate settings are configured in this profile. the libvpx video codec is selected, and libvorbis for audio.

the audio bitrate is explicitly left to ffmpeg defaults; the extension is set to vp8.webm. leaving it up to ffmpeg, we love a hands-off queen πŸŽ€

🌟 webm

this profile subclasses from the vp9 profile, and only changes the extension to plain webm instead of vp9.webm. that's the whole glow-up. ✨

note that future versions of this class may switch to subclassing from the AV1 profile rather than the VP9 profile, although this will not happen before AV1 encoding can be done at reasonable speeds by Media::Convert. so like, heads up, but also not yet. 🫢

🌟 vp8_lq

this profile subclasses from the vp8 profile. the extension is set to lq.webm. on top of the changes the vp8 profile already made, 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 4. small. smol. adorable. πŸ“


πŸ’« SEE ALSO πŸ’«

go read these next, bestie, they're all part of the lore:

  • Media::Convert::Asset
  • Media::Convert::Profile::mp4
  • Media::Convert::Profile::mpeg2
  • Media::Convert::Profile::copy

and that's the whole page, mwah πŸ’‹ this was perl v5.40.1, dated 2026-02-15 β€” thanks for reading my lil manual-page essay, love u, bye πŸ§šπŸ’œ

πŸ“¦ where this page comes from