ffmpeg.php: fix mp4 logic for checking if audio exist

This commit is contained in:
fowr 2025-02-12 14:46:22 -03:00 committed by Zankaria
parent 6f9ea52212
commit 6ae47061cd

View file

@ -84,13 +84,28 @@ function is_valid_webm($ffprobe_out) {
}
} elseif ($extension === 'mp4' || stristr($ffprobe_out['format']['format_name'], 'mp4')) {
// If the video is not h264 or (there is audio but it's not aac).
if (($ffprobe_out['streams'][$videoidx]['codec_name'] != 'h264') || ((count($trackmap['audioat']) > 0) && ($ffprobe_out['streams'][$trackmap['audioat'][0]]['codec_name'] != 'aac'))) {
return [
'error' => [
'code' => 2,
'msg' => $config['error']['invalidwebm'] . ' [h264/aac check]'
]
];
if ($ffprobe_out['streams'][$videoidx]['codec_name'] != 'h264') {
if (!isset($ffprobe_out['streams'][0]['codec_name'])) {
return [
'error' => [
'code' => 2,
'msg' => $config['error']['invalidwebm']
]
];
}
$video_codec = $ffprobe_out['streams'][0]['codec_name'];
$audio_codec = $ffprobe_out['streams'][1]['codec_name'] ?? null;
if ($video_codec !== 'h264' || ($audio_codec && $audio_codec !== 'aac')) {
return [
'error' => [
'code' => 2,
'msg' => $config['error']['invalidwebm']
]
];
}
}
} else {
return [