WIP got hls with aac and vp9 fixed with init segments
This commit is contained in:
parent
5a4e9aa6bb
commit
f7a7059e39
7 changed files with 81 additions and 69 deletions
|
|
@ -66,6 +66,7 @@ class Video {
|
|||
'common' => [
|
||||
'-vcodec', 'libvpx-vp9',
|
||||
'-row-mt', '1',
|
||||
'-tile-columns', '4',
|
||||
],
|
||||
'fast' => [
|
||||
'-quality', 'realtime',
|
||||
|
|
@ -206,29 +207,37 @@ class Transcoder {
|
|||
}
|
||||
|
||||
private function ffmpeg( $options, $outfile, $container ) {
|
||||
$segmentOptions = [];
|
||||
$playlist = "$outfile.m3u8";
|
||||
$init = "$outfile.init.$container";
|
||||
$segment = "$outfile.%04d.$container";
|
||||
if ( $container == 'mp4' ) {
|
||||
$segmentOptions[] = '-segment_format_options';
|
||||
//$segmentOptions[] = 'movflags=+frag_keyframe+empty_moov';
|
||||
$segmentOptions[] = 'movflags=frag_keyframe';
|
||||
}
|
||||
if ( $container == 'mp3' ) {
|
||||
$segmentOptions[] = '-segment_format_options';
|
||||
$segmentOptions[] = 'id3v2_version=0:write_xing=0:write_id3v1=0';
|
||||
// HLS muxer seems to give the right options for fMP4
|
||||
$segmentOptions = [
|
||||
'-f', 'hls',
|
||||
'-hls_segment_type', 'fmp4',
|
||||
'-hls_time', '10',
|
||||
'-hls_playlist_type', 'vod',
|
||||
'-hls_fmp4_init_filename', $init,
|
||||
'-hls_segment_filename', $segment,
|
||||
'-y', $playlist,
|
||||
];
|
||||
} elseif ( $container == 'mp3' ) {
|
||||
// For MP3, segment it raw.
|
||||
// We'll need to postprocess to add an ID3 tag with timestamp.
|
||||
$segmentOptions = [
|
||||
'-f', 'segment',
|
||||
'-segment_format_options', 'id3v2_version=0:write_xing=0:write_id3v1=0',
|
||||
'-segment_time', '10',
|
||||
'-segment_list', $playlist,
|
||||
'-y', $segment
|
||||
];
|
||||
} else {
|
||||
die( 'missing container in config' );
|
||||
}
|
||||
$ffmpegOptions = array_merge( [
|
||||
'-hide_banner',
|
||||
'-i',
|
||||
$this->source->filename,
|
||||
'-f', 'segment',
|
||||
'-segment_time', '10',
|
||||
'-segment_list', "$outfile.m3u8",
|
||||
],
|
||||
$segmentOptions,
|
||||
$options,
|
||||
[
|
||||
'-y', "$outfile.%04d.$container"
|
||||
] );
|
||||
'-i', $this->source->filename,
|
||||
], $options, $segmentOptions);
|
||||
|
||||
$output = run( 'ffmpeg', $ffmpegOptions );
|
||||
}
|
||||
|
|
@ -298,11 +307,16 @@ foreach ( $infiles as $filename ) {
|
|||
$codec->audio('mp3');
|
||||
$codec->audio('aac');
|
||||
foreach ( Video::FORMATS['vp9']['resolutions'] as $res => $format ) {
|
||||
|
||||
if ( $format['width'] <= $source->width && $format['height'] <= $source->height ) {
|
||||
$codec->video('vp9', $res, 'fast');
|
||||
}
|
||||
}
|
||||
/*
|
||||
foreach ( Video::FORMATS['vp9']['resolutions'] as $res => $format ) {
|
||||
if ( $format['width'] <= $source->width && $format['height'] <= $source->height ) {
|
||||
$codec->video('vp9', $res, 'pass1');
|
||||
$codec->video('vp9', $res, 'pass2');
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue