- .m4a uploads are now accepted in add/edit, and M4A handling now keeps the original source while adding a generated black-frame H.264 MP4 companion source when ffmpeg can run.
The core conversion helper is in [includes/db.php (line 1161)](/Users/tyemeclifford/Documents/GH/mediaplayer/includes/db.php:1161). The upload flows insert the converted MP4 first for playback and retain the original M4A as a separate source in [admin/add.php (line 129)](/Users/tyemeclifford/Documents/GH/mediaplayer/admin/add.php:129) and [admin/edit.php (line 172)](/Users/tyemeclifford/Documents/GH/mediaplayer/admin/edit.php:172). I also updated the admin upload hints, [README.md (line 77)](/Users/tyemeclifford/Documents/GH/mediaplayer/README.md:77), and [changelog.md (line 14)](/Users/tyemeclifford/Documents/GH/mediaplayer/changelog.md:14).
This commit is contained in:
@@ -1158,6 +1158,40 @@ function media_ffmpeg_path(): string {
|
||||
return $path !== '' && is_executable($path) ? $path : '';
|
||||
}
|
||||
|
||||
function media_black_video_from_m4a(string $file_path, string $slug, int $index = 0): string {
|
||||
$ffmpeg = media_ffmpeg_path();
|
||||
if ($ffmpeg === '') return '';
|
||||
|
||||
$source = MEDIA_DIR . ltrim($file_path, '/');
|
||||
if ($file_path === '' || !is_file($source) || !is_readable($source)) return '';
|
||||
if (strtolower(pathinfo($source, PATHINFO_EXTENSION)) !== 'm4a') return '';
|
||||
|
||||
$videos_dir = MEDIA_DIR . 'videos/';
|
||||
if (!is_dir($videos_dir)) mkdir($videos_dir, 0755, true);
|
||||
if (!function_exists('exec') || media_disabled_function('exec')) return '';
|
||||
|
||||
$label = media_clean_token($slug);
|
||||
if ($label === '') $label = 'video';
|
||||
$fname = $label . '_m4a_black_' . $index . '_' . time() . '_' . substr(sha1($file_path), 0, 8) . '.mp4';
|
||||
$target = $videos_dir . $fname;
|
||||
|
||||
$cmd = escapeshellarg($ffmpeg)
|
||||
. ' -y -f lavfi -i ' . escapeshellarg('color=c=black:s=1280x720:r=30')
|
||||
. ' -i ' . escapeshellarg($source)
|
||||
. ' -shortest -map 0:v:0 -map 1:a:0'
|
||||
. ' -c:v libx264 -preset veryfast -tune stillimage -pix_fmt yuv420p'
|
||||
. ' -c:a aac -b:a 192k -movflags +faststart '
|
||||
. escapeshellarg($target) . ' 2>/dev/null';
|
||||
@exec($cmd, $output, $code);
|
||||
|
||||
if ($code === 0 && is_file($target) && filesize($target) > 0) {
|
||||
return 'videos/' . $fname;
|
||||
}
|
||||
|
||||
if (is_file($target)) unlink($target);
|
||||
return '';
|
||||
}
|
||||
|
||||
function media_thumbnail_from_local_video(string $file_path, string $slug): string {
|
||||
$ffmpeg = media_ffmpeg_path();
|
||||
if ($ffmpeg === '') return '';
|
||||
|
||||
Reference in New Issue
Block a user