r82002 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82001‎ | r82002 | r82003 >
Date:23:37, 11 February 2011
Author:dale
Status:deferred
Tags:
Comment:
added some debug msgs removed old .sql patch
Modified paths:
  • /trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php (modified) (history)
  • /trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscodeJob.php (modified) (history)
  • /trunk/extensions/TimedMediaHandler/WebVideoTranscode/patch-image-index.sql (deleted) (history)

Diff [purge]

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 @@
2121 public function __construct( $title, $params, $id = 0 ) {
2222 parent::__construct( 'webVideoTranscode', $title, $params, $id );
2323 }
 24+ // local function to debug output
 25+ private function output( $msg ){
 26+ print $msg . "\n";
 27+ }
2428 // Run the transcode request
2529 public function run() {
2630 // Get the file object
@@ -28,9 +32,10 @@
2933
3034 // Build the destination target
3135 $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'] );
3540 // Check the codec see which encode method to call;
3641 if( $options['codec'] == 'theora' ){
3742 $status = $this->ffmpeg2TheoraEncode( $file, $destinationFile, $options );
@@ -50,6 +55,12 @@
5156 $status = false;
5257 }
5358
 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+
5465 return $status;
5566 }
5667
@@ -59,6 +70,7 @@
6071 global $wgFFmpegLocation;
6172 // Get the source
6273 $source = $file->getFullPath();
 74+ $this->output( "Encode:\n source:$source\n target:$target\n" );
6375
6476 // Set up the base command
6577 $cmd = wfEscapeShellArg( $wgFFmpegLocation ) . ' ' . wfEscapeShellArg( $source );
@@ -72,13 +84,14 @@
7385 $cmd.= " -vpre libvpx-1080p";
7486 }
7587 }
76 -
 88+ $this->output( "novideo::$cmd" );
7789 if ( isset( $options['novideo'] ) ) {
7890 $cmd.= " -vn ";
7991 } else {
8092 $cmd.= $this->ffmpegAddVideoOptions( $file, $target, $options, $pass );
8193
8294 }
 95+ $this->output( "add starty optiosn$cmd" );
8396
8497 // Check for start time
8598 if( isset( $options['starttime'] ) ){
@@ -90,14 +103,14 @@
91104 if( isset( $options['endtime'] ) ){
92105 $cmd.= ' -t ' . intval( $options['endtime'] ) - intval($options['starttime'] ) ;
93106 }
 107+ $this->output( "add audio optiosn$cmd" );
94108
95 -
96109 if ( $pass == 1 || $options['noaudio'] ) {
97110 $cmd.= ' -an';
98111 } else {
99112 $cmd.= $this->ffmpegAddAudioOptions( $file, $target, $options, $pass );
100113 }
101 -
 114+ $this->output( "add webmn$cmd" );
102115 // Output WebM
103116 $cmd.=" -f webm";
104117
@@ -112,7 +125,7 @@
113126 $cmd.= $target;
114127 }
115128
116 - print "Running cmd: \n\n" .$cmd . "\n\n" ;
 129+ $this->output( "Running cmd: \n\n" .$cmd . "\n" );
117130
118131 wfProfileIn( 'ffmpeg_encode' );
119132 wfShellExec( $cmd, $retval );
@@ -233,26 +246,24 @@
234247
235248 // Set up the base command
236249 $cmd = wfEscapeShellArg( $wgffmpeg2theoraLocation ) . ' ' . wfEscapeShellArg( $source );
237 -
238250 // 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] ) ){
242254 $cmd.= ' '. implode(' ', WebVideoTranscode::$foggMap[$key] );
243255 }else if($val == 'true' || $val === true){
244 - $cmd.= ' '. WebVideoTranscode::$foggMap[$key];
 256+ $cmd.= ' '. self::$foggMap[$key];
245257 }else if( $val === false){
246258 //ignore "false" flags
247259 }else{
248260 //normal get/set value
249 - $cmd.= ' '. WebVideoTranscode::$foggMap[$key] . ' ' . wfEscapeShellArg( $val );
 261+ $cmd.= ' '. self::$foggMap[$key] . ' ' . wfEscapeShellArg( $val );
250262 }
251263 }
252 - }
253 - die( "run\n\n" . $cmd. "\n");
 264+ }
254265 // Add the output target:
255266 $cmd.= ' -o ' . wfEscapeShellArg ( $target );
256 - print "Running cmd: \n\n" .$cmd . "\n\n" ;
 267+ $this->output( "Running cmd: \n\n" .$cmd . "\n" );
257268
258269 wfProfileIn( 'ffmpeg2theora_encode' );
259270 wfShellExec( $cmd, $retval );
@@ -263,4 +274,49 @@
264275 }
265276 return true;
266277 }
 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+
267323 }
\ No newline at end of file
Index: trunk/extensions/TimedMediaHandler/WebVideoTranscode/WebVideoTranscode.php
@@ -105,52 +105,7 @@
106106 'noUpscaling' => 'true',
107107 'codec' => 'vp8',
108108 )
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+ );
155110 static public function getDerivativeFilePath($file, $transcodeKey){
156111 return dirname(
157112 $file->getThumbPath(

Status & tagging log