mirror of https://github.com/OpenVidu/openvidu.git
openvidu-test-browsers: fix webm file extension limitations
parent
6bf0797df6
commit
d260bbceaa
|
@ -19,25 +19,22 @@ package io.openvidu.test.browsers.utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.common.io.Files;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
import io.openvidu.test.browsers.utils.CommandLineExecutor;
|
|
||||||
|
|
||||||
public class MultimediaFileMetadata {
|
public class MultimediaFileMetadata {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(MultimediaFileMetadata.class);
|
private static final Logger log = LoggerFactory.getLogger(MultimediaFileMetadata.class);
|
||||||
|
|
||||||
private CommandLineExecutor executer = new CommandLineExecutor();
|
private CommandLineExecutor executer = new CommandLineExecutor();
|
||||||
private JsonParser parser = new JsonParser();
|
|
||||||
|
|
||||||
private JsonObject json;
|
private JsonObject json;
|
||||||
private JsonObject formatJson;
|
private JsonObject formatJson;
|
||||||
|
@ -155,13 +152,14 @@ public class MultimediaFileMetadata {
|
||||||
private JsonObject executeFfprobeCommand(String filePath) {
|
private JsonObject executeFfprobeCommand(String filePath) {
|
||||||
log.info("Running ffprobe command on '{}'", filePath);
|
log.info("Running ffprobe command on '{}'", filePath);
|
||||||
String cmd = "ffprobe -v quiet -print_format json -show_format -show_streams " + filePath;
|
String cmd = "ffprobe -v quiet -print_format json -show_format -show_streams " + filePath;
|
||||||
return this.parser.parse(this.executer.executeCommand(cmd)).getAsJsonObject();
|
return JsonParser.parseString(this.executer.executeCommand(cmd)).getAsJsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fixWebmFile(String filePath) throws IOException {
|
private void fixWebmFile(String filePath) throws IOException {
|
||||||
Path source = Paths.get(filePath);
|
Path source = Paths.get(filePath);
|
||||||
|
String extension = Files.getFileExtension(source.getFileName().toString());
|
||||||
String pathCopy = null;
|
String pathCopy = null;
|
||||||
pathCopy = Files.move(source, source.resolveSibling("COPY.webm")).toString();
|
pathCopy = java.nio.file.Files.move(source, source.resolveSibling("COPY." + extension)).toString();
|
||||||
log.warn("Fixing file '{}' with ffmpeg", filePath);
|
log.warn("Fixing file '{}' with ffmpeg", filePath);
|
||||||
String cmd = "ffmpeg -i " + pathCopy + " -vcodec copy -acodec copy " + filePath;
|
String cmd = "ffmpeg -i " + pathCopy + " -vcodec copy -acodec copy " + filePath;
|
||||||
this.executer.executeCommand(cmd);
|
this.executer.executeCommand(cmd);
|
||||||
|
|
|
@ -24,16 +24,21 @@ import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.common.io.Files;
|
||||||
|
|
||||||
public class Unzipper {
|
public class Unzipper {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(Unzipper.class);
|
private static final Logger log = LoggerFactory.getLogger(Unzipper.class);
|
||||||
|
|
||||||
|
private final Set<String> VIDEO_EXTENSIONS = Set.of("webm", "mkv", "mp4");
|
||||||
|
|
||||||
public List<File> unzipFile(String path, String fileName) {
|
public List<File> unzipFile(String path, String fileName) {
|
||||||
final int BUFFER = 2048;
|
final int BUFFER = 2048;
|
||||||
final List<File> recordingFiles = new ArrayList<>();
|
final List<File> recordingFiles = new ArrayList<>();
|
||||||
|
@ -44,7 +49,8 @@ public class Unzipper {
|
||||||
ZipEntry entry;
|
ZipEntry entry;
|
||||||
while ((entry = zis.getNextEntry()) != null) {
|
while ((entry = zis.getNextEntry()) != null) {
|
||||||
log.info("Extracting: " + entry);
|
log.info("Extracting: " + entry);
|
||||||
if (entry.getName().endsWith(".webm")) {
|
String fileExtension = Files.getFileExtension(entry.getName());
|
||||||
|
if (VIDEO_EXTENSIONS.contains(fileExtension)) {
|
||||||
recordingFiles.add(new File(path + entry.getName()));
|
recordingFiles.add(new File(path + entry.getName()));
|
||||||
}
|
}
|
||||||
int count;
|
int count;
|
||||||
|
|
Loading…
Reference in New Issue