Difference between revisions of "Extension talk:VideoSectionLink"

From Organic Design wiki
(ffmpeg: this is exactly what we need :-))
(Special page: (later))
Line 46: Line 46:
 
</php>
 
</php>
  
== Special page ==
+
== Special page (later) ==
 
Later it could be good to have a special page which allows simple navigation of the video content to determine the exact start and finish times, and also as a means of creating a repository of video slices which could be then referred to by other sites that don't have the ability to refer to sections of video content.
 
Later it could be good to have a special page which allows simple navigation of the video content to determine the exact start and finish times, and also as a means of creating a repository of video slices which could be then referred to by other sites that don't have the ability to refer to sections of video content.
  

Revision as of 06:08, 31 October 2008

Parser function

We need a parser function so that links can be made using syntax such as the following:

{{#videosection:http://foo.bar/baz.avi|01:25:31|01:25:50}}

This would generate a link which when clicked downloads the specified segment of content from the specified video resource. Of course such a resource doesn't exist though, so the link is actually back to the wiki with action=videosection in the query string which will prompt the extension to generate the video section and return it to the client. The other parameters supplied in the parser-function should also be added to the query-string of the link.

Later we may add more parameters such as format and maybe embed - although embedding may be able to be achieved by using the existing video embedding extension with a VideoSectionLink URL as its source parameter.

Unknown action hook

The UnknownAction hook is used for executing code in response to new actions specified in the query string. An example of it's use is the PdfBook extension, it defines a callback method in its class called onUnknownAction and registers it with the hook in the classes' constructor.

This hook must construct an ffmpeg shell command from the query-string parameters and execute it, then pass the resulting binary or file back to the client. To pass the video data back to the client in such a way as to make it bring up the download dialog, use the following snippet. <php> $wgOut->disable(); header("Content-Type: video/mpeg"); header("Content-Disposition: attachment; filename=\"$name.mpeg\"");

  1. Use this if sending string content to client

print $content;

  1. or use this if sending content of a file back to the client

readfile($file); </php>

Caching (later)

Whenever a new clip is generated, it should be stored in the wiki's tmp directory (which is where it also stores cached math equations and resized images. Here's a snippet of code taken from Extension:Flashlets.php which is doing a similar task. It's creating a binary file of compiled actionscript which has a filename that's unique to the actionscript so that different actionscript produces a different filename. VideoSectionLink would create cache files a similar way except that the unique names should be generated from the shell command string instead, and the command being executed to generate the content is ffmpeg or similar instead of the mtasc compiler. <php>

  1. create swf filename unique to the actionscript content and parameters

$swf = md5("$actionscript$ver$width$height$fps"); $file = "$wgFlashletsDirectory/$swf"; $path = "$wgFlashletsPath/$swf.swf";

  1. Compile the SWF if it doesn't already exist

if (!file_exists("$file.swf")) {

# Write the actionscript to a file for MTASC to compile from if ($handle = fopen("$file.as", 'w+')) { fwrite($handle,$actionscript); fclose($handle); $cont = $this->container; $sh = "$wgFlashletsMTASC -cp $wgFlashletsCP -swf $cont -out $file.swf -main -version $ver -header $width:$height:$fps $file.as 2>&1"; $html = shell_exec($sh); unlink("$file.as"); } else $html = "Could not open '$file.as' for writing!"; } </php>

Special page (later)

Later it could be good to have a special page which allows simple navigation of the video content to determine the exact start and finish times, and also as a means of creating a repository of video slices which could be then referred to by other sites that don't have the ability to refer to sections of video content.

ffmpeg