bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.53k stars 1.58k forks source link

AVFormat not being detected? #2000

Closed polvallverdu closed 1 year ago

polvallverdu commented 1 year ago

I'm having this issue:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.bytedeco.ffmpeg.avformat.AVFormatContext.duration()" because "this.oc" is null
    at org.bytedeco.javacv.FFmpegFrameGrabber.getLengthInTime(FFmpegFrameGrabber.java:876)
    at org.bytedeco.javacv.FFmpegFrameGrabber.getLengthInVideoFrames(FFmpegFrameGrabber.java:882)
    at org.bytedeco.javacv.FFmpegFrameGrabber.getLengthInFrames(FFmpegFrameGrabber.java:872)
    at dev.polv.mediaextractor.Extractor.<init>(Extractor.java:38)
    at dev.polv.mediaextractor.AudioExtractor.<init>(AudioExtractor.java:17)
    at Main.main(Main.java:6)

My gradle is:

plugins {
    id("java")
    id("maven-publish")
    // id("com.github.johnrengelman.shadow").version("7.1.2")
}

group = "dev.polv"
version = "0.2.2"

repositories {
    mavenCentral()
}

dependencies {
    testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")

    implementation("org.bytedeco:javacv-platform:1.5.8")
    implementation("org.bytedeco:ffmpeg-platform:5.1.2-1.5.8")
}

tasks.getByName<Test>("test") {
    useJUnitPlatform()
}

publishing {
    publications {
        create<MavenPublication>("maven") {
            groupId = project.group.toString()
            artifactId = "MediaExtractor"
            version = project.version.toString()

            from(components["java"])
        }
    }

    repositories {
        maven {
            url = uri("file://" + System.getenv("local_maven"))
        }
    }
}

I can't also seem to access av related classes.

saudet commented 1 year ago

Did you call start()?

polvallverdu commented 1 year ago

I didn't had all the needed libraries on windows, and I suppose when building it wasn't getting AV or something. It's now solved