mwahahaha

lying about mpeg 4 visual being avc1 lets it work in hls
This commit is contained in:
Brooke Vibber 2023-03-27 12:24:04 -07:00
parent aacd048f12
commit 02c01d60cf
3 changed files with 55 additions and 16 deletions

View file

@ -22,6 +22,26 @@
<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>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.mpeg4.m3u8>
</video>
<p>HLS MPEG-4 Visual+MP3:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.mpeg4-mp3.m3u8>
</video>
<p>HLS MPEG-4 Visual+AAC:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.mpeg4-aac.m3u8>
</video>
<p>HLS VP9+Opus or VP9+MP3, with MPEG-4 Visual fallback:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.vp9-mpeg4.m3u8>
</video>
<p>HLS VP9+Opus or VP9+MP3, with h.264 fallback:</p> <p>HLS VP9+Opus or VP9+MP3, with h.264 fallback:</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>
@ -39,6 +59,11 @@
<source type=application/vnd.apple.mpegurl src=fmp4.480p.h264.mp4.m3u8> <source type=application/vnd.apple.mpegurl src=fmp4.480p.h264.mp4.m3u8>
</video> </video>
<p>HLS MPEG-4 Visual in fMP4:</p>
<video controls width=640 height=360>
<source type=application/vnd.apple.mpegurl src=fmp4.480p.mpeg4.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

@ -8,6 +8,7 @@ BITRATE_LO="-b:v 1000k"
SIZE_MAIN="-s 854x480" SIZE_MAIN="-s 854x480"
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_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"
@ -19,23 +20,31 @@ INFILE=caminandes-llamigos.webm
set -e set -e
# Audio for HLS # Audio for HLS
ffmpeg -i $INFILE -vn $AUDIO_MP3 -y fmp4.audio.mpeg.mp3 #ffmpeg -i $INFILE -vn $AUDIO_MP3 -y fmp4.audio.mpeg.mp3
ffmpeg -i $INFILE -vn $AUDIO_AAC $AUDFLAGS -y fmp4.audio.aac.mp4 #ffmpeg -i $INFILE -vn $AUDIO_AAC $AUDFLAGS -y fmp4.audio.aac.mp4
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_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_VP9 $MOVFLAGS -pass 1 -y fmp4.480p.vp9.mp4 #ffmpeg -i $INFILE -an $VIDEO_MPEG4 $MOVFLAGS -pass 1 -y fmp4.480p.mpeg4.mp4
ffmpeg -i $INFILE -an $VIDEO_VP9 $MOVFLAGS -pass 2 -y fmp4.480p.vp9.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_VP9 $MOVFLAGS -pass 2 -y fmp4.480p.vp9.mp4
# 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.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.vp9.mp4 > fmp4.480p.vp9.mp4.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.vp9.mp4 480p.h264.mp4 > fmp4.vp9-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.mpeg.mp3 480p.mpeg4.mp4 > fmp4.mpeg4-mp3.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 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

View file

@ -8,13 +8,18 @@ $video = [];
$audioCodecs = [ $audioCodecs = [
'mpeg' => 'mp4a.40.34', 'mpeg' => 'mp4a.40.34',
'opus' => 'opus' 'aac' => 'mp4a.40.2',
'opus' => 'opus',
]; ];
// @fixme use correct settings based on the file // @fixme use correct settings based on the file
$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',
//'mpeg4' => 'mp4v',
'mpeg4' => 'avc1.42e00a',
]; ];
@ -36,7 +41,7 @@ while ( count( $argv ) > 0 ) {
$height = 480; // @fixme $height = 480; // @fixme
$fps = 24.0; // @fixme $fps = 24.0; // @fixme
$baseLine = "#EXT-X-STREAM-INF:BANDWIDTH=$bandwidth,RESOLUTION={$width}x{$height},FRAME-RATE={$fps}"; $baseLine = "#EXT-X-STREAM-INF:BANDWIDTH=$bandwidth,RESOLUTION={$width}x{$height},FRAME-RATE={$fps}";
if ( count( $audio ) > 1 ) { if ( count( $audio ) >= 1 ) {
foreach ( array_keys( $audio ) as $audioCodec ) { foreach ( array_keys( $audio ) as $audioCodec ) {
$codecs = implode( ',', [ $codecs = implode( ',', [
$videoCodecs[$codec], $videoCodecs[$codec],