|
1 | | -#!/usr/bin/perl -w |
2 | 1 | # |
3 | | -# $Date$ |
4 | | -# $Revision$ |
5 | | -# $Author$ |
| 2 | +# ffmpeg-based XviD export module for nuvexport. |
6 | 3 | # |
7 | | -# export::ffmpeg::XviD |
8 | | -# Maintained by Chris Petersen <mythtv@forevermore.net> |
| 4 | +# @url $URL$ |
| 5 | +# @date $Date$ |
| 6 | +# @version $Revision$ |
| 7 | +# @author $Author$ |
| 8 | +# @copyright Silicon Mechanics |
9 | 9 | # |
10 | 10 |
|
11 | 11 | package export::ffmpeg::XviD; |
@@ -61,6 +61,9 @@ package export::ffmpeg::XviD; |
61 | 61 | push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to xvid.\n" |
62 | 62 | ." (It must be compiled with the --enable-xvid option)"; |
63 | 63 | } |
| 64 | + if (!$self->can_encode('mp3')) { |
| 65 | + push @{$self->{'errors'}}, "Your ffmpeg installation doesn't support encoding to mp3 audio."; |
| 66 | + } |
64 | 67 |
|
65 | 68 | # Any errors? disable this function |
66 | 69 | $self->{'enabled'} = 0 if ($self->{'errors'} && @{$self->{'errors'}} > 0); |
@@ -131,59 +134,50 @@ package export::ffmpeg::XviD; |
131 | 134 | my $episode = shift; |
132 | 135 | # Make sure we have the framerate |
133 | 136 | $self->{'out_fps'} = $episode->{'finfo'}{'fps'}; |
| 137 | + # Embed the title |
| 138 | + my $safe_title = shell_escape($episode->{'show_name'}.' - '.$episode->{'title'}); |
| 139 | + # Build the common ffmpeg string |
| 140 | + my $ffmpeg_xtra = ' -vcodec xvid' |
| 141 | + .' -b '.$self->{'v_bitrate'} |
| 142 | + .($self->{'vbr'} |
| 143 | + ? ' -bt 32 -minrate 32 -maxrate '.(2*$self->{'v_bitrate'}) |
| 144 | + .' -bufsize 65535' |
| 145 | + : '') |
| 146 | + .' -flags +4mv+trell+loop' |
| 147 | + .' -aic 1' |
| 148 | + .' -mbd 1' |
| 149 | + .' -cmp 2 -subcmp 2' |
| 150 | + .' -cgop 1' |
| 151 | + .' -max_b_frames 1' |
| 152 | + .' -b_quant_factor 150' |
| 153 | + .' -b_quant_offset 100' |
| 154 | + ; |
134 | 155 | # Dual pass? |
135 | 156 | if ($self->{'multipass'}) { |
136 | 157 | # Add the temporary file to the list |
137 | 158 | push @tmpfiles, "/tmp/xvid.$$.log"; |
138 | | - # Back up the path and use /dev/null for the first pass |
139 | | - my $path_bak = $self->{'path'}; |
140 | | - $self->{'path'} = '/dev/null'; |
141 | 159 | # First pass |
142 | 160 | print "First pass...\n"; |
143 | | - $self->{'ffmpeg_xtra'} = ' -vcodec xvid' |
144 | | - . ' -b ' . $self->{'v_bitrate'} |
145 | | - . ' -minrate 32 -maxrate '.(2*$self->{'v_bitrate'}).' -bt 32' |
146 | | - . ' -bufsize 65535' |
147 | | - . ' -lumi_mask 0.05 -dark_mask 0.02 -scplx_mask 0.5' |
148 | | - . ($self->{'ffmpeg_vers'} =~ /cvs|svn/ ? ' -mv4' : ' -4mv') |
149 | | - . ' -part' |
150 | | - . " -pass 1 -passlogfile '/tmp/xvid.$$.log'" |
151 | | - . ' -f avi'; |
152 | | - $self->SUPER::export($episode, ''); |
153 | | - # Restore the path |
154 | | - $self->{'path'} = $path_bak; |
| 161 | + $self->{'ffmpeg_xtra'} = $ffmpeg_xtra |
| 162 | + ." -pass 1 -passlogfile '/tmp/xvid.$$.log'" |
| 163 | + .' -f avi'; |
| 164 | + $self->SUPER::export($episode, '', 1); |
155 | 165 | # Second pass |
156 | 166 | print "Final pass...\n"; |
157 | | - $self->{'ffmpeg_xtra'} = ' -vcodec xvid' |
158 | | - . ' -b ' . $self->{'v_bitrate'} |
159 | | - . ' -minrate 32 -maxrate '.(2*$self->{'v_bitrate'}).' -bt 32' |
160 | | - . ' -bufsize 65535' |
161 | | - . ' -lumi_mask 0.05 -dark_mask 0.02 -scplx_mask 0.5' |
162 | | - . ($self->{'ffmpeg_vers'} =~ /cvs|svn/ ? ' -mv4' : ' -4mv') |
163 | | - . ' -part' |
164 | | - . ' -acodec mp3' |
165 | | - . ' -ab ' . $self->{'a_bitrate'} |
166 | | - . " -pass 2 -passlogfile '/tmp/xvid.$$.log'" |
167 | | - . ' -f avi'; |
| 167 | + $self->{'ffmpeg_xtra'} = $ffmpeg_xtra |
| 168 | + . " -pass 2 -passlogfile '/tmp/xvid.$$.log'"; |
168 | 169 | } |
169 | 170 | # Single Pass |
170 | 171 | else { |
171 | | - $self->{'ffmpeg_xtra'} = ' -vcodec xvid' |
172 | | - . ' -b ' . $self->{'v_bitrate'} |
173 | | - . (($self->{'vbr'}) |
174 | | - ? " -qmin $self->{'quantisation'}" |
175 | | - . ' -qmax 31 -minrate 32' |
176 | | - . ' -maxrate '.(2*$self->{'v_bitrate'}) |
177 | | - . ' -bt 32' |
178 | | - . ' -bufsize 65535' |
179 | | - : '') |
180 | | - . ' -lumi_mask 0.05 -dark_mask 0.02 -scplx_mask 0.5' |
181 | | - . ($self->{'ffmpeg_vers'} =~ /cvs|svn/ ? ' -mv4' : ' -4mv') |
182 | | - . ' -part' |
183 | | - . ' -acodec mp3' |
184 | | - . ' -ab ' . $self->{'a_bitrate'} |
185 | | - . ' -f avi'; |
| 172 | + $self->{'ffmpeg_xtra'} = $ffmpeg_xtra |
| 173 | + .($self->{'vbr'} |
| 174 | + ? ' -qmax 31 -qmin '.$self->{'quantisation'} |
| 175 | + : ''); |
186 | 176 | } |
| 177 | + # Don't forget the audio, etc. |
| 178 | + $self->{'ffmpeg_xtra'} .= ' -acodec mp3 -async 1' |
| 179 | + .' -ab '.$self->{'a_bitrate'} |
| 180 | + .' -f avi'; |
187 | 181 | # Execute the (final pass) encode |
188 | 182 | $self->SUPER::export($episode, '.avi'); |
189 | 183 | } |
|
0 commit comments