« blib/lib/Video/DVDRip/GUI/Project/Subtitle.pm
↑ Summary
blib/lib/Video/DVDRip/Cluster/JobPlanner.pm »
| 1 | # $Id: Convert.pm 2187 2006-08-16 19:34:38Z joern $ | ||
| 2 | |||
| 3 | #----------------------------------------------------------------------- | ||
| 4 | # Copyright (C) 2001-2006 Jörn Reder <joern AT zyn.de>. | ||
| 5 | # All Rights Reserved. See file COPYRIGHT for details. | ||
| 6 | # | ||
| 7 | # This module is part of Video::DVDRip, which is free software; you can | ||
| 8 | # redistribute it and/or modify it under the same terms as Perl itself. | ||
| 9 | #----------------------------------------------------------------------- | ||
| 10 | |||
| 11 | package Video::DVDRip::Convert; | ||
| 12 | use Locale::TextDomain qw (video.dvdrip); | ||
| 13 | |||
| 14 | use base Video::DVDRip::Base; | ||
| 15 | |||
| 16 | use Carp; | ||
| 17 | use strict; | ||
| 18 | |||
| 19 | sub convert_audio_tracks_0_45_04 { | ||
| 20 | my $class = shift; | ||
| 21 | my %par = @_; | ||
| 22 | my ($project) = @par{'project'}; | ||
| 23 | |||
| 24 | print "[auto-conversion] Import audio configuration (0.45_04)\n"; | ||
| 25 | |||
| 26 | print "\nSorry, this version can't convert such old files.\n"; | ||
| 27 | print "If you really need this file, install dvd::rip < 0.49 first\n"; | ||
| 28 | print "and convert the file. Then upgrade dvd::rip again and\n"; | ||
| 29 | print "you should be able to convert and use the file.\n\n"; | ||
| 30 | |||
| 31 | exit 1; | ||
| 32 | |||
| 33 | 1; | ||
| 34 | } | ||
| 35 | |||
| 36 | sub set_audio_bitrates_0_47_02 { | ||
| 37 | my $class = shift; | ||
| 38 | my %par = @_; | ||
| 39 | my ($project) = @par{'project'}; | ||
| 40 | |||
| 41 | |||
| 42 | "[auto-conversion] Setting new audio bitrate attributes (0.47_02)\n"; | ||
| 43 | |||
| 44 | foreach my $title ( values %{ $project->content->titles } ) { | ||
| 45 | my $audio_info = $title->audio_tracks; | ||
| 46 | next if not $audio_info; | ||
| 47 | my $i = 0; | ||
| 48 | foreach my $audio ( @{ $title->{tc_audio_tracks} } ) { | ||
| 49 | $audio->{tc_mp2_bitrate} = $audio->{tc_bitrate}; | ||
| 50 | $audio->{tc_mp3_bitrate} = $audio->{tc_bitrate}; | ||
| 51 | $audio->{tc_ogg_bitrate} = $audio->{tc_bitrate}; | ||
| 52 | $audio->{tc_ac3_bitrate} = $audio_info->[$i]->bitrate; | ||
| 53 | ++$i; | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | 1; | ||
| 58 | } | ||
| 59 | |||
| 60 | sub convert_container_0_49_1 { | ||
| 61 | my $class = shift; | ||
| 62 | my %par = @_; | ||
| 63 | my ($project) = @par{'project'}; | ||
| 64 | |||
| 65 | |||
| 66 | "[auto-conversion] Converting container, vorbis, manual attributes (0.49.1)\n"; | ||
| 67 | |||
| 68 | foreach my $title ( sort { $a->nr <=> $b->nr } | ||
| 69 | values %{ $project->content->titles } ) { | ||
| 70 | |||
| 71 | # convert 'ogg' codec to 'vorbis' (incl. bitrate setting) | ||
| 72 | foreach my $audio_track ( @{ $title->{tc_audio_tracks} } ) { | ||
| 73 | if ( $audio_track->{tc_audio_codec} eq 'ogg' ) { | ||
| 74 | $audio_track->{tc_audio_codec} = 'vorbis'; | ||
| 75 | } | ||
| 76 | my $ogg_bitrate = delete $audio_track->{tc_ogg_bitrate}; | ||
| 77 | $audio_track->{tc_vorbis_bitrate} = $ogg_bitrate | ||
| 78 | if $ogg_bitrate; | ||
| 79 | $audio_track->{tc_vorbis_quality} = 3.00; | ||
| 80 | $audio_track->{tc_vorbis_quality_enable} = 0; | ||
| 81 | } | ||
| 82 | |||
| 83 | # set samplerate to probed value | ||
| 84 | my $i = 0; | ||
| 85 | my $audio_info = $title->audio_tracks; | ||
| 86 | foreach my $audio ( @{ $title->{tc_audio_tracks} } ) { | ||
| 87 | ++$i, next if not defined $audio_info->[$i]; | ||
| 88 | $audio->{tc_vorbis_samplerate} = $audio_info->[$i]->sample_rate; | ||
| 89 | $audio->{tc_mp3_samplerate} = $audio_info->[$i]->sample_rate; | ||
| 90 | ++$i; | ||
| 91 | } | ||
| 92 | |||
| 93 | # set container attribute | ||
| 94 | my $container = $title->tc_video_codec =~ /S?VCD/ ? "vcd" : "avi"; | ||
| 95 | if ( $container eq 'avi' ) { | ||
| 96 | $container = "ogg" | ||
| 97 | if $title->get_first_audio_track >= 0 | ||
| 98 | and | ||
| 99 | $title->{tc_audio_tracks}->[ $title->get_first_audio_track ] | ||
| 100 | ->{tc_audio_codec} eq 'vorbis'; | ||
| 101 | } | ||
| 102 | |||
| 103 | $title->set_tc_container($container); | ||
| 104 | $title->set_tc_video_bitrate_manual(1); | ||
| 105 | |||
| 106 | } | ||
| 107 | |||
| 108 | 1; | ||
| 109 | } | ||
| 110 | |||
| 111 | sub convert_0_49_2 { | ||
| 112 | my $class = shift; | ||
| 113 | my %par = @_; | ||
| 114 | my ($project) = @par{'project'}; | ||
| 115 | |||
| 116 | |||
| 117 | "[auto-conversion] Converting title and audio attributes (0.49.2)\n"; | ||
| 118 | |||
| 119 | foreach my $title ( sort { $a->nr <=> $b->nr } | ||
| 120 | values %{ $project->content->titles } ) { | ||
| 121 | |||
| 122 | # 1. no probe_result object anymore | ||
| 123 | my $probe_result = delete $title->{probe_result}; | ||
| 124 | next if not defined $probe_result; | ||
| 125 | $title->set_width( $probe_result->{width} ); | ||
| 126 | $title->set_height( $probe_result->{height} ); | ||
| 127 | $title->set_aspect_ratio( $probe_result->{aspect_ratio} ); | ||
| 128 | $title->set_video_mode( $probe_result->{video_mode} ); | ||
| 129 | $title->set_letterboxed( $probe_result->{letterboxed} ); | ||
| 130 | $title->set_frames( $probe_result->{frames} ); | ||
| 131 | $title->set_runtime( $probe_result->{runtime} ); | ||
| 132 | $title->set_frame_rate( $probe_result->{frame_rate} ); | ||
| 133 | $title->set_chapters( $probe_result->{chapters} ); | ||
| 134 | $title->set_viewing_angles( $probe_result->{viewing_angles} ); | ||
| 135 | $title->set_dvd_probe_output( $probe_result->{probe_output} ); | ||
| 136 | $title->set_vob_probe_output( $probe_result->{audio_probe_output} ); | ||
| 137 | |||
| 138 | delete $title->{scan_result}; | ||
| 139 | |||
| 140 | # 2. no ProbeAudio object anymore, merged into Audio (tc_audio_tracks) | ||
| 141 | my $tc_audio_tracks = delete $title->{tc_audio_tracks}; | ||
| 142 | my $audio_tracks = $probe_result->audio_tracks; | ||
| 143 | |||
| 144 | my $i = 0; | ||
| 145 | foreach my $audio ( @{$tc_audio_tracks} ) { | ||
| 146 | $audio->set_type( $audio_tracks->[$i]->{type} ); | ||
| 147 | $audio->set_lang( $audio_tracks->[$i]->{lang} ); | ||
| 148 | $audio->set_channels( $audio_tracks->[$i]->{channels} ); | ||
| 149 | $audio->set_bitrate( $audio_tracks->[$i]->{bitrate} ); | ||
| 150 | $audio->set_sample_rate( $audio_tracks->[$i]->{sample_rate} ); | ||
| 151 | $audio->set_volume_rescale( | ||
| 152 | $audio_tracks->[$i]->{volume_rescale} ); | ||
| 153 | $audio->set_scan_output( | ||
| 154 | $audio_tracks->[$i]->{scan_result}->{scan_output} ); | ||
| 155 | delete $audio_tracks->[$i]->{scan_result}; | ||
| 156 | ++$i; | ||
| 157 | } | ||
| 158 | |||
| 159 | $title->set_audio_tracks($tc_audio_tracks); | ||
| 160 | |||
| 161 | $title->set_subtitles( {} ) if not $title->subtitles; | ||
| 162 | } | ||
| 163 | |||
| 164 | 1; | ||
| 165 | } | ||
| 166 | |||
| 167 | 1; |