audio tweaks etc
* pass --no-audio through from pack-set to pack-vid * don't reserve bitrate for audio if there's no audio track
This commit is contained in:
parent
f380334fe2
commit
97a21bd75f
2 changed files with 20 additions and 7 deletions
9
pack-set
9
pack-set
|
@ -1,10 +1,17 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
OPTS=""
|
||||||
|
if [ "$1" == "--no-audio" ]
|
||||||
|
then
|
||||||
|
OPTS="--no-audio"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
for INFILE in "$@"
|
for INFILE in "$@"
|
||||||
do
|
do
|
||||||
echo "$INFILE"
|
echo "$INFILE"
|
||||||
|
|
||||||
COMMON="--exposure=-2.5 --peak=141 --fps=60000/1001"
|
COMMON="$OPTS --exposure=-2.5 --peak=141 --fps=60000/1001"
|
||||||
SPEED_SMALL="veryslow"
|
SPEED_SMALL="veryslow"
|
||||||
SPEED_LARGE="medium"
|
SPEED_LARGE="medium"
|
||||||
|
|
||||||
|
|
18
pack-vid
18
pack-vid
|
@ -121,16 +121,22 @@ function sizify( $str ) {
|
||||||
die( "Unexpected size format '$str'\n" );
|
die( "Unexpected size format '$str'\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractTracks( $streams, $type ) {
|
||||||
|
return array_values(
|
||||||
|
array_filter( $streams, function ( $stream ) use ( $type ) {
|
||||||
|
return $stream->codec_type === $type;
|
||||||
|
} )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function convert( $src, $dest, $options ) {
|
function convert( $src, $dest, $options ) {
|
||||||
$maxBits = 8 * sizify( $options['size'] );
|
$maxBits = 8 * sizify( $options['size'] );
|
||||||
|
|
||||||
$probe = ffprobe( $src );
|
$probe = ffprobe( $src );
|
||||||
|
|
||||||
$videoTracks = array_values(
|
$videoTracks = extractTracks( $probe->streams, 'video' );
|
||||||
array_filter( $probe->streams, function ( $stream ) {
|
$audioTracks = extractTracks( $probe->streams, 'audio' );
|
||||||
return $stream->codec_type === 'video';
|
|
||||||
} )
|
|
||||||
);
|
|
||||||
if ( count( $videoTracks ) == 0 ) {
|
if ( count( $videoTracks ) == 0 ) {
|
||||||
var_dump( $probe );
|
var_dump( $probe );
|
||||||
die("oh no\n");
|
die("oh no\n");
|
||||||
|
@ -146,7 +152,7 @@ function convert( $src, $dest, $options ) {
|
||||||
$bitrate = floor( $maxBits / $duration );
|
$bitrate = floor( $maxBits / $duration );
|
||||||
|
|
||||||
|
|
||||||
if ( $options[ 'no-audio' ] ) {
|
if ( $options[ 'no-audio' ] || count( $audioTracks ) == 0 ) {
|
||||||
$audio = [ '-an' ];
|
$audio = [ '-an' ];
|
||||||
} else {
|
} else {
|
||||||
$audioBitrate = 96 * 1000;
|
$audioBitrate = 96 * 1000;
|
||||||
|
|
Loading…
Reference in a new issue