Skip to content

Commit

Permalink
fix #1809: copy videos from long paths to local temp so mplayer works
Browse files Browse the repository at this point in the history
  • Loading branch information
lfcnassif committed Aug 16, 2023
1 parent c534e9b commit 270f44b
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -92,6 +93,7 @@ public VideoProcessResult createThumbs(File inOrg, File tmp, List<VideoThumbsOut

boolean fixed = false;
File lnk = null;
File subTmpFile = null;
String videoStream = null;
for (int step = numFrames <= 0 ? 0 : 1; step <= 1; step++) {
if (step == 1) {
Expand Down Expand Up @@ -130,6 +132,25 @@ public VideoProcessResult createThumbs(File inOrg, File tmp, List<VideoThumbsOut
step--;
continue;
}
if (inOrg.getAbsolutePath().length() > 256) {
subTmpFile = File.createTempFile("_temp_video_", ".tmp", subTmp);
subTmpFile.deleteOnExit();
if (verbose) {
System.err.println("Using temp file = " + subTmpFile); //$NON-NLS-1$
}
try {
Files.copy(inOrg.toPath(), subTmpFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
in = subTmpFile;
cmds.set(cmds.size() - 1, in.getPath());
step--;
continue;
} catch (IOException e) {
if (verbose) {
System.err.println("Error copying to temp a file with long path: " + inOrg.toPath()); //$NON-NLS-1$
e.printStackTrace();
}
}
}
}
if (info != null) {
result.setVideoInfo(info);
Expand Down Expand Up @@ -340,6 +361,9 @@ public boolean accept(File pathname) {
if (lnk != null) {
lnk.delete();
}
if (subTmpFile != null) {
subTmpFile.delete();
}
if (images.size() == 0) {
return result;
}
Expand Down

0 comments on commit 270f44b

Please sign in to comment.