Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Oct 26, 2018
2 parents 91c9bd7 + e7b2bd0 commit f48b539
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 39 deletions.
46 changes: 30 additions & 16 deletions Blacklight/processing/post/ProcessAdditional.php
Original file line number Diff line number Diff line change
Expand Up @@ -1799,10 +1799,14 @@ protected function _getAudioInfo($fileLocation, $fileExtension): bool

// Create an audio sample.
if ($this->ffprobe->isValid($fileLocation)) {
$audioSample = $this->ffmpeg->open($fileLocation);
$format = new Vorbis();
$audioSample->clip(TimeCode::fromSeconds(30), TimeCode::fromSeconds(30));
$audioSample->save($format, $this->tmpPath.$audioFileName);
try {
$audioSample = $this->ffmpeg->open($fileLocation);
$format = new Vorbis();
$audioSample->clip(TimeCode::fromSeconds(30), TimeCode::fromSeconds(30));
$audioSample->save($format, $this->tmpPath.$audioFileName);
} catch (\InvalidArgumentException $e) {
//We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file)
}
}

// Check if the new file was created.
Expand Down Expand Up @@ -1918,6 +1922,8 @@ protected function _getSample(string $fileLocation): bool
$this->ffmpeg->open($fileLocation)->frame(TimeCode::fromString($time === '' ? '00:00:03:00' : $time))->save($fileName);
} catch (\RuntimeException $runtimeException) {
//We show no error at all, we failed to save the frame and move on
} catch (\InvalidArgumentException $e) {
//We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file)
}
}

Expand Down Expand Up @@ -2000,25 +2006,33 @@ protected function _getVideo(string $fileLocation): bool

// Try to get the sample (from the end instead of the start).
if ($this->ffprobe->isValid($fileLocation)) {
$video = $this->ffmpeg->open($fileLocation);
$videoSample = $video->clip(TimeCode::fromString($lowestLength), TimeCode::fromSeconds($this->_ffMPEGDuration));
$format = new Ogg();
$format->setAudioCodec(new Vorbis());
$videoSample->filters()->resize(new Dimension(320, -1), ResizeFilter::RESIZEMODE_SCALE_HEIGHT);
$videoSample->save($format, $fileName);
try {
$video = $this->ffmpeg->open($fileLocation);
$videoSample = $video->clip(TimeCode::fromString($lowestLength), TimeCode::fromSeconds($this->_ffMPEGDuration));
$format = new Ogg();
$format->setAudioCodec(new Vorbis());
$videoSample->filters()->resize(new Dimension(320, -1), ResizeFilter::RESIZEMODE_SCALE_HEIGHT);
$videoSample->save($format, $fileName);
} catch (\InvalidArgumentException $e) {
//We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file)
}
}
}
}

if ($newMethod === false) {
// If longer than 60 or we could not get the video length, run the old way.
if ($this->ffprobe->isValid($fileLocation)) {
$video = $this->ffmpeg->open($fileLocation);
$videoSample = $video->clip(TimeCode::fromSeconds(0), TimeCode::fromSeconds($this->_ffMPEGDuration));
$format = new Ogg();
$format->setAudioCodec(new Vorbis());
$videoSample->filters()->resize(new Dimension(320, -1), ResizeFilter::RESIZEMODE_SCALE_HEIGHT);
$videoSample->save($format, $fileName);
try {
$video = $this->ffmpeg->open($fileLocation);
$videoSample = $video->clip(TimeCode::fromSeconds(0), TimeCode::fromSeconds($this->_ffMPEGDuration));
$format = new Ogg();
$format->setAudioCodec(new Vorbis());
$videoSample->filters()->resize(new Dimension(320, -1), ResizeFilter::RESIZEMODE_SCALE_HEIGHT);
$videoSample->save($format, $fileName);
} catch (\InvalidArgumentException $e) {
//We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file)
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2018-10-26 DariusIII
* Chg: Update font-awesome to version 5.4.2
* Chg: Catch InvalidArgumentException when opening corrupt video/audio file for processing
2018-10-25 DariusIII
* Chg: Update groupfixrelnames.php, remove traversable check for query results
* Fix: Fix deletion of sjows from my shows page
Expand Down
65 changes: 42 additions & 23 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f48b539

Please sign in to comment.