Open KhuramKhalid opened 6 years ago
Can you try to initialize as follow?
val movie = new demux.Movie("helloworld.mp4")
I tried, it gives syntax error. However, if I try val movie = demux.Movie("helloworld.mp4")
then there isn't any syntax error but I get the above mentioned error again.
I think it might be related to the underlying native object being destroyed before the Scala counterpart is gone. Can you try the following? I will try to create a helloworld example for Scala as well.
import resource._
for (movie <- managed(demux.Movie("helloworld.mp4"))) {
println("video track duration: %d".format(movie.videoTrack.duration())
}
FYI: I didn't have the chance to test this snippet yet. It might be a while before I can provide a well tested sample.
I got the same error with the above code as well. As soon as I access the movie instance within loop, it breaks.
I also tried the following, but still the same error.
object UsingMovie {
def apply[T](src: String)(f: demux.Movie => T): T = {
val movie = demux.Movie(src)
try {
f(movie)
} finally {
movie.close()
}
}
}
object App {
def main(args: Array[String]): Unit = {
UsingMovie("helloworld.mp4") { movie =>
println("video track duration: %d".format(movie.videoTrack.duration()))
}
}
}
Ok, I'll have to do a deeper dive it seems. I'll keep the thread posted.
Best, Can On Dec 6, 2018, 2:34 AM -0800, Khuram U. Khalid notifications@github.com, wrote:
I also tried the following, but still the same error. object UsingMovie { def apply[T](src: String)(f: demux.Movie => T): T = { val movie = demux.Movie(src) try { f(movie) } finally { movie.close() } } } object App { def main(args: Array[String]): Unit = { UsingMovie("helloworld.mp4") { movie => println("video track duration: %d".format(movie.videoTrack.duration())) } } } — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Many thanks.
Native library throws exception when initialising
demux.Movie
object withByteData(arrayOfBytes)
Expected behavior
Should initialise the Movie object without exception.
Actual behavior
Native code throws exception.
Steps to reproduce the behavior
If possible, can you provide a Scala example.
hs_err_pid22716.log