Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/net/bramp/ffmpeg/builder/FFmpegBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,19 @@ public FFmpegBuilder setPassDirectory(String directory) {
return this;
}

public String getPassDirectory() {
return this.pass_directory;
}

public FFmpegBuilder setPassPrefix(String prefix) {
this.pass_prefix = checkNotNull(prefix);
return this;
}

public String getPassPrefix() {
return this.pass_prefix;
}

public FFmpegBuilder setVerbosity(Verbosity verbosity) {
checkNotNull(verbosity);
this.verbosity = verbosity;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/bramp/ffmpeg/job/TwoPassFFmpegJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public TwoPassFFmpegJob(
}

protected void deletePassLog() throws IOException {
final Path cwd = Paths.get("");
final Path cwd = Paths.get(builder.getPassDirectory());
try (DirectoryStream<Path> stream = Files.newDirectoryStream(cwd, passlogPrefix + "*.log*")) {
for (Path p : stream) {
Files.deleteIfExists(p);
Expand Down
39 changes: 39 additions & 0 deletions src/test/java/net/bramp/ffmpeg/FFmpegExecutorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import com.google.common.io.ByteStreams;
import com.google.common.io.CountingOutputStream;
import com.google.common.net.HostAndPort;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -270,6 +272,43 @@ public void testIssue112() {
ffExecutor.createJob(builder).run();
}


@Test
public void testIssue287() throws InterruptedException, ExecutionException, IOException {
FFmpegProbeResult in = ffprobe.probe(Samples.big_buck_bunny_720p_1mb);
assertFalse(in.hasError());

String tempDir = System.getProperty("java.io.tmpdir");

FFmpegBuilder builder =
new FFmpegBuilder()
.setInput(in)
.done()
.overrideOutputFiles(true)
.addOutput(Samples.output_mp4)
.setFormat("mp4")
.disableAudio()
.setVideoCodec("mpeg4")
.setVideoFrameRate(FFmpeg.FPS_30)
.setVideoResolution(320, 240)
.setTargetSize(1024 * 1024)
.done().setPassDirectory(tempDir);

FFmpegJob job = ffExecutor.createTwoPassJob(builder);
runAndWait(job);

assertEquals(FFmpegJob.State.FINISHED, job.getState());

File passDir = new File(builder.getPassDirectory());
String passPrefix = builder.getPassPrefix();

File[] remainingFiles = passDir.listFiles((dir, name) ->
name.startsWith(passPrefix) && name.contains(".log")
);

assertEquals(true, remainingFiles == null || remainingFiles.length == 0);
}

protected void runAndWait(FFmpegJob job) throws ExecutionException, InterruptedException {
executor.submit(job).get();
}
Expand Down
Loading