diff --git a/server/build.gradle b/server/build.gradle index 8feec89e8..2ae40004f 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -53,6 +53,10 @@ ext { pf4j = '3.9.0' jsoup = '1.15.3' springDocOpenAPI = "2.0.2" + javaCvVersion = '1.5.9' + ffmpegVersion = '6.0' + osWindowsX86_64 = 'windows-x86_64' + osLinuxX86_64 = 'linux-x86_64' } dependencies { @@ -65,6 +69,13 @@ dependencies { implementation 'org.apache.httpcomponents.client5:httpclient5:5.2.1' implementation 'org.json:json:20230227' + // ffmpeg + implementation "org.bytedeco:javacv:$javaCvVersion" + implementation "org.bytedeco:javacpp-platform:$javaCvVersion" + implementation "org.bytedeco:ffmpeg:$ffmpegVersion-$javaCvVersion" + implementation "org.bytedeco:ffmpeg:$ffmpegVersion-$javaCvVersion:$osWindowsX86_64" + implementation "org.bytedeco:ffmpeg:$ffmpegVersion-$javaCvVersion:$osLinuxX86_64" + developmentOnly 'org.springframework.boot:spring-boot-devtools' testImplementation 'org.springframework.boot:spring-boot-starter-test' diff --git a/server/src/test/java/run/ikaros/server/ffmpeg/FfmpegTest.java b/server/src/test/java/run/ikaros/server/ffmpeg/FfmpegTest.java new file mode 100644 index 000000000..2223242a4 --- /dev/null +++ b/server/src/test/java/run/ikaros/server/ffmpeg/FfmpegTest.java @@ -0,0 +1,41 @@ +package run.ikaros.server.ffmpeg; + +import static org.bytedeco.ffmpeg.global.avformat.av_dump_format; +import static org.bytedeco.ffmpeg.global.avformat.avformat_close_input; +import static org.bytedeco.ffmpeg.global.avformat.avformat_find_stream_info; +import static org.bytedeco.ffmpeg.global.avformat.avformat_open_input; +import static org.bytedeco.ffmpeg.global.avutil.av_strerror; + +import org.bytedeco.ffmpeg.avformat.AVFormatContext; +import org.bytedeco.javacpp.BytePointer; +import org.bytedeco.javacpp.PointerPointer; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +public class FfmpegTest { + + static void check(int err) { + if (err < 0) { + BytePointer e = new BytePointer(512); + av_strerror(err, e, 512); + throw new RuntimeException( + e.getString().substring(0, (int) BytePointer.strlen(e)) + ":" + err); + } + } + + @Test + @Disabled + void getVideoInfo() { + String fileName = System.getenv("IKAROS_FFMPEG_TEST_VIDEO_URL"); + AVFormatContext inputFormatContext = new AVFormatContext(null); + try { + check(avformat_open_input(inputFormatContext, fileName, null, null)); + check(avformat_find_stream_info(inputFormatContext, (PointerPointer) null)); + av_dump_format(inputFormatContext, 0, fileName, 0); + } finally { + avformat_close_input(inputFormatContext); + } + } + + +}