r96873 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96872‎ | r96873 | r96874 >
Date:17:50, 12 September 2011
Author:j
Status:ok (Comments)
Tags:
Comment:
work around ffmpeg seeking issues in ogg files
Modified paths:
  • /trunk/extensions/TimedMediaHandler/TimedMediaThumbnail.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TimedMediaHandler/TimedMediaThumbnail.php
@@ -20,8 +20,15 @@
2121
2222 $cmd = wfEscapeShellArg( $wgFFmpegLocation );
2323
24 - $cmd .= ' -ss ' . intval( self::getThumbTime( $options ) );
 24+ $offset = intval( self::getThumbTime( $options ) );
 25+ //seek 2 seconds before offset and seek in decoded stream,
 26+ //works around
 27+ if($offset > 2) {
 28+ $cmd .= ' -ss ' . ($offset - 2);
 29+ $offset = 2;
 30+ }
2531 $cmd .= ' -i ' . wfEscapeShellArg( $options['file']->getPath() );
 32+ $cmd .= ' -ss ' . $offset . ' ';
2633 // Set the output size if set in options:
2734 if( isset( $options['width'] ) && isset( $options['height'] ) ){
2835 $cmd.= ' -s '. intval( $options['width'] ) . 'x' . intval( $options['height'] );

Follow-up revisions

RevisionCommit summaryAuthorDate
r96875better comment for seek workaroundj17:55, 12 September 2011

Comments

#Comment by Raindrift (talk | contribs)   23:33, 21 September 2011

Does this make sense even when the keyframe interval is greater than 48 (for 24fps video) or 60 (for 30fps)? It's not uncommon to see videos with a keyframe every 240 p-frames or more. I'm not familiar enough with the code yet to know what video metadata is available, but if you know the keyframe interval and framerate, it might make sense to use them here. If not, maybe it doesn't really matter... thumbnailing doesn't have to be too precise, right?  :)

#Comment by Mdale (talk | contribs)   16:02, 27 September 2011

ffmpeg has a bug and the use of double -ss offsets helps work around this bug by seeking a few seconds before then decoding forward to get the actual thumbnail.

Status & tagging log