Index: trunk/extensions/TimedMediaHandler/WebVideoTranscode/patch-image-index.sql |
— | — | @@ -1,14 +0,0 @@ |
2 | | -CREATE INDEX /*i*/image_media_type ON /*_*/image ( img_media_type ); |
3 | | - |
4 | | -CREATE INDEX /*i*/transcode_job_name ON /*_*/transcode_job ( tjob_name ); |
5 | | - |
6 | | -CREATE INDEX /*i*/transcode_job_state ON /*_*/transcode_job ( tjob_state ); |
\ No newline at end of file |
Index: trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscodeJob.php |
— | — | @@ -20,6 +20,10 @@ |
21 | 21 | public function __construct( $title, $params, $id = 0 ) { |
22 | 22 | parent::__construct( 'webVideoTranscode', $title, $params, $id ); |
23 | 23 | } |
| 24 | + // local function to debug output |
| 25 | + private function output( $msg ){ |
| 26 | + print $msg . "\n"; |
| 27 | + } |
24 | 28 | // Run the transcode request |
25 | 29 | public function run() { |
26 | 30 | // Get the file object |
— | — | @@ -28,9 +32,10 @@ |
29 | 33 | |
30 | 34 | // Build the destination target |
31 | 35 | $destinationFile = WebVideoTranscode::getTargetEncodePath( $file, $transcodeKey ); |
32 | | - |
33 | | - $options = WebVideoTranscode::$derivativeSettings[ $transcodeKey ]; |
34 | | - |
| 36 | + |
| 37 | + $options = WebVideoTranscode::$derivativeSettings[ $transcodeKey ]; |
| 38 | + |
| 39 | + $this->output( "Encoding to codec: " . $options['codec'] ); |
35 | 40 | // Check the codec see which encode method to call; |
36 | 41 | if( $options['codec'] == 'theora' ){ |
37 | 42 | $status = $this->ffmpeg2TheoraEncode( $file, $destinationFile, $options ); |
— | — | @@ -50,6 +55,12 @@ |
51 | 56 | $status = false; |
52 | 57 | } |
53 | 58 | |
| 59 | + // If status is oky move the file to its final destination. ( timedMediaHandler will look for it there ) |
| 60 | + // XXX would be nice to clear the cache for the pages where the title in use |
| 61 | + if( $status ){ |
| 62 | + $status = @rename($destinationFile, WebVideoTranscode::getDerivativeFilePath( $file, $transcodeKey) ); |
| 63 | + } |
| 64 | + |
54 | 65 | return $status; |
55 | 66 | } |
56 | 67 | |
— | — | @@ -59,6 +70,7 @@ |
60 | 71 | global $wgFFmpegLocation; |
61 | 72 | // Get the source |
62 | 73 | $source = $file->getFullPath(); |
| 74 | + $this->output( "Encode:\n source:$source\n target:$target\n" ); |
63 | 75 | |
64 | 76 | // Set up the base command |
65 | 77 | $cmd = wfEscapeShellArg( $wgFFmpegLocation ) . ' ' . wfEscapeShellArg( $source ); |
— | — | @@ -72,13 +84,14 @@ |
73 | 85 | $cmd.= " -vpre libvpx-1080p"; |
74 | 86 | } |
75 | 87 | } |
76 | | - |
| 88 | + $this->output( "novideo::$cmd" ); |
77 | 89 | if ( isset( $options['novideo'] ) ) { |
78 | 90 | $cmd.= " -vn "; |
79 | 91 | } else { |
80 | 92 | $cmd.= $this->ffmpegAddVideoOptions( $file, $target, $options, $pass ); |
81 | 93 | |
82 | 94 | } |
| 95 | + $this->output( "add starty optiosn$cmd" ); |
83 | 96 | |
84 | 97 | // Check for start time |
85 | 98 | if( isset( $options['starttime'] ) ){ |
— | — | @@ -90,14 +103,14 @@ |
91 | 104 | if( isset( $options['endtime'] ) ){ |
92 | 105 | $cmd.= ' -t ' . intval( $options['endtime'] ) - intval($options['starttime'] ) ; |
93 | 106 | } |
| 107 | + $this->output( "add audio optiosn$cmd" ); |
94 | 108 | |
95 | | - |
96 | 109 | if ( $pass == 1 || $options['noaudio'] ) { |
97 | 110 | $cmd.= ' -an'; |
98 | 111 | } else { |
99 | 112 | $cmd.= $this->ffmpegAddAudioOptions( $file, $target, $options, $pass ); |
100 | 113 | } |
101 | | - |
| 114 | + $this->output( "add webmn$cmd" ); |
102 | 115 | // Output WebM |
103 | 116 | $cmd.=" -f webm"; |
104 | 117 | |
— | — | @@ -112,7 +125,7 @@ |
113 | 126 | $cmd.= $target; |
114 | 127 | } |
115 | 128 | |
116 | | - print "Running cmd: \n\n" .$cmd . "\n\n" ; |
| 129 | + $this->output( "Running cmd: \n\n" .$cmd . "\n" ); |
117 | 130 | |
118 | 131 | wfProfileIn( 'ffmpeg_encode' ); |
119 | 132 | wfShellExec( $cmd, $retval ); |
— | — | @@ -233,26 +246,24 @@ |
234 | 247 | |
235 | 248 | // Set up the base command |
236 | 249 | $cmd = wfEscapeShellArg( $wgffmpeg2theoraLocation ) . ' ' . wfEscapeShellArg( $source ); |
237 | | - |
238 | 250 | // Add in the encode settings |
239 | | - foreach( $options as $key => $val){ |
240 | | - if( isset( WebVideoTranscode::$foggMap[$key] ) ){ |
241 | | - if( is_array( WebVideoTranscode::$foggMap[$key] ) ){ |
| 251 | + foreach( $options as $key => $val ){ |
| 252 | + if( isset( self::$foggMap[$key] ) ){ |
| 253 | + if( is_array( self::$foggMap[$key] ) ){ |
242 | 254 | $cmd.= ' '. implode(' ', WebVideoTranscode::$foggMap[$key] ); |
243 | 255 | }else if($val == 'true' || $val === true){ |
244 | | - $cmd.= ' '. WebVideoTranscode::$foggMap[$key]; |
| 256 | + $cmd.= ' '. self::$foggMap[$key]; |
245 | 257 | }else if( $val === false){ |
246 | 258 | //ignore "false" flags |
247 | 259 | }else{ |
248 | 260 | //normal get/set value |
249 | | - $cmd.= ' '. WebVideoTranscode::$foggMap[$key] . ' ' . wfEscapeShellArg( $val ); |
| 261 | + $cmd.= ' '. self::$foggMap[$key] . ' ' . wfEscapeShellArg( $val ); |
250 | 262 | } |
251 | 263 | } |
252 | | - } |
253 | | - die( "run\n\n" . $cmd. "\n"); |
| 264 | + } |
254 | 265 | // Add the output target: |
255 | 266 | $cmd.= ' -o ' . wfEscapeShellArg ( $target ); |
256 | | - print "Running cmd: \n\n" .$cmd . "\n\n" ; |
| 267 | + $this->output( "Running cmd: \n\n" .$cmd . "\n" ); |
257 | 268 | |
258 | 269 | wfProfileIn( 'ffmpeg2theora_encode' ); |
259 | 270 | wfShellExec( $cmd, $retval ); |
— | — | @@ -263,4 +274,49 @@ |
264 | 275 | } |
265 | 276 | return true; |
266 | 277 | } |
| 278 | + /** |
| 279 | + * Mapping between firefogg api and ffmpeg2theora command line |
| 280 | + * |
| 281 | + * This lets us share a common api between firefogg and WebVideoTranscode |
| 282 | + * also see: http://firefogg.org/dev/index.html |
| 283 | + */ |
| 284 | + public static $foggMap = array( |
| 285 | + // video |
| 286 | + 'width' => "--width", |
| 287 | + 'height' => "--height", |
| 288 | + 'maxSize' => "--max_size", |
| 289 | + 'noUpscaling' => "--no-upscaling", |
| 290 | + 'videoQuality'=> "-v", |
| 291 | + 'videoBitrate' => "-V", |
| 292 | + 'twopass' => "--two-pass", |
| 293 | + 'framerate' => "-F", |
| 294 | + 'aspect' => "--aspect", |
| 295 | + 'starttime' => "--starttime", |
| 296 | + 'endtime' => "--endtime", |
| 297 | + 'cropTop' => "--croptop", |
| 298 | + 'cropBottom' => "--cropbottom", |
| 299 | + 'cropLeft' => "--cropleft", |
| 300 | + 'cropRight' => "--cropright", |
| 301 | + 'keyframeInterval'=> "--key", |
| 302 | + 'denoise' => array("--pp", "de"), |
| 303 | + 'deinterlace' => "--deinterlace", |
| 304 | + 'novideo' => array("--novideo", "--no-skeleton"), |
| 305 | + 'bufDelay' => "--buf-delay", |
| 306 | + // audio |
| 307 | + 'audioQuality' => "-a", |
| 308 | + 'audioBitrate' => "-A", |
| 309 | + 'samplerate' => "-H", |
| 310 | + 'channels' => "-c", |
| 311 | + 'noaudio' => "--noaudio", |
| 312 | + // metadata |
| 313 | + 'artist' => "--artist", |
| 314 | + 'title' => "--title", |
| 315 | + 'date' => "--date", |
| 316 | + 'location' => "--location", |
| 317 | + 'organization' => "--organization", |
| 318 | + 'copyright' => "--copyright", |
| 319 | + 'license' => "--license", |
| 320 | + 'contact' => "--contact" |
| 321 | + ); |
| 322 | + |
267 | 323 | } |
\ No newline at end of file |
Index: trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php |
— | — | @@ -105,52 +105,7 @@ |
106 | 106 | 'noUpscaling' => 'true', |
107 | 107 | 'codec' => 'vp8', |
108 | 108 | ) |
109 | | - ); |
110 | | - /** |
111 | | - * Mapping between firefogg api and ffmpeg2theora command line |
112 | | - * |
113 | | - * This lets us share a common api between firefogg and WebVideoTranscode |
114 | | - * also see: http://firefogg.org/dev/index.html |
115 | | - */ |
116 | | - public static $foggMap = array( |
117 | | - // video |
118 | | - 'width' => "--width", |
119 | | - 'height' => "--height", |
120 | | - 'maxSize' => "--max_size", |
121 | | - 'noUpscaling' => "--no-upscaling", |
122 | | - 'videoQuality'=> "-v", |
123 | | - 'videoBitrate' => "-V", |
124 | | - 'twopass' => "--two-pass", |
125 | | - 'framerate' => "-F", |
126 | | - 'aspect' => "--aspect", |
127 | | - 'starttime' => "--starttime", |
128 | | - 'endtime' => "--endtime", |
129 | | - 'cropTop' => "--croptop", |
130 | | - 'cropBottom' => "--cropbottom", |
131 | | - 'cropLeft' => "--cropleft", |
132 | | - 'cropRight' => "--cropright", |
133 | | - 'keyframeInterval'=> "--key", |
134 | | - 'denoise' => array("--pp", "de"), |
135 | | - 'deinterlace' => "--deinterlace", |
136 | | - 'novideo' => array("--novideo", "--no-skeleton"), |
137 | | - 'bufDelay' => "--buf-delay", |
138 | | - // audio |
139 | | - 'audioQuality' => "-a", |
140 | | - 'audioBitrate' => "-A", |
141 | | - 'samplerate' => "-H", |
142 | | - 'channels' => "-c", |
143 | | - 'noaudio' => "--noaudio", |
144 | | - // metadata |
145 | | - 'artist' => "--artist", |
146 | | - 'title' => "--title", |
147 | | - 'date' => "--date", |
148 | | - 'location' => "--location", |
149 | | - 'organization' => "--organization", |
150 | | - 'copyright' => "--copyright", |
151 | | - 'license' => "--license", |
152 | | - 'contact' => "--contact" |
153 | | - ); |
154 | | - |
| 109 | + ); |
155 | 110 | static public function getDerivativeFilePath($file, $transcodeKey){ |
156 | 111 | return dirname( |
157 | 112 | $file->getThumbPath( |