wip trying with segment muxer
not having luck with the fmp4 just gonna stick with hls i think
This commit is contained in:
parent
74dbc1419f
commit
b14806a74b
5 changed files with 61 additions and 4 deletions
|
@ -33,6 +33,9 @@ ffmpeg -i $INFILE -s 320x180 $VIDEO_JPEG $AUDIO_MP3 $MOVFLAGS -y new-mjpeg.mov
|
|||
ffmpeg -i $INFILE -vn $AUDIO_AAC $HLSFLAGS -hls_segment_filename new-aac.mp4 -y new-aac.m3u8
|
||||
ffmpeg -i $INFILE -vn $AUDIO_OPUS $HLSFLAGS -hls_segment_filename new-opus.mp4 -y new-opus.m3u8
|
||||
|
||||
#ffmpeg -i $INFILE -vn $AUDIO_MP3 $HLSFLAGS -hls_segment_filename new-mp3.mp4 -y new-mp3-mp4.m3u8
|
||||
#ffmpeg -i $INFILE -vn $AUDIO_MP3 $TSFLAGS -hls_segment_filename new-mp3.ts -y new-mp3-ts.m3u8
|
||||
|
||||
ffmpeg -i $INFILE -vn $AUDIO_MP3 -f segment -segment_time 10 -segment_list new-mp3.m3u8 -y new-mp3-%04d.mp3
|
||||
php timestamp-id3.php new-mp3.m3u8 new-mp3.mp3
|
||||
|
||||
|
|
30
make-hls-segment.sh
Executable file
30
make-hls-segment.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
MOVFLAGS="+frag_keyframe+empty_moov+default_base_moof+faststart"
|
||||
SEGFLAGS="-f ssegment -segment_time 10 -segment_format movflags=$MOVFLAGS"
|
||||
|
||||
BITRATE="-b:v 1000k"
|
||||
|
||||
VIDEO_VP9="-vcodec libvpx-vp9 -row-mt 1 -cpu-used 3 -g 240 $BITRATE -s 854x480"
|
||||
VIDEO_H264="-vcodec h264 -g 240 $BITRATE $SIZE_MAIN -s 640x360"
|
||||
VIDEO_JPEG="-vcodec mjpeg -g 240 $BITRATE $SIZE_JPEG -s 213x120"
|
||||
|
||||
AUDIO_OPUS="-acodec libopus -ac 2 -ar 48000 -vb 96k"
|
||||
AUDIO_AAC="-ac 2 -ar 44100 -vb 128k"
|
||||
AUDIO_MP3="-acodec libmp3lame -ac 2 -ar 44100 -vb 128k"
|
||||
|
||||
INFILE=caminandes-llamigos.webm
|
||||
|
||||
set -e
|
||||
|
||||
# Audio for HLS
|
||||
ffmpeg -i $INFILE -vn $AUDIO_AAC $SEGFLAGS -segment_list segment-aac.m3u8 -y segment-aac-%04d.mp4
|
||||
php timestamp-id3.php segment-aac.m3u8 segment-aac.mp4
|
||||
|
||||
ffmpeg -i $INFILE -vn $AUDIO_OPUS $SEGFLAGS -segment_list segment-opus.m3u8 -y segment-opus-%04d.mp4
|
||||
php timestamp-id3.php segment-opus.m3u8 segment-opus.mp4
|
||||
|
||||
ffmpeg -i $INFILE -vn $AUDIO_MP3 -segment_list segment-mp3.m3u8 -y segment-mp3-%04d.mp3
|
||||
php timestamp-id3.php segment-mp3.m3u8 segment-mp3.mp3
|
||||
|
||||
# Video for HLS
|
||||
ffmpeg -i $INFILE -an $VIDEO_VP9 $SEGFLAGS -segment_list segment-vp9.m3u8 -y segment-vp9-%04d.mp4
|
||||
php timestamp-id3.php segment-vp9.m3u8 segment-vp9.mp4
|
13
new.html
13
new.html
|
@ -57,7 +57,17 @@
|
|||
<source type=application/vnd.apple.mpegurl src=new-opus.m3u8>
|
||||
</video>
|
||||
|
||||
<p>HLS MP3 alone (only audio)</p>
|
||||
<p>HLS MP3 MP4 alone (only audio)</p>
|
||||
<video controls width=640 height=360>
|
||||
<source type=application/vnd.apple.mpegurl src=new-mp3-mp4.m3u8>
|
||||
</video>
|
||||
|
||||
<p>HLS MP3 TS alone (only audio)</p>
|
||||
<video controls width=640 height=360>
|
||||
<source type=application/vnd.apple.mpegurl src=new-mp3-ts.m3u8>
|
||||
</video>
|
||||
|
||||
<p>HLS MP3 raw alone (only audio)</p>
|
||||
<video controls width=640 height=360>
|
||||
<source type=application/vnd.apple.mpegurl src=new-mp3.m3u8>
|
||||
</video>
|
||||
|
@ -77,6 +87,7 @@
|
|||
['Opus-in-WebM', 'audio/webm; codecs="opus"'],
|
||||
['VP9-in-MP4', 'video/mp4; codecs="vp09.00.10.08"'],
|
||||
['Opus-in-MP4', 'audio/mp4; codecs="opus"'],
|
||||
['MP3-in-MP4', 'audio/mp4; codecs="mp4a.6b"'],
|
||||
['MP3', 'audio/mp3'],
|
||||
];
|
||||
let yes = [];
|
||||
|
|
10
segment.m3u8
Normal file
10
segment.m3u8
Normal file
|
@ -0,0 +1,10 @@
|
|||
#EXTM3U
|
||||
|
||||
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="opus",NAME="English",LANGUAGE="en-US",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="segment-opus.m3u8"
|
||||
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="mp3",NAME="English",LANGUAGE="en-US",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="segment-mp3.m3u8"
|
||||
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=2560000,RESOLUTION=1920x1080,FRAME-RATE=24.0,CODECS="vp09.00.10.08,opus",AUDIO="opus"
|
||||
segment-vp9.m3u8
|
||||
|
||||
#EXT-X-STREAM-INF:BANDWIDTH=2560000,RESOLUTION=1920x1080,FRAME-RATE=24.0,CODECS="vp09.00.10.08,mp4a.40.34",AUDIO="mp3"
|
||||
segment-vp9.m3u8
|
|
@ -59,7 +59,7 @@ function hexdump($str) {
|
|||
const KHZ_90 = 90000;
|
||||
const MHZ_27 = 27000000;
|
||||
|
||||
function process_mp3( $filename, $pts ) {
|
||||
function process_mp3( $filename, $data, $pts ) {
|
||||
$owner = "com.apple.streaming.transportStreamTimestamp\x00";
|
||||
$timestamp = $pts * KHZ_90;
|
||||
$timestamp_high = 0;
|
||||
|
@ -99,7 +99,6 @@ function process_mp3( $filename, $pts ) {
|
|||
$hex = hexdump($tag);
|
||||
print "$filename $pts $hex\n";
|
||||
|
||||
$data = file_get_contents( $filename );
|
||||
return "$tag$data";
|
||||
}
|
||||
|
||||
|
@ -111,6 +110,7 @@ $self = array_shift( $args );
|
|||
$playlist = array_shift( $args );
|
||||
$playlist_out = $playlist;
|
||||
$outfile = array_shift( $args );
|
||||
$process_mp3 = preg_match('/\.mp3$/i', $outfile);
|
||||
|
||||
$lines = file( $playlist, FILE_IGNORE_NEW_LINES + FILE_SKIP_EMPTY_LINES );
|
||||
|
||||
|
@ -153,7 +153,10 @@ foreach ( $lines as $line ) {
|
|||
continue;
|
||||
}
|
||||
$filename = $line;
|
||||
$chunk = process_mp3( $filename, $pts );
|
||||
$chunk = file_get_contents( $filename );
|
||||
if ( $process_mp3 ) {
|
||||
$chunk = process_mp3( $filename, $chunk, $pts );
|
||||
}
|
||||
$len = strlen( $chunk );
|
||||
$lines_out[] = "#EXT-X-BYTERANGE:$len@$offset";
|
||||
$lines_out[] = "$outfile";
|
||||
|
|
Loading…
Reference in a new issue