HLS with VP9/MJPEG video tracks and Opus/MP3 audio tracks. Video.js enabled to provide HLS-over-MSE for Chrome/Firefox.
+
HLS with VP9 (.mp4)/MJPEG (.mov) video tracks and Opus/MP3 audio tracks. Video.js enabled to provide HLS-over-MSE for Chrome/Firefox.
Current behavior:
+
Browsers that play the VP9 track will get sharp video, those that play the MJPEG track will get blurry video. Audio should sound the same either way.
MSE-based streaming with VHS
@@ -35,13 +36,14 @@
Apple HLS player
-
Safari 16 on macOS 13 plays MJPEG and MP3 audio
-
iOS 16 plays VP9 or MJPEG if no hardware codec, and MP3 audio
-
Those last two will also play h.263 or MPEG-4 visual IF labeled as false "avc1"; MJPEG can be properly labeled as "jpeg".
+
macOS 13's Safari 16 plays MJPEG.
+
iOS 16 plays VP9 if supported, or MJPEG if no hardware codec
+
Those last two will also play h.263 or MPEG-4 visual IF labeled as if h.264 in the playlist; MJPEG can be properly labeled as "jpeg". I haven't found a supported labeling that is correct yet.
no access to iOS 13-15
-
iOS 12 doesn't seem to like any version on an old iPad Air, except the h264+MP3
+
iOS 13 doesn't seem to like mjpeg in .mp4, but .mov is fine
+
iOS 12 doesn't seem to like any version on an old iPad Air, except with h264 video
no access to iOS 11
-
iOS 10 on iPhone 5C plays jpeg, h.263, or mpeg-4 visual IF labeled as false avc1.blah.
+
iOS 10 on iPhone 5C plays h.263, or mpeg-4 visual IF labeled as false avc1.blah. It will also play mjpeg if so mislabeled, but only in .mov not in .mp4 as above.
iOS 9 doesn't understand the required version of HLS playlist format, and fails.
diff --git a/make-fmp4.sh b/make-fmp4.sh
index d5305d2..9d823a3 100755
--- a/make-fmp4.sh
+++ b/make-fmp4.sh
@@ -42,12 +42,11 @@ set -e
#ffmpeg -i $INFILE -an $VIDEO_MPEG4 $MOVFLAGS -pass 2 -y fmp4.480p.mpeg4.mp4
#ffmpeg -i $INFILE -an $VIDEO_H263 $MOVFLAGS -y fmp4.288p.h263.3gp
-#ffmpeg -i $INFILE -an $VIDEO_H263 $MOVFLAGS -y fmp4.288p.h263.mov
# Note use duration, not keyframe interval, for fragments,
# because all are keyframes!
-#ffmpeg -i $INFILE -an $VIDEO_MJPEG $AUDFLAGS -y fmp4.120p.mjpeg.mp4
-#ffmpeg -i $INFILE -an $VIDEO_MJPEG $AUDFLAGS -y fmp4.120p.mjpeg.mov
+ffmpeg -i $INFILE -an $VIDEO_MJPEG $AUDFLAGS -y fmp4.120p.mjpeg.mp4
+ffmpeg -i $INFILE -an $VIDEO_MJPEG $AUDFLAGS -y fmp4.120p.mjpeg.mov
# Playlist processing
php extract-playlist.php fmp4.audio.mpeg.mp3 > fmp4.audio.mpeg.mp3.m3u8
@@ -68,15 +67,17 @@ MPEG_TRACK=audio.mpeg.mp3
php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 480p.vp9.mp4 > fmp4.vp9.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 480p.h264.mp4 > fmp4.h264.m3u8
-php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 480p.mpeg4.mp4 > fmp4.mpeg4.m3u8
-php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 288p.h263.3gp > fmp4.h263.3gp.m3u8
-php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 288p.h263.mov > fmp4.h263.mov.m3u8
+php meta-playlist.php --lie fmp4 audio.opus.mp4 $MPEG_TRACK 480p.mpeg4.mp4 > fmp4.mpeg4.m3u8
+php meta-playlist.php --lie fmp4 audio.opus.mp4 $MPEG_TRACK 288p.h263.3gp > fmp4.h263.3gp.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 120p.mjpeg.mp4 > fmp4.mjpeg.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 120p.mjpeg.mov > fmp4.mjpeg.mov.m3u8
+php meta-playlist.php --lie fmp4 audio.opus.mp4 $MPEG_TRACK 120p.mjpeg.mp4 > fmp4.mjpeg.lie.m3u8
+php meta-playlist.php --lie fmp4 audio.opus.mp4 $MPEG_TRACK 120p.mjpeg.mov > fmp4.mjpeg.mov.lie.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 480p.vp9.mp4 480p.h264.mp4 > fmp4.vp9-h264.m3u8
-php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 480p.vp9.mp4 480p.mpeg4.mp4 > fmp4.vp9-mpeg4.m3u8
-php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 480p.vp9.mp4 288p.h263.3gp > fmp4.vp9-h263.3gp.m3u8
-php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 480p.vp9.mp4 288p.h263.mov > fmp4.vp9-h263.mov.m3u8
+php meta-playlist.php --lie fmp4 audio.opus.mp4 $MPEG_TRACK 480p.vp9.mp4 480p.mpeg4.mp4 > fmp4.vp9-mpeg4.m3u8
+php meta-playlist.php --lie fmp4 audio.opus.mp4 $MPEG_TRACK 480p.vp9.mp4 288p.h263.3gp > fmp4.vp9-h263.3gp.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 480p.vp9.mp4 120p.mjpeg.mp4 > fmp4.vp9-mjpeg.m3u8
php meta-playlist.php fmp4 audio.opus.mp4 $MPEG_TRACK 480p.vp9.mp4 120p.mjpeg.mov > fmp4.vp9-mjpeg.mov.m3u8
+php meta-playlist.php --lie fmp4 audio.opus.mp4 $MPEG_TRACK 480p.vp9.mp4 120p.mjpeg.mp4 > fmp4.vp9-mjpeg.lie.m3u8
+php meta-playlist.php --lie fmp4 audio.opus.mp4 $MPEG_TRACK 480p.vp9.mp4 120p.mjpeg.mov > fmp4.vp9-mjpeg.mov.lie.m3u8
diff --git a/meta-playlist.php b/meta-playlist.php
index 7c41d7a..af5fabb 100644
--- a/meta-playlist.php
+++ b/meta-playlist.php
@@ -2,13 +2,17 @@
$argv = $_SERVER['argv'];
$self = array_shift( $argv );
+if ( ( $argv[0] ?? '' ) === '--lie') {
+ $lie = array_shift( $argv );
+} else {
+ $lie = false;
+}
$base = array_shift( $argv ); // "fmp4"
$audio = [];
$video = [];
$audioCodecs = [
- //'mpeg' => 'mp4a.40.34', // (this seems wrong but it works for now)
- 'mpeg' => 'mp4a.6b', // should work!
+ 'mpeg' => 'mp4a.6b', // works but, technically this is for .fmp4 and we're in mp3 raw
//'mpeg' => 'mp3', // doesn't seem to work
'aac' => 'mp4a.40.2',
'opus' => 'opus',
@@ -16,33 +20,24 @@ $audioCodecs = [
// @fixme use correct settings based on the file
$videoCodecs = [
- 'vp9' => 'vp09.00.41.08',
+ 'vp9' => 'vp09.00.41.08',
'h264' => 'avc1.42e00a',
- //'mpeg4' => 'mp4v.20',
-
- // Lies for desktop safari
- //'mpeg4' => 'avc1', // lies
- //'h263' => 'avc1', // lies
-
// truths
- //'mjpeg' => 'jpeg', // works on current mac & iOS 16, but not iOS 10
- //'h263' => 's263', // fail? or should it be s263?
- //'mpeg4' => 'mp4v.20.9', // fail?
-
- // These lies work on current mac & and iOS 16, but not iOS 10
- //'h263' => 'jpeg', // lies
- //'mpeg4' => 'jpeg', // lies
+ 'mjpeg' => 'jpeg', // works on current mac & iOS 16, but not iOS 10
+ 'h263' => 's263', // fail? or should it be s263?
+ 'mpeg4' => 'mp4v.20.9', // fail?
// none of them seem to work on iOS 12!
-
- // These lies work on iOS 10 and iOS 16 too
- 'mjpeg' => 'avc1.42e00a', // lies
- 'h263' => 'avc1.42e00a', // lies
- 'mpeg4' => 'avc1.42e00a', // lies
-
];
+if ( $lie ) {
+ // These lies work on iOS 10 and iOS 16 too
+ $videoCodecs['mjpeg'] = 'avc1.42e00a';
+ $videoCodecs['h263' ] = 'avc1.42e00a';
+ $videoCodecs['mpeg4'] = 'avc1.42e00a';
+}
+
while ( count( $argv ) > 0 ) {
$track = array_shift( $argv );