Brion VIBBER has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/380886 )
Change subject: [WIP] QuickTime MJPEG/MP3 240p video fallback for iOS ...................................................................... [WIP] QuickTime MJPEG/MP3 240p video fallback for iOS Still testing this, based on old abandonded patch. As a stopgap until the frontend video rewrite is done, produce video transcodes at low resolution in a format that iOS understands that should be free of patent issues. QuickTime (.mov) container with MJPEG video (no known patents) and MP3 audio (patents expired). iOS and Mac OS understand such files and will play them back in a <video> element in Safari, but video quality is bad and bitrate is high because MJPEG has no interframe compression. Desktop view will get the ogv.js shim along with the rest of the player frontend, so this MJPEG file is only exposed in these situations: * mobile view * JS disabled * HTML-scraping with the JS removed Bug: T101716 Change-Id: I15b971d47bf8862524e3306615cfbc366e6d8116 --- M TimedMediaHandler.php M WebVideoTranscode/WebVideoTranscode.php M WebVideoTranscode/WebVideoTranscodeJob.php M i18n/en.json 4 files changed, 63 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler refs/changes/86/380886/1 diff --git a/TimedMediaHandler.php b/TimedMediaHandler.php index 0cade78..3804eda 100644 --- a/TimedMediaHandler.php +++ b/TimedMediaHandler.php @@ -216,6 +216,9 @@ // A 4K high quality stream; higher end phones, tablets, smart tvs WebVideoTranscode::ENC_H264_2160P, */ + + // Last-ditch fallback for iOS; low visual quality. + WebVideoTranscode::ENC_MJPEG_240P, ]; $wgEnabledAudioTranscodeSet = [ diff --git a/WebVideoTranscode/WebVideoTranscode.php b/WebVideoTranscode/WebVideoTranscode.php index b444c08..768669b 100644 --- a/WebVideoTranscode/WebVideoTranscode.php +++ b/WebVideoTranscode/WebVideoTranscode.php @@ -64,6 +64,9 @@ const ENC_H264_1440P = '1440p.mp4'; const ENC_H264_2160P = '2160p.mp4'; + // mjpeg+mp3 QuickTime profile for iOS + const ENC_MJPEG_240P = '240p.mov'; + const ENC_OGG_VORBIS = 'ogg'; const ENC_OGG_OPUS = 'opus'; const ENC_MP3 = 'mp3'; @@ -478,6 +481,20 @@ 'type' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', ], + // MJPEG/MP3 profile for iOS last-ditch fallback + // Won't look good, but plays. :D + self::ENC_MJPEG_240P => + [ + 'maxSize' => '426x240', + 'videoBitrate' => '1536', + 'framerate' => '15', + 'samplerate' => '44010', + 'bufDelay' => '256', + 'videoCodec' => 'mjpeg', + 'audioCodec' => 'pcm_mulaw', + 'type' => 'video/quicktime; codecs="jpeg, mp3"', + ], + // Audio profiles self::ENC_OGG_VORBIS => [ diff --git a/WebVideoTranscode/WebVideoTranscodeJob.php b/WebVideoTranscode/WebVideoTranscodeJob.php index cec23b2..ebbaa12 100644 --- a/WebVideoTranscode/WebVideoTranscodeJob.php +++ b/WebVideoTranscode/WebVideoTranscodeJob.php @@ -199,7 +199,8 @@ $status = $this->ffmpeg2TheoraEncode( $options ); } elseif ( $options['videoCodec'] == 'vp8' || $options['videoCodec'] == 'vp9' || $options['videoCodec'] == 'h264' || - ( $options['videoCodec'] == 'theora' && $wgFFmpeg2theoraLocation === false ) + ( $options['videoCodec'] == 'theora' && $wgFFmpeg2theoraLocation === false ) || + $options['videoCodec'] == 'mjpeg' ) { // Check for twopass: if ( isset( $options['twopass'] ) ) { @@ -384,6 +385,8 @@ $cmd .= $this->ffmpegAddH264VideoOptions( $options, $pass ); } elseif ( $options['videoCodec'] == 'theora' ) { $cmd .= $this->ffmpegAddTheoraVideoOptions( $options, $pass ); + } elseif ( $options['videoCodec'] == 'mjpeg' ) { + $cmd .= $this->ffmpegAddMJPEGVideoOptions( $options, $pass ); } // Add size options: $cmd .= $this->ffmpegAddVideoSizeOptions( $options ); @@ -631,6 +634,43 @@ } /** + * Adds ffmpeg shell options for MJPEG MOV + * + * @param array $options + * @param string $pass + * @return string + */ + function ffmpegAddMJPEGVideoOptions( $options, $pass ) { + global $wgFFmpegThreads; + + // Get a local pointer to the file object + $file = $this->getFile(); + + $cmd = ' -threads ' . intval( $wgFFmpegThreads ); + + // Check for video bitrate: + if ( isset( $options['videoBitrate'] ) ) { + $cmd .= " -qmin 2 -qmax 31"; + $cmd .= " -vb " . wfEscapeShellArg( $options['videoBitrate'] * 1000 ); + } + // Set the codec: + $cmd .= " -vcodec mjpeg"; + + if( isset( $options['deinterlace'] ) ){ + $cmd .= ' -deinterlace'; + } + + if( isset( $options['framerate'] ) ) { + $cmd .= ' -r ' . wfEscapeShellArg( $options['framerate'] ); + } + + // Output QuickTime MOV container + $cmd .= " -f mov -movflags faststart"; // no -movflags on avconv in Ubuntu 14.04 + + return $cmd; + } + + /** * @param array $options * @param int $pass * @return string diff --git a/i18n/en.json b/i18n/en.json index e99e71b..d30555b 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -110,6 +110,8 @@ "timedmedia-derivative-desc-1440p.vp9.webm": "UHD VP9 (1440P)", "timedmedia-derivative-2160p.vp9.webm": "VP9 2160P", "timedmedia-derivative-desc-2160p.vp9.webm": "4K UHD VP9 (2160P)", + "timedmedia-derivative-240p.mov": "MJPEG 240P", + "timedmedia-derivative-desc-240p.mov": "Low-quality MJPEG video (240P)", "timedmedia-derivative-160p.mp4": "H264 160P", "timedmedia-derivative-desc-160p.mp4": "Low bandwidth MP4 H.264 (160P)", "timedmedia-derivative-240p.mp4": "H264 240P", -- To view, visit https://gerrit.wikimedia.org/r/380886 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I15b971d47bf8862524e3306615cfbc366e6d8116 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: master Gerrit-Owner: Brion VIBBER <br...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits