mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-03-16 16:30:01 +01:00
Add a way of specifying the ffmpeg prefix to use
It's useful for specifying a docker command
This commit is contained in:
parent
79690f2edb
commit
ff79a638d3
3 changed files with 31 additions and 6 deletions
|
@ -28,6 +28,7 @@ use Carbon\Carbon;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Config;
|
use Illuminate\Support\Facades\Config;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
|
@ -123,7 +124,14 @@ class EncodeTrackFile extends Job implements ShouldQueue
|
||||||
|
|
||||||
// Prepare the command
|
// Prepare the command
|
||||||
$format = Track::$Formats[$this->trackFile->format];
|
$format = Track::$Formats[$this->trackFile->format];
|
||||||
$command = $format['command'];
|
|
||||||
|
$prefix = Config('ponyfm.ffmpeg_prefix');
|
||||||
|
|
||||||
|
if (str_contains($prefix, '$(pwd)')) {
|
||||||
|
$prefix = str_replace('$(pwd)', App::basePath(), $prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
$command = $prefix . " " . $format['command'];
|
||||||
$command = str_replace('{$source}', '"'.$source.'"', $command);
|
$command = str_replace('{$source}', '"'.$source.'"', $command);
|
||||||
$command = str_replace('{$target}', '"'.$target.'"', $command);
|
$command = str_replace('{$target}', '"'.$target.'"', $command);
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
|
||||||
'tag_format' => 'metaflac',
|
'tag_format' => 'metaflac',
|
||||||
'tag_method' => 'updateTagsWithGetId3',
|
'tag_method' => 'updateTagsWithGetId3',
|
||||||
'mime_type' => 'audio/flac',
|
'mime_type' => 'audio/flac',
|
||||||
'command' => 'ffmpeg 2>&1 -y -i {$source} -map 0:a -map_metadata -1 -codec:a flac -aq 8 -f flac {$target}',
|
'command' => '2>&1 -y -i {$source} -map 0:a -map_metadata -1 -codec:a flac -aq 8 -f flac {$target}',
|
||||||
],
|
],
|
||||||
'MP3' => [
|
'MP3' => [
|
||||||
'index' => 1,
|
'index' => 1,
|
||||||
|
@ -209,7 +209,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
|
||||||
'tag_format' => 'id3v2.3',
|
'tag_format' => 'id3v2.3',
|
||||||
'tag_method' => 'updateTagsWithGetId3',
|
'tag_method' => 'updateTagsWithGetId3',
|
||||||
'mime_type' => 'audio/mpeg',
|
'mime_type' => 'audio/mpeg',
|
||||||
'command' => 'ffmpeg 2>&1 -y -i {$source} -map 0:a -map_metadata -1 -codec:a libmp3lame -ab 320k -f mp3 {$target}',
|
'command' => '2>&1 -y -i {$source} -map 0:a -map_metadata -1 -codec:a libmp3lame -ab 320k -f mp3 {$target}',
|
||||||
],
|
],
|
||||||
'OGG Vorbis' => [
|
'OGG Vorbis' => [
|
||||||
'index' => 2,
|
'index' => 2,
|
||||||
|
@ -218,7 +218,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
|
||||||
'tag_format' => 'vorbiscomment',
|
'tag_format' => 'vorbiscomment',
|
||||||
'tag_method' => 'updateTagsWithGetId3',
|
'tag_method' => 'updateTagsWithGetId3',
|
||||||
'mime_type' => 'audio/ogg',
|
'mime_type' => 'audio/ogg',
|
||||||
'command' => 'ffmpeg 2>&1 -y -i {$source} -map 0:a -map_metadata -1 -codec:a libvorbis -aq 7 -f ogg {$target}',
|
'command' => '2>&1 -y -i {$source} -map 0:a -map_metadata -1 -codec:a libvorbis -aq 7 -f ogg {$target}',
|
||||||
],
|
],
|
||||||
'AAC' => [
|
'AAC' => [
|
||||||
'index' => 3,
|
'index' => 3,
|
||||||
|
@ -227,7 +227,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
|
||||||
'tag_format' => 'AtomicParsley',
|
'tag_format' => 'AtomicParsley',
|
||||||
'tag_method' => 'updateTagsWithAtomicParsley',
|
'tag_method' => 'updateTagsWithAtomicParsley',
|
||||||
'mime_type' => 'audio/mp4',
|
'mime_type' => 'audio/mp4',
|
||||||
'command' => 'ffmpeg 2>&1 -y -i {$source} -map 0:a -map_metadata -1 -codec:a aac -ab 256k -f mp4 {$target}',
|
'command' => '2>&1 -y -i {$source} -map 0:a -map_metadata -1 -codec:a aac -ab 256k -f mp4 {$target}',
|
||||||
],
|
],
|
||||||
'ALAC' => [
|
'ALAC' => [
|
||||||
'index' => 4,
|
'index' => 4,
|
||||||
|
@ -236,7 +236,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
|
||||||
'tag_format' => 'AtomicParsley',
|
'tag_format' => 'AtomicParsley',
|
||||||
'tag_method' => 'updateTagsWithAtomicParsley',
|
'tag_method' => 'updateTagsWithAtomicParsley',
|
||||||
'mime_type' => 'audio/mp4',
|
'mime_type' => 'audio/mp4',
|
||||||
'command' => 'ffmpeg 2>&1 -y -i {$source} -map 0:a -map_metadata -1 -codec:a alac {$target}',
|
'command' => '2>&1 -y -i {$source} -map 0:a -map_metadata -1 -codec:a alac {$target}',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -130,4 +130,21 @@ return [
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'gcm_key' => env('GCM_KEY', 'default'),
|
'gcm_key' => env('GCM_KEY', 'default'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| ffmpeg prefix
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This is the prefix to the ffmpeg binary to use when encoding tracks
|
||||||
|
|
|
||||||
|
| On system where ffmpeg is installed it can be left as default.
|
||||||
|
|
|
||||||
|
| On systems where ffmpeg isn't installed, but docker is, it's preferable
|
||||||
|
| change this so it can use a prebuilt version of ffmpeg.
|
||||||
|
|
|
||||||
|
| E.G "docker run -v "$(pwd):$(pwd)" -w "$(pwd)" jrottenberg/ffmpeg:4.3-alpine312"
|
||||||
|
*/
|
||||||
|
|
||||||
|
'ffmpeg_prefix' => env('FFMPEG_PREFIX', 'ffmpeg'),
|
||||||
];
|
];
|
||||||
|
|
Loading…
Add table
Reference in a new issue