|  | 
|  | 1 | +# | 
|  | 2 | +# $Date$ | 
|  | 3 | +# $Revision$ | 
|  | 4 | +# $Author$ | 
|  | 5 | +# | 
|  | 6 | +#  export::ffmpeg::PSP | 
|  | 7 | +# | 
|  | 8 | +#   obtained and slightly modified from http://mysettopbox.tv/phpBB2/viewtopic.php?t=5030& | 
|  | 9 | +# | 
|  | 10 | + | 
|  | 11 | +package export::ffmpeg::PSP; | 
|  | 12 | +    use base 'export::ffmpeg'; | 
|  | 13 | + | 
|  | 14 | +# Load the myth and nuv utilities, and make sure we're connected to the database | 
|  | 15 | +    use nuv_export::shared_utils; | 
|  | 16 | +    use nuv_export::cli; | 
|  | 17 | +    use nuv_export::ui; | 
|  | 18 | +    use mythtv::db; | 
|  | 19 | +    use mythtv::recordings; | 
|  | 20 | + | 
|  | 21 | +# Load the following extra parameters from the commandline | 
|  | 22 | + | 
|  | 23 | +    sub new { | 
|  | 24 | +        my $class = shift; | 
|  | 25 | +        my $self  = { | 
|  | 26 | +                     'cli'      => qr/\bpsp\b/i, | 
|  | 27 | +                     'name'     => 'Export to PSP', | 
|  | 28 | +                     'enabled'  => 1, | 
|  | 29 | +                     'errors'   => [], | 
|  | 30 | +                     'defaults' => {}, | 
|  | 31 | +                    }; | 
|  | 32 | +        bless($self, $class); | 
|  | 33 | + | 
|  | 34 | +    # Initialize the default parameters | 
|  | 35 | +        $self->load_defaults(); | 
|  | 36 | + | 
|  | 37 | +    # Initialize and check for ffmpeg | 
|  | 38 | +        $self->init_ffmpeg(); | 
|  | 39 | + | 
|  | 40 | +    # Can we even encode psp? | 
|  | 41 | +        if (!$self->can_encode('psp')) { | 
|  | 42 | +            push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to psp video."; | 
|  | 43 | +        } | 
|  | 44 | +        if (!$self->can_encode('aac')) { | 
|  | 45 | +            push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to aac audio."; | 
|  | 46 | +        } | 
|  | 47 | +    # Any errors?  disable this function | 
|  | 48 | +        $self->{'enabled'} = 0 if ($self->{'errors'} && @{$self->{'errors'}} > 0); | 
|  | 49 | +    # Return | 
|  | 50 | +        return $self; | 
|  | 51 | +    } | 
|  | 52 | + | 
|  | 53 | +# Load default settings | 
|  | 54 | +    sub load_defaults { | 
|  | 55 | +        my $self = shift; | 
|  | 56 | +    # Load the parent module's settings | 
|  | 57 | +        $self->SUPER::load_defaults(); | 
|  | 58 | +    # Not really anything to add | 
|  | 59 | +    } | 
|  | 60 | + | 
|  | 61 | +# Gather settings from the user | 
|  | 62 | +    sub gather_settings { | 
|  | 63 | +        my $self = shift; | 
|  | 64 | +    # Load the parent module's settings | 
|  | 65 | +        $self->SUPER::gather_settings(); | 
|  | 66 | +    } | 
|  | 67 | + | 
|  | 68 | +    sub export { | 
|  | 69 | +        my $self    = shift; | 
|  | 70 | +        my $episode = shift; | 
|  | 71 | +    # Load nuv info | 
|  | 72 | +        load_finfo($episode); | 
|  | 73 | +    # Force to 4:3 aspect ratio | 
|  | 74 | +        $self->{'out_aspect'} = 1.3333; | 
|  | 75 | +        $self->{'aspect_stretched'} = 1; | 
|  | 76 | +    # PAL or NTSC? | 
|  | 77 | +        my $standard = ($episode->{'finfo'}{'fps'} =~ /^2(?:5|4\.9)/) ? 'PAL' : 'NTSC'; | 
|  | 78 | +        $self->{'width'} = 320; | 
|  | 79 | +        $self->{'height'} = ($standard eq 'PAL') ? '288' : '240'; | 
|  | 80 | +        $self->{'out_fps'} = ($standard eq 'PAL') ? 25 : 29.97; | 
|  | 81 | +    # Build the transcode string | 
|  | 82 | +        my $safe_title       = shell_escape($episode->{'show_name'}." - ".$episode->{'title'}); | 
|  | 83 | +        $self->{'ffmpeg_xtra'}  = " -b 768" | 
|  | 84 | +                                 ." -ab 32 -ar 24000 -acodec aac" | 
|  | 85 | +                                 ." -bitexact -f psp -title $safe_title"; | 
|  | 86 | +    # Execute the parent method | 
|  | 87 | +        $self->SUPER::export($episode, ".mp4"); | 
|  | 88 | +    } | 
|  | 89 | + | 
|  | 90 | +1;  #return true | 
|  | 91 | + | 
|  | 92 | +# vim:ts=4:sw=4:ai:et:si:sts=4 | 
0 commit comments