haha array_filter preserves keys

This commit is contained in:
Brooke Vibber 2023-02-22 13:15:06 -08:00
parent 930518f046
commit f5a2a9faf0

View file

@ -95,9 +95,15 @@ function convert( $src, $dest, $options ) {
$probe = ffprobe( $src );
$videoTracks = array_filter( $probe->streams, function ( $stream ) {
$videoTracks = array_values(
array_filter( $probe->streams, function ( $stream ) {
return $stream->codec_type === 'video';
} );
} )
);
if ( count( $videoTracks ) == 0 ) {
var_dump( $probe );
die("oh no\n");
}
$track = $videoTracks[0];
$duration = floatval( $track->duration );