From 47de94a3dfd4ea1ef2e9cdf4ea43c3fd4afb26cf Mon Sep 17 00:00:00 2001 From: Ty Clifford Date: Thu, 25 Jun 2026 17:47:54 -0400 Subject: [PATCH] - .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). --- README.md | 4 +++- admin/add.php | 38 ++++++++++++++++++++++++++++++-------- admin/edit.php | 38 ++++++++++++++++++++++++++++++-------- changelog.md | 1 + includes/db.php | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9921592..8b00f44 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ Styled to match the existing `gate.php` / `index.php` dark theme exactly. - **MP4** (H.264) — widest compatibility - **WebM** (VP9) — smaller size, modern browsers - **OGV** — Firefox fallback (legacy) + - **M4A** — kept as an original source and converted to a black-frame H.264 MP4 companion source when `ffmpeg` is installed 6. Set quality labels (1080p, 720p, 480p, etc.) 7. Save — Video.js will use the stored source location and auto-select the best format the browser supports @@ -81,7 +82,7 @@ External URLs must use `http://` or `https://`. Uploaded files and remote URLs c When adding an external URL, the admin form can fetch title, description, duration, thumbnail metadata, and readable provider view counts through oEmbed, page metadata, and JSON-LD. The save action repeats the metadata lookup as a fallback, so blank titles can be filled from supported external pages even if the browser autofill was not used. -If no thumbnail image is uploaded, the add/edit forms can auto-grab one from the first supported source. YouTube and Dailymotion use direct thumbnail URLs; Vimeo, Wistia, TikTok, SoundCloud, and Spotify use oEmbed when available. Local uploaded videos can generate a first-frame thumbnail when `ffmpeg` is installed on the server. +If no thumbnail image is uploaded, the add/edit forms can auto-grab one from the first supported source. YouTube and Dailymotion use direct thumbnail URLs; Vimeo, Wistia, TikTok, SoundCloud, and Spotify use oEmbed when available. Local uploaded videos can generate a first-frame thumbnail when `ffmpeg` is installed on the server. Uploaded M4A files also use `ffmpeg` to create a black-frame H.264 MP4 playback source while keeping the original M4A source. ### Live Homepage Option @@ -142,6 +143,7 @@ Use the **Sort Order** field — lower numbers appear first. Default is 0. The * - Playback rate controls: 0.5×, 1×, 1.25×, 1.5×, 2× - Multiple source fallback — browser picks best format automatically - Local uploaded sources and remote URL sources +- M4A uploads can add a generated black-frame H.264 MP4 companion source - Provider embeds for popular video and audio platforms - Thumbnail posters - Per-video view counts and optional public library statistics diff --git a/admin/add.php b/admin/add.php index 24aed78..4a39b31 100644 --- a/admin/add.php +++ b/admin/add.php @@ -88,7 +88,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $inserted_sources = 0; $moved_files = []; - $allowed_video = ['mp4','webm','ogv','ogg','mov','mkv','avi']; + $allowed_video = ['mp4','webm','ogv','ogg','mov','mkv','avi','m4a']; for ($i = 0; $i < $source_count; $i++) { $type = ($source_types[$i] ?? 'local') === 'remote' ? 'remote' : 'local'; @@ -123,12 +123,34 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $fname = $slug . '_' . ($i+1) . '_' . time() . '.' . $ext; if (move_uploaded_file($tmp, $videos_dir . $fname)) { + $file_path = 'videos/' . $fname; $moved_files[] = $videos_dir . $fname; - $db->prepare(" - INSERT INTO video_sources (video_id, label, source_type, file_path, source_url, mime_type, quality, sort_order) - VALUES (?,?,?,?,?,?,?,?) - ")->execute([$video_id, $label, 'local', 'videos/' . $fname, '', mime_from_ext($fname), $quality, $sort]); - $inserted_sources++; + + if ($ext === 'm4a') { + $converted_path = media_black_video_from_m4a($file_path, $slug, $i); + if ($converted_path !== '') { + $moved_files[] = MEDIA_DIR . $converted_path; + $converted_label = $label !== '' ? $label . ' (MP4)' : 'Converted MP4'; + $db->prepare(" + INSERT INTO video_sources (video_id, label, source_type, file_path, source_url, mime_type, quality, sort_order) + VALUES (?,?,?,?,?,?,?,?) + ")->execute([$video_id, $converted_label, 'local', $converted_path, '', 'video/mp4', $quality, $sort]); + $inserted_sources++; + } + + $original_label = $label !== '' ? $label . ' (M4A)' : 'Original M4A'; + $db->prepare(" + INSERT INTO video_sources (video_id, label, source_type, file_path, source_url, mime_type, quality, sort_order) + VALUES (?,?,?,?,?,?,?,?) + ")->execute([$video_id, $original_label, 'local', $file_path, '', mime_from_ext($fname), '', $converted_path !== '' ? $sort + 1 : $sort]); + $inserted_sources++; + } else { + $db->prepare(" + INSERT INTO video_sources (video_id, label, source_type, file_path, source_url, mime_type, quality, sort_order) + VALUES (?,?,?,?,?,?,?,?) + ")->execute([$video_id, $label, 'local', $file_path, '', mime_from_ext($fname), $quality, $sort]); + $inserted_sources++; + } } } @@ -309,7 +331,7 @@ render_head('Add Video — Admin', '

Video Sources

Upload a video file, link a direct media file, or paste a provider page URL such as YouTube or Vimeo. The player will use a provider embed when the URL supports it. - Uploaded files: MP4, WebM, OGV, MOV, MKV, AVI. Remote URLs must use http:// or https://. + Uploaded files: MP4, WebM, OGV, MOV, MKV, AVI, M4A. M4A uploads keep the original source and add a black-frame H.264 MP4 source when ffmpeg is available. Remote URLs must use http:// or https://.

@@ -325,7 +347,7 @@ render_head('Add Video — Admin', '