- .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:
+30
-8
@@ -127,7 +127,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$new_files = $_FILES['new_source_file'] ?? [];
|
||||
$videos_dir = MEDIA_DIR . 'videos/';
|
||||
if (!is_dir($videos_dir)) mkdir($videos_dir, 0755, true);
|
||||
$allowed_video = ['mp4','webm','ogv','ogg','mov','mkv','avi'];
|
||||
$allowed_video = ['mp4','webm','ogv','ogg','mov','mkv','avi','m4a'];
|
||||
|
||||
$new_count = max(
|
||||
count($new_types),
|
||||
@@ -166,12 +166,34 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (!in_array($ext, $allowed_video, true)) continue;
|
||||
$fname = $slug . '_' . time() . '_' . $i . '.' . $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([$id, $label, 'local', 'videos/' . $fname, '', mime_from_ext($fname), $quality, $sort]);
|
||||
$inserted_source_ids[] = (int)$db->lastInsertId();
|
||||
|
||||
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([$id, $converted_label, 'local', $converted_path, '', 'video/mp4', $quality, $sort]);
|
||||
$inserted_source_ids[] = (int)$db->lastInsertId();
|
||||
}
|
||||
|
||||
$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([$id, $original_label, 'local', $file_path, '', mime_from_ext($fname), '', $converted_path !== '' ? $sort + 1 : $sort]);
|
||||
$inserted_source_ids[] = (int)$db->lastInsertId();
|
||||
} else {
|
||||
$db->prepare("
|
||||
INSERT INTO video_sources (video_id, label, source_type, file_path, source_url, mime_type, quality, sort_order)
|
||||
VALUES (?,?,?,?,?,?,?,?)
|
||||
")->execute([$id, $label, 'local', $file_path, '', mime_from_ext($fname), $quality, $sort]);
|
||||
$inserted_source_ids[] = (int)$db->lastInsertId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,7 +447,7 @@ render_head('Edit Video — Admin', '
|
||||
<!-- ── Add new sources ── -->
|
||||
<div class="card" style="margin-bottom:1rem;">
|
||||
<p class="section-heading">Add New Sources</p>
|
||||
<p class="hint" style="margin-bottom:.85rem;">Upload another file, link a direct media file, or paste a provider page URL such as YouTube or Vimeo.</p>
|
||||
<p class="hint" style="margin-bottom:.85rem;">Upload another file, link a direct media file, or paste a provider page URL such as YouTube or Vimeo. M4A uploads keep the original source and add a black-frame H.264 MP4 source when ffmpeg is available.</p>
|
||||
<div class="source-list" id="new-sources-container">
|
||||
<div class="add-source-row" data-new-row="0">
|
||||
<div class="form-group">
|
||||
@@ -438,7 +460,7 @@ render_head('Edit Video — Admin', '
|
||||
<div class="form-group source-location-panel source-location-local">
|
||||
<label class="form-label">Video File</label>
|
||||
<input class="form-input" type="file" name="new_source_file[]"
|
||||
accept="video/mp4,video/webm,video/ogg,.mp4,.webm,.ogv,.mov,.mkv,.avi"
|
||||
accept="video/mp4,video/webm,video/ogg,audio/mp4,.mp4,.webm,.ogv,.mov,.mkv,.avi,.m4a"
|
||||
style="padding:.45rem .6rem;">
|
||||
</div>
|
||||
<div class="form-group source-location-panel source-location-remote" hidden>
|
||||
|
||||
Reference in New Issue
Block a user