r44253 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44252‎ | r44253 | r44254 >
Date:17:15, 5 December 2008
Author:dale
Status:deferred
Tags:
Comment:
maintenance scripts update
Modified paths:
  • /trunk/extensions/MetavidWiki/maintenance/mv_oneTime_fixes.php (modified) (history)
  • /trunk/extensions/MetavidWiki/maintenance/transcode_to_flv.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/maintenance/transcode_to_flv.php
@@ -25,6 +25,29 @@
2626 //mencoder based (good)
2727 $flvEncodeCommand = 'mencoder $input -noskip -mc 0 -o $output -of lavf -oac mp3lame -lameopts abr:br=32 -ovc lavc -lavcopts vcodec=flv:vbitrate=250:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=400:300 -srate 22050 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames';
2828
 29+if ( count( $args ) == 0 || isset ( $options['help'] ) ) {
 30+ print<<<EOT
 31+Run transcode for HQ oggs
 32+from dir: $mvMountedSource *.HQ.ogg
 33+to dir: $mvMountedDest *.flv
 34+
 35+default:
 36+ only gennerates flvs where the ogg exists and a flv is missing
 37+
 38+arguments:
 39+ generate_new_flv // used if you do a new set flv encode (will remove old flv in place)
 40+
 41+
 42+EOT;
 43+ exit ();
 44+}
 45+$genNewFlv = false;
 46+switch ( $args[0] ) {
 47+ case 'generate_new_flv' :
 48+ $genNewFlv = true;
 49+ break;
 50+}
 51+
2952 $doneWithTrascode=false;
3053 while($doneWithTrascode==false){
3154 $doneWithTrascode=true;
@@ -47,7 +70,11 @@
4871 if(substr($source_file, -7)=='.HQ.ogg'){
4972 //gennerate flash file name:
5073 $stream_name = substr( $source_file,0,(strlen($source_file)-7));
51 - $local_fl =$mvMountedDest . $stream_name . '.new.flv';
 74+ if($genNewFlv){
 75+ $local_fl =$mvMountedDest . $stream_name . '.new.flv';
 76+ }else{
 77+ $local_fl =$mvMountedDest . $stream_name . '.flv';
 78+ }
5279 clearstatcache();
5380 if(!is_file($local_fl)){
5481 $doneWithTrascode=false;
@@ -85,20 +112,20 @@
86113 //update db:
87114 update_flv_pointer_db($stream_name);
88115 //remove the old local_file:
89 - unlink($mvMountedDest . $stream_name . '.flv');
90 - unlink($mvMountedDest . $stream_name . '.flv'.META_DATA_EXT);
91 - //move file to "live" location
92 - rename($local_fl, $mvMountedDest . $stream_name . '.flv');
93 - rename($local_fl.META_DATA_EXT, $mvMountedDest . $stream_name . '.flv'.META_DATA_EXT);
94 - //keep an empty file in place of .new (so we don't re-do this same stream)
95 - file_put_contents($local_fl, ' -async 2 done ');
96 - file_put_contents($local_fl.META_DATA_EXT, ' -async 2 meta done ');
97 - //print "put zeor size file_contents";
98 -
 116+ if($genNewFlv){
 117+ unlink($mvMountedDest . $stream_name . '.flv');
 118+ unlink($mvMountedDest . $stream_name . '.flv'.META_DATA_EXT);
 119+ //move file to "live" location
 120+ rename($local_fl, $mvMountedDest . $stream_name . '.flv');
 121+ rename($local_fl.META_DATA_EXT, $mvMountedDest . $stream_name . '.flv'.META_DATA_EXT);
 122+ //keep an empty file in place of .new (so we don't re-do this same stream)
 123+ file_put_contents($local_fl, ' -async 2 done ');
 124+ file_put_contents($local_fl.META_DATA_EXT, ' -async 2 meta done ');
 125+ } //
99126 break; //break out of forloop
100127 }
101128 }else{
102 - print "skiped HQ_File: {$mvMountedSource}{$source_file} \n";
 129+ print "skipped HQ_File: {$source_file} (local .flv file already exists) \n";
103130 }
104131 }
105132 }
Index: trunk/extensions/MetavidWiki/maintenance/mv_oneTime_fixes.php
@@ -17,6 +17,7 @@
1818 strip_speech_by //strips extra speech by text
1919 update_stream_desc //updates stream desc
2020 update_archive_org_files [stream_name] //updates pointers to archive.org mp4 streaming
 21+ update_flv_meta //gennerates meta data for all .flv files in /metavid/video_archive
2122
2223 EOT;
2324 exit ();
@@ -33,6 +34,9 @@
3435 case 'update_stream_desc':
3536 update_stream_desc();
3637 break;
 38+ case 'update_flv_meta':
 39+ update_flv_meta();
 40+ break;
3741 case 'update_archive_org_files':
3842 $stream_name = (isset( $args[1] ))?$args[1]:'';
3943 run_archive_org_update( $stream_name );
@@ -73,7 +77,29 @@
7478 }
7579 }
7680 }
77 -
 81+function update_flv_meta(){
 82+ $path = '/metavid/video_archive/';
 83+ $flist = scandir($path);
 84+ require_once('../skins/mv_embed/flvServer/MvFlv.php');
 85+ foreach($flist as $local_fl){
 86+ print "lf: is_file(" . $path . $local_fl . ")\n";
 87+ if( is_file($path.$local_fl) && substr($local_fl, -3)=='flv'){
 88+ //check for .meta
 89+
 90+ if(!is_file($path . $local_fl .'.meta')){
 91+ echo "generating flv metadata for {$path}{$local_fl} \n";
 92+ $flv = new MyFLV();
 93+ try {
 94+ $flv->open( $path . $local_fl );
 95+ } catch (Exception $e) {
 96+ die("<pre>The following exception was detected while trying to open a FLV file:\n" . $e->getMessage() . "</pre>");
 97+ }
 98+ $flv->getMetaData();
 99+ echo "done with .meta (" . filesize($path.$local_fl.META_DATA_EXT).") \n";
 100+ }
 101+ }
 102+ }
 103+}
78104 function update_stream_desc(){
79105 /*==Official Record==
80106 *[[GovTrack]] Congressional Record[http://www.govtrack.us/congress/recordindex.xpd?date=20080609&where=h]

Status & tagging log