heck yeah fallbacks working

This commit is contained in:
Brooke Vibber 2023-03-27 14:41:21 -07:00
parent 02c01d60cf
commit 16420f12d4
4 changed files with 116 additions and 28 deletions

View file

@ -768,7 +768,7 @@ $target = 10;
$ext = substr( $filename, strrpos( $filename, '.' ) ); $ext = substr( $filename, strrpos( $filename, '.' ) );
if ( $ext === '.mp3' ) { if ( $ext === '.mp3' ) {
$segments = extractMP3( $filename ); $segments = extractMP3( $filename );
} elseif ( $ext === '.mp4' ) { } elseif ( $ext === '.mp4' || $ext === '.mov' || $ext === '.3gp' ) {
$segments = extractFragmentedMP4( $filename ); $segments = extractFragmentedMP4( $filename );
} else { } else {
die( "Unexpected file extension $ext\n" ); die( "Unexpected file extension $ext\n" );

View file

@ -10,39 +10,70 @@
<h2>Caminandes - Llamigos</h2> <h2>Caminandes - Llamigos</h2>
<p>WebM VP9 and VP8 in front, HLS with VP9-in-MP4 video with Opus-in-MP4 or AAC audio behind.</p> <h3>Full fallbacks</h3>
<p>WebM VP9 and VP8 in front, HLS with VP9/MJPEG video and Opus/MP3 audio behind.</p>
<video controls width=640 height=360> <video controls width=640 height=360>
<source type="video/webm; codecs=&quot;vp9, opus&quot;" src=new-vp9.webm> <source type="video/webm; codecs=&quot;vp9, opus&quot;" src=new-vp9.webm>
<source type="video/webm; codecs=&quot;vp8, vorbis&quot;" src=new-vp8.webm> <source type="video/webm; codecs=&quot;vp8, vorbis&quot;" src=new-vp8.webm>
<source type=application/vnd.apple.mpegurl src=fmp4.vp9.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.vp9-mjpeg.mov.m3u8>
</video> </video>
<p>HLS VP9+Opus or VP9+MP3, no fallbacks:</p> <h3>Single video codecs</h3>
<p>HLS VP9 + Opus/MP3:</p>
<video controls width=640 height=360> <video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.vp9.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.vp9.m3u8>
</video> </video>
<p>HLS MPEG-4 Visual+Opus or MPEG-4 Visual+MP3:</p> <p>HLS Motion-JPEG.mov + Opus/MP3:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.mjpeg.mov.m3u8>
</video>
<p>HLS H.263.3gp + Opus/MP3:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.h263.3gp.m3u8>
</video>
<p>HLS H.263.mov + Opus/MP3:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.h263.mov.m3u8>
</video>
<p>HLS MPEG-4 Visual + Opus/MP3:</p>
<video controls width=640 height=360> <video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.mpeg4.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.mpeg4.m3u8>
</video> </video>
<p>HLS MPEG-4 Visual+MP3:</p> <p>HLS H.264 + Opus/MP3:</p>
<video controls width=640 height=360> <video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.mpeg4-mp3.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.h264.m3u8>
</video> </video>
<p>HLS MPEG-4 Visual+AAC:</p> <h3>VP9 + Single fallback</h3>
<p>HLS VP9/MJPEG.mov with Opus/MP3:</p>
<video controls width=640 height=360> <video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.mpeg4-aac.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.vp9-mjpeg.mov.m3u8>
</video> </video>
<p>HLS VP9+Opus or VP9+MP3, with MPEG-4 Visual fallback:</p> <p>HLS VP9/H.263.3gp with Opus/MP3:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.vp9-h263.3gp.m3u8>
</video>
<p>HLS VP9/H.263.mov with Opus/MP3:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.vp9-h263.mov.m3u8>
</video>
<p>HLS VP9/MPEG-4 Visual with Opus/MP3:</p>
<video controls width=640 height=360> <video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.vp9-mpeg4.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.vp9-mpeg4.m3u8>
</video> </video>
<p>HLS VP9+Opus or VP9+MP3, with h.264 fallback:</p> <p>HLS VP9/H.264 with Opus/MP3:</p>
<video controls width=640 height=360> <video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.vp9-h264.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.vp9-h264.m3u8>
</video> </video>
@ -54,9 +85,19 @@
<source type=application/vnd.apple.mpegurl src=fmp4.480p.vp9.mp4.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.480p.vp9.mp4.m3u8>
</video> </video>
<p>HLS h.264 in fMP4:</p> <p>HLS MJPEG.mov in fMP4:</p>
<video controls width=640 height=360> <video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.480p.h264.mp4.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.120p.mjpeg.mov.m3u8>
</video>
<p>HLS h.263.3gp in fMP4:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.288p.h263.3gp.m3u8>
</video>
<p>HLS h.263.mov in fMP4:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.288p.h263.mov.m3u8>
</video> </video>
<p>HLS MPEG-4 Visual in fMP4:</p> <p>HLS MPEG-4 Visual in fMP4:</p>
@ -64,6 +105,11 @@
<source type=application/vnd.apple.mpegurl src=fmp4.480p.mpeg4.mp4.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.480p.mpeg4.mp4.m3u8>
</video> </video>
<p>HLS h.264 in fMP4:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.480p.h264.mp4.m3u8>
</video>
<p>HLS Opus in fMP4:</p> <p>HLS Opus in fMP4:</p>
<video controls width=640 height=360> <video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.audio.opus.mp4.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.audio.opus.mp4.m3u8>

View file

@ -6,9 +6,13 @@ BITRATE_HI="-b:v 1250k"
BITRATE_LO="-b:v 1000k" BITRATE_LO="-b:v 1000k"
SIZE_MAIN="-s 854x480" SIZE_MAIN="-s 854x480"
SIZE_H263="-s 352x288"
SIZE_SMALL="-s 212x120"
VIDEO_H264="-vcodec h264 -g 240 $BITRATE_HI $SIZE_MAIN" VIDEO_H264="-vcodec h264 -g 240 $BITRATE_HI $SIZE_MAIN"
VIDEO_MPEG4="-vcodec mpeg4 -g 240 $BITRATE_HI $SIZE_MAIN" VIDEO_MPEG4="-vcodec mpeg4 -g 240 $BITRATE_HI $SIZE_MAIN"
VIDEO_H263="-vcodec h263 -g 240 $BITRATE_LO $SIZE_H263"
VIDEO_MJPEG="-vcodec mjpeg $BITRATE_HI $SIZE_SMALL"
VIDEO_VP9="-vcodec libvpx-vp9 -tile-columns 2 -row-mt 1 -cpu-used 3 -g 240 $BITRATE_LO $SIZE_MAIN" VIDEO_VP9="-vcodec libvpx-vp9 -tile-columns 2 -row-mt 1 -cpu-used 3 -g 240 $BITRATE_LO $SIZE_MAIN"
AUDIO_OPUS="-acodec libopus -ac 2 -ar 48000 -ab 96k" AUDIO_OPUS="-acodec libopus -ac 2 -ar 48000 -ab 96k"
@ -25,26 +29,45 @@ set -e
#ffmpeg -i $INFILE -vn $AUDIO_OPUS $AUDFLAGS -y fmp4.audio.opus.mp4 #ffmpeg -i $INFILE -vn $AUDIO_OPUS $AUDFLAGS -y fmp4.audio.opus.mp4
# Video for HLS # Video for HLS
#ffmpeg -i $INFILE -an $VIDEO_VP9 $MOVFLAGS -pass 1 -y fmp4.480p.vp9.mp4
#ffmpeg -i $INFILE -an $VIDEO_VP9 $MOVFLAGS -pass 2 -y fmp4.480p.vp9.mp4
#ffmpeg -i $INFILE -an $VIDEO_H264 $MOVFLAGS -pass 1 -y fmp4.480p.h264.mp4 #ffmpeg -i $INFILE -an $VIDEO_H264 $MOVFLAGS -pass 1 -y fmp4.480p.h264.mp4
#ffmpeg -i $INFILE -an $VIDEO_H264 $MOVFLAGS -pass 2 -y fmp4.480p.h264.mp4 #ffmpeg -i $INFILE -an $VIDEO_H264 $MOVFLAGS -pass 2 -y fmp4.480p.h264.mp4
#ffmpeg -i $INFILE -an $VIDEO_MPEG4 $MOVFLAGS -pass 1 -y fmp4.480p.mpeg4.mp4 #ffmpeg -i $INFILE -an $VIDEO_MPEG4 $MOVFLAGS -pass 1 -y fmp4.480p.mpeg4.mp4
#ffmpeg -i $INFILE -an $VIDEO_MPEG4 $MOVFLAGS -pass 2 -y fmp4.480p.mpeg4.mp4 #ffmpeg -i $INFILE -an $VIDEO_MPEG4 $MOVFLAGS -pass 2 -y fmp4.480p.mpeg4.mp4
#ffmpeg -i $INFILE -an $VIDEO_VP9 $MOVFLAGS -pass 1 -y fmp4.480p.vp9.mp4 #ffmpeg -i $INFILE -an $VIDEO_H263 $MOVFLAGS -y fmp4.288p.h263.3gp
#ffmpeg -i $INFILE -an $VIDEO_VP9 $MOVFLAGS -pass 2 -y fmp4.480p.vp9.mp4 #ffmpeg -i $INFILE -an $VIDEO_H263 $MOVFLAGS -y fmp4.288p.h263.mov
#ffmpeg -i $INFILE -an $VIDEO_MJPEG $MOVFLAGS -y fmp4.120p.mjpeg.mp4
#ffmpeg -i $INFILE -an $VIDEO_MJPEG $MOVFLAGS -y fmp4.120p.mjpeg.mov
# Playlist processing # Playlist processing
#php extract-playlist.php fmp4.audio.mpeg.mp3 > fmp4.audio.mpeg.mp3.m3u8 php extract-playlist.php fmp4.audio.mpeg.mp3 > fmp4.audio.mpeg.mp3.m3u8
#php extract-playlist.php fmp4.audio.aac.mp4 > fmp4.audio.aac.mp4.m3u8 php extract-playlist.php fmp4.audio.aac.mp4 > fmp4.audio.aac.mp4.m3u8
#php extract-playlist.php fmp4.audio.opus.mp4 > fmp4.audio.opus.mp4.m3u8 php extract-playlist.php fmp4.audio.opus.mp4 > fmp4.audio.opus.mp4.m3u8
#php extract-playlist.php fmp4.480p.h264.mp4 > fmp4.480p.h264.mp4.m3u8 php extract-playlist.php fmp4.480p.vp9.mp4 > fmp4.480p.vp9.mp4.m3u8
#php extract-playlist.php fmp4.480p.mpeg4.mp4 > fmp4.480p.mpeg4.mp4.m3u8 php extract-playlist.php fmp4.480p.h264.mp4 > fmp4.480p.h264.mp4.m3u8
#php extract-playlist.php fmp4.480p.vp9.mp4 > fmp4.480p.vp9.mp4.m3u8 php extract-playlist.php fmp4.480p.mpeg4.mp4 > fmp4.480p.mpeg4.mp4.m3u8
php extract-playlist.php fmp4.288p.h263.3gp > fmp4.288p.h263.3gp.m3u8
php extract-playlist.php fmp4.288p.h263.mov > fmp4.288p.h263.mov.m3u8
php extract-playlist.php fmp4.120p.mjpeg.mp4 > fmp4.120p.mjpeg.mp4.m3u8
php extract-playlist.php fmp4.120p.mjpeg.mov > fmp4.120p.mjpeg.mov.m3u8
#php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.vp9.mp4 > fmp4.vp9.m3u8 php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.vp9.mp4 > fmp4.vp9.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.h264.mp4 > fmp4.h264.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.mpeg4.mp4 > fmp4.mpeg4.m3u8 php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.mpeg4.mp4 > fmp4.mpeg4.m3u8
php meta-playlist.php fmp4 audio.mpeg.mp3 480p.mpeg4.mp4 > fmp4.mpeg4-mp3.m3u8 php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 288p.h263.3gp > fmp4.h263.3gp.m3u8
php meta-playlist.php fmp4 audio.aac.mp3 480p.mpeg4.mp4 > fmp4.mpeg4-aac.m3u8 php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 288p.h263.mov > fmp4.h263.mov.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 120p.mjpeg.mp4 > fmp4.mjpeg.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 120p.mjpeg.mov > fmp4.mjpeg.mov.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.vp9.mp4 480p.h264.mp4 > fmp4.vp9-h264.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.vp9.mp4 480p.mpeg4.mp4 > fmp4.vp9-mpeg4.m3u8 php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.vp9.mp4 480p.mpeg4.mp4 > fmp4.vp9-mpeg4.m3u8
#php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.vp9.mp4 480p.h264.mp4 > fmp4.vp9-h264.m3u8 php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.vp9.mp4 288p.h263.3gp > fmp4.vp9-h263.3gp.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.vp9.mp4 288p.h263.mov > fmp4.vp9-h263.mov.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.vp9.mp4 120p.mjpeg.mp4 > fmp4.vp9-mjpeg.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 audio.mpeg.mp3 480p.vp9.mp4 120p.mjpeg.mov > fmp4.vp9-mjpeg.mov.m3u8

View file

@ -16,10 +16,29 @@ $audioCodecs = [
$videoCodecs = [ $videoCodecs = [
'vp9' => 'vp09.00.10.08', 'vp9' => 'vp09.00.10.08',
'h264' => 'avc1.42e00a', 'h264' => 'avc1.42e00a',
//'mpeg4' => 'mp4v.20.9',
//'mpeg4' => 'mp4v.20.9', // fail?
//'mpeg4' => 'mp4v.20', //'mpeg4' => 'mp4v.20',
//'mpeg4' => 'mp4v',
'mpeg4' => 'avc1.42e00a', // Lies for desktop safari
// 'mpeg4' => 'avc1', // lies
// 'h263' => 'avc1', // lies
'mjpeg' => 'jpeg', // works on mov, not mp4
// These lies work on iOS too
'h263' => 'avc1.42e00a', // lies
'mpeg4' => 'avc1.42e00a', // lies
//'mpeg4' => 'mp4v', // ???
//'h263' => 'h263', // ???
/*
'h264' => 'mp4v',
'h263' => 'mp4v',
'mjpeg' => 'mp4v',
'mpeg4' => 'mp4v',
*/
]; ];