Add a way of specifying the ffmpeg prefix to use

It's useful for specifying a docker command
This commit is contained in:
Adam Lavin 2021-03-28 17:51:21 +01:00
parent 79690f2edb
commit ff79a638d3
No known key found for this signature in database
GPG key ID: 9C4C68AFA9CA6461
3 changed files with 31 additions and 6 deletions

View file

@ -28,6 +28,7 @@ use Carbon\Carbon;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
@ -123,7 +124,14 @@ class EncodeTrackFile extends Job implements ShouldQueue
// Prepare the command
$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('{$target}', '"'.$target.'"', $command);

View file

@ -200,7 +200,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
'tag_format' => 'metaflac',
'tag_method' => 'updateTagsWithGetId3',
'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' => [
'index' => 1,
@ -209,7 +209,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
'tag_format' => 'id3v2.3',
'tag_method' => 'updateTagsWithGetId3',
'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' => [
'index' => 2,
@ -218,7 +218,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
'tag_format' => 'vorbiscomment',
'tag_method' => 'updateTagsWithGetId3',
'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' => [
'index' => 3,
@ -227,7 +227,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
'tag_format' => 'AtomicParsley',
'tag_method' => 'updateTagsWithAtomicParsley',
'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' => [
'index' => 4,
@ -236,7 +236,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable
'tag_format' => 'AtomicParsley',
'tag_method' => 'updateTagsWithAtomicParsley',
'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}',
],
];

View file

@ -130,4 +130,21 @@ return [
*/
'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'),
];