diff --git a/inc/lib/webm/ffmpeg.php b/inc/lib/webm/ffmpeg.php index 810c68c1..accc634c 100644 --- a/inc/lib/webm/ffmpeg.php +++ b/inc/lib/webm/ffmpeg.php @@ -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 [