Removes inclusion of external audio files, as ffmpeg produces audio streams with no sound
All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good

This commit is contained in:
Kristian Knarvik 2024-07-10 19:53:03 +02:00
parent 2145bfb8ea
commit 972691db76
2 changed files with 4 additions and 10 deletions

View File

@ -51,8 +51,7 @@ public abstract class AbstractConverter implements Converter {
@Override
public void convert(@NotNull File file) throws IOException {
StreamProbeResult probeResult = FFMpegHelper.probeFile(this.ffprobePath, file, this.subtitleFormats,
this.audioFormats);
StreamProbeResult probeResult = FFMpegHelper.probeFile(this.ffprobePath, file, this.subtitleFormats);
if (probeResult.parsedStreams().isEmpty()) {
throw new IllegalArgumentException("The file has no valid streams. Please make sure the file exists and" +
" is not corrupt.");

View File

@ -41,15 +41,13 @@ public final class FFMpegHelper {
* @param ffprobePath <p>The path/command to ffprobe</p>
* @param file <p>The file to probe</p>
* @param subtitleFormats <p>The extensions to accept for external subtitles</p>
* @param audioFormats <p>The extensions to accept for external audio files</p>
* @return <p>A list of StreamObjects</p>
* @throws IOException <p>If the process can't be readProcess</p>
*/
@NotNull
public static StreamProbeResult probeFile(@NotNull String ffprobePath, @NotNull File file,
@NotNull List<String> subtitleFormats,
@NotNull List<String> audioFormats) throws IOException {
return parseStreams(ffprobePath, probeForStreams(ffprobePath, file), file, subtitleFormats, audioFormats);
@NotNull List<String> subtitleFormats) throws IOException {
return parseStreams(ffprobePath, probeForStreams(ffprobePath, file), file, subtitleFormats);
}
/**
@ -277,17 +275,14 @@ public final class FFMpegHelper {
* @param streams <p>A list of all streams for the current file.</p>
* @param file <p>The file currently being converted.</p>
* @param subtitleFormats <p>The extensions to accept for external subtitles</p>
* @param audioFormats <p>The extensions to accept for external audio tracks</p>
* @return <p>A list of StreamObjects.</p>
*/
@NotNull
private static StreamProbeResult parseStreams(@NotNull String ffprobePath, @NotNull List<String> streams,
@NotNull File file, @NotNull List<String> subtitleFormats,
@NotNull List<String> audioFormats) throws IOException {
@NotNull File file, @NotNull List<String> subtitleFormats) throws IOException {
StreamProbeResult probeResult = new StreamProbeResult(new ArrayList<>(List.of(file)),
parseStreamObjects(streams));
getExternalStreams(probeResult, ffprobePath, file.getParentFile(), file.getName(), subtitleFormats);
getExternalStreams(probeResult, ffprobePath, file.getParentFile(), file.getName(), audioFormats);
return probeResult;
}