[mythtv-users] nuvexport MPG.pm again
Jonathan Markevich
mythtv at jonandtina.net
Fri Dec 3 00:26:27 UTC 2004
I figured out why I couldn't resize video in my module. It was my
misunderstanding of the parameters for ffmpeg. You notice that no
matter what you type in for the previous module, nothing gets passed to
the encoder? I fixed that now.
This is a simple change, all it does is uncomment one line I had
commented out. Oh yeah, I changed the default export bitrate to 1150 to
be more universally VCD-friendly (if not compliant).
-------------- next part --------------
#!/usr/bin/perl -w
#Last Updated: 2004.11.28 (jmarkevich)
#
# export::MPG
# Originally export::WMV by Gavin Hurlbut <gjhurlbu at gmail.com>
#
package export::MPG;
use base 'export::ffmpeg';
# Load the myth and nuv utilities, and make sure we're connected to the database
use nuv_export::shared_utils;
use nuv_export::ui;
use mythtv::db;
use mythtv::recordings;
# Load the following extra parameters from the commandline
$cli_args{'a_bitrate|a=i'} = 1; # Audio bitrate
$cli_args{'v_bitrate|v=i'} = 1; # Video bitrate
$cli_args{'height|v_res|h=i'} = 1; # Height
$cli_args{'width|h_res|w=i'} = 1; # Width
sub new {
my $class = shift;
my $self = {
'cli' => qr/\bmpg\b/i,
'name' => 'Export to MPG',
'enabled' => 1,
'errors' => [],
# ffmpeg-related settings
'noise_reduction' => 0,
'deinterlace' => 0,
'crop' => 0,,
# MPG-specific settings
'a_bitrate' => 224,
'v_bitrate' => 1150,
'width' => 352,
'height' => 240,
};
bless($self, $class);
# Initialize and check for ffmpeg
$self->init_ffmpeg();
# Any errors? disable this function
$self->{'enabled'} = 0 if ($self->{'errors'} && @{$self->{'errors'}} > 0);
# Return
return $self;
}
sub gather_settings {
my $self = shift;
# Load the parent module's settings
$self->SUPER::gather_settings();
# Audio Bitrate
if ($Args{'a_bitrate'}) {
$self->{'a_bitrate'} = $Args{'a_bitrate'};
die "Audio bitrate must be > 0\n" unless ($Args{'a_bitrate'} > 0);
}
else {
$self->{'a_bitrate'} = query_text('Audio bitrate?',
'int',
$self->{'a_bitrate'});
}
# Ask the user what video bitrate he/she wants
if ($Args{'v_bitrate'}) {
die "Video bitrate must be > 0\n" unless ($Args{'v_bitrate'} > 0);
$self->{'v_bitrate'} = $Args{'v_bitrate'};
}
elsif ($self->{'multipass'} || !$self->{'vbr'}) {
# make sure we have v_bitrate on the commandline
$self->{'v_bitrate'} = query_text('Video bitrate?',
'int',
$self->{'v_bitrate'});
}
# Ask the user what resolution he/she wants
if ($Args{'width'}) {
die "Width must be > 0\n" unless ($Args{'width'} > 0);
$self->{'width'} = $Args{'width'};
}
else {
$self->{'width'} = query_text('Width?',
'int',
$self->{'width'});
}
if ($Args{'height'}) {
die "Height must be > 0\n" unless ($Args{'height'} > 0);
$self->{'height'} = $Args{'height'};
}
else {
$self->{'height'} = query_text('Height?',
'int',
$self->{'height'});
}
}
sub export {
my $self = shift;
my $episode = shift;
# Load nuv info
load_finfo($episode);
my $kvcd_params = " -intra_matrix "
. "8,9,12,22,26,27,29,34,"
. "9,10,14,26,27,29,34,37,"
. "12,14,18,27,29,34,37,38,"
. "22,26,27,31,36,37,38,40,"
. "26,27,29,36,39,38,40,48,"
. "27,29,34,37,38,40,48,58,"
. "27,29,34,37,38,40,48,58,"
. "34,37,38,40,48,58,69,79"
. " -inter_matrix "
. "16,18,20,22,24,26,28,30,"
. "18,20,22,24,26,28,30,32,"
. "20,22,24,26,28,30,32,34,"
. "22,24,26,30,32,32,34,36,"
. "24,26,28,32,34,34,36,38,"
. "26,28,30,32,34,36,38,40,"
. "28,30,32,34,36,38,42,42,"
. "30,32,34,36,38,40,42,44"
. " -g 24"
. " -r 23.976";
# Build the ffmpeg string
$self->{'ffmpeg_xtra'} = " -b " . $self->{'v_bitrate'}
. " -vcodec mpeg1video"
# these are not quite working yet
#. " " . $kvcd_params
. " -aspect 4:3"
. " -qmin 3 -qmax 13"
. " -ar 44100 "
. " -ab " . $self->{'a_bitrate'}
. " -acodec mp2"
. " -hq"
. " -s " .$self->{'width'} . "x" . $self->{'height'}
. " -f vcd";
# Execute the parent method
$self->SUPER::export($episode, ".mpg");
}
1; #return true
# vim:ts=4:sw=4:ai:et:si:sts=4
More information about the mythtv-users
mailing list