mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 04:58:01 +01:00
Pony.fm should accept all PCM and ADPCM files now.
This commit is contained in:
parent
5241331fb3
commit
5588b836a0
2 changed files with 24 additions and 9 deletions
|
@ -52,13 +52,8 @@ class UploadTrackCommand extends CommandBase
|
|||
|
||||
private $_losslessFormats = [
|
||||
'flac',
|
||||
'pcm_s16le ([1][0][0][0] / 0x0001)',
|
||||
'pcm_s16be',
|
||||
'adpcm_ms ([2][0][0][0] / 0x0002)',
|
||||
'pcm_s24le ([1][0][0][0] / 0x0001)',
|
||||
'pcm_s24be',
|
||||
'pcm_f32le ([3][0][0][0] / 0x0003)',
|
||||
'pcm_f32be (fl32 / 0x32336C66)'
|
||||
'pcm',
|
||||
'adpcm',
|
||||
];
|
||||
|
||||
public function __construct($allowLossy = false, $allowShortTrack = false, $customTrackSource = null, $autoPublishByDefault = false)
|
||||
|
@ -114,7 +109,9 @@ class UploadTrackCommand extends CommandBase
|
|||
$validator = \Validator::make($input, [
|
||||
'track' =>
|
||||
'required|'
|
||||
. ($this->_allowLossy ? '' : 'audio_format:'. implode(',', $this->_losslessFormats).'|')
|
||||
. ($this->_allowLossy
|
||||
? 'audio_format:flac,pcm,adpcm,aac,mp3,vorbis|'
|
||||
: 'audio_format:flac,pcm,adpcm|')
|
||||
. ($this->_allowShortTrack ? '' : 'min_duration:30|')
|
||||
. 'audio_channels:1,2',
|
||||
|
||||
|
@ -194,7 +191,7 @@ class UploadTrackCommand extends CommandBase
|
|||
// Lossy uploads need to be identified and set as the master file
|
||||
// without being re-encoded.
|
||||
$audioObject = AudioCache::get($source);
|
||||
$isLossyUpload = !in_array($audioObject->getAudioCodec(), $this->_losslessFormats);
|
||||
$isLossyUpload = !Str::startsWith($audioObject->getAudioCodec(), $this->_losslessFormats);
|
||||
|
||||
if ($isLossyUpload) {
|
||||
if ($audioObject->getAudioCodec() === 'mp3') {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Pony.fm - A community for pony fan music.
|
||||
|
@ -45,6 +46,23 @@ class PfmValidator extends Illuminate\Validation\Validator
|
|||
// value is the file array itself
|
||||
// parameters is a list of formats the file can be, verified via ffmpeg
|
||||
$file = AudioCache::get($value->getPathname());
|
||||
$codecString = $file->getAudioCodec();
|
||||
|
||||
// PCM, ADPCM, and AAC come in several variations as far as FFmpeg
|
||||
// is concerned. They're all acceptable for Pony.fm, so we check what
|
||||
// the codec string returned by FFmpeg starts with instead of looking
|
||||
// for an exact match for these.
|
||||
if (in_array('adpcm', $parameters) && Str::startsWith($codecString, 'adpcm')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (in_array('pcm', $parameters) && Str::startsWith($codecString, 'pcm')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (in_array('aac', $parameters) && Str::startsWith($codecString, 'aac')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return in_array($file->getAudioCodec(), $parameters);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue