Skip to content

Commit

Permalink
build: add ffmpeg and javacv dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
li-guohao committed Sep 6, 2023
1 parent f79b608 commit 8c27f92
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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'
Expand Down
41 changes: 41 additions & 0 deletions server/src/test/java/run/ikaros/server/ffmpeg/FfmpegTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}


}

0 comments on commit 8c27f92

Please sign in to comment.