Skip to content
Snippets Groups Projects
Commit b13af013 authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

#173 - Add null check for ffmpeg and ffprobe initialization

parent ea8e9855
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ import de.tobias.playpad.profile.Profile ...@@ -8,6 +8,7 @@ import de.tobias.playpad.profile.Profile
import javafx.util.Pair import javafx.util.Pair
import net.bramp.ffmpeg.builder.FFmpegBuilder import net.bramp.ffmpeg.builder.FFmpegBuilder
import net.bramp.ffmpeg.{FFmpeg, FFmpegExecutor, FFprobe} import net.bramp.ffmpeg.{FFmpeg, FFmpegExecutor, FFprobe}
import org.apache.commons.lang3.StringUtils
import java.nio.file.{Files, Path} import java.nio.file.{Files, Path}
...@@ -21,11 +22,26 @@ object FfmpegUtils { ...@@ -21,11 +22,26 @@ object FfmpegUtils {
val profile = Profile.currentProfile() val profile = Profile.currentProfile()
val contentPluginConfiguration = profile.getCustomSettings(ContentPluginMain.zoneConfigurationKey).asInstanceOf[ContentPlayerPluginConfiguration] val contentPluginConfiguration = profile.getCustomSettings(ContentPluginMain.zoneConfigurationKey).asInstanceOf[ContentPlayerPluginConfiguration]
if (StringUtils.isNotEmpty(contentPluginConfiguration.ffmpegExecutable) && StringUtils.isNotEmpty(contentPluginConfiguration.ffprobeExecutable)) {
ffmpeg = new FFmpeg(contentPluginConfiguration.ffmpegExecutable) ffmpeg = new FFmpeg(contentPluginConfiguration.ffmpegExecutable)
ffprobe = new FFprobe(contentPluginConfiguration.ffprobeExecutable) ffprobe = new FFprobe(contentPluginConfiguration.ffprobeExecutable)
} }
}
def checkInitialization(): Boolean = {
if (ffprobe == null || ffmpeg == null) {
initialize()
return ffprobe != null && ffmpeg != null
}
true
}
def getResolution(path: Path): Pair[Int, Int] = { def getResolution(path: Path): Pair[Int, Int] = {
if (!checkInitialization()) {
return null
}
val probeResult = ffprobe.probe(path.toAbsolutePath.toString) val probeResult = ffprobe.probe(path.toAbsolutePath.toString)
val stream = probeResult.streams.head val stream = probeResult.streams.head
...@@ -36,6 +52,10 @@ object FfmpegUtils { ...@@ -36,6 +52,10 @@ object FfmpegUtils {
} }
def convertMediaVStack(path: Path): Unit = { def convertMediaVStack(path: Path): Unit = {
if (!checkInitialization()) {
return
}
val globalSettings = PlayPadPlugin.getInstance.getGlobalSettings val globalSettings = PlayPadPlugin.getInstance.getGlobalSettings
val convertPath = globalSettings.getCachePath.resolve(path.getFileName + ".mp4") val convertPath = globalSettings.getCachePath.resolve(path.getFileName + ".mp4")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment