bytedeco / javacv

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

Unsupported video format or codec not found for AV1 videos #1656

Open mlipkovich opened 3 years ago

mlipkovich commented 3 years ago

Hello,

I'm trying to use FFmpegFrameGrabber with AV1 videos:

import org.bytedeco.javacv.FFmpegFrameGrabber
import org.bytedeco.javacv.FFmpegLogCallback

FFmpegLogCallback.set()

val url = "https://www.elecard.com/storage/video/Stream1_AV1_720p_1.5mbps.webm"
val frameGrabber = new FFmpegFrameGrabber(url)
frameGrabber.start()

but it fails with the following error:

Info: Input #0, matroska,webm, from 'https://www.elecard.com/storage/video/Stream1_AV1_720p_1.5mbps.webm':

Info:   Metadata:

Info:     encoder         : 
Info: libwebm-0.2.1.0
Info: 

Info:   Duration: 
Info: 00:02:54.20
Info: , start: 
Info: 0.000000
Info: , bitrate: 
Info: 1458 kb/s
Info: 

Info:     Stream #0:0
Info: (eng)
Info: : Video: av1 (Main), yuv420p(tv), 1280x720
Info: , SAR 1:1 DAR 16:9
Info: , 
Info: 25 fps, 
Info: 25 tbr, 
Info: 1k tbn, 
Info: 1k tbc
Info:  (default)
Info: 

org.bytedeco.javacv.FFmpegFrameGrabber$Exception: avcodec_find_decoder() error: Unsupported video format or codec not found: 32797. (For more details, make sure FFmpegLogCallback.set() has been called.)
  at org.bytedeco.javacv.FFmpegFrameGrabber.startUnsafe(FFmpegFrameGrabber.java:968)
  at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:846)
  at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:841)
  ... 36 elided

This number 32797 corresponds to decoder AV_CODEC_ID_AV1. If i set it explicitly it also doesn't work

import org.bytedeco.ffmpeg.global.avcodec
avcodec.avcodec_find_decoder_by_name("AV_CODEC_ID_AV1")

returns null.  

I'm using the following dependencies:

  "org.bytedeco" % "javacv" % "1.5.5",
  "org.bytedeco" % "ffmpeg-platform" % "4.3.2-1.5.5"

also tried to switch to

"org.bytedeco" % "javacv-platform" % "1.5.5"

with no success.  

Am I missing some native libraries?  

It works fine when I use the same URL with command line ffmpeg (version 4.1), OS Debian 10

saudet commented 3 years ago

I suppose we would need to enable support for that codec. Contributions are welcome!

mlipkovich commented 3 years ago

Thank you for your response! Are there Pull Requests with similar changes so that I could see how it should be done? Or maybe some docs?

saudet commented 3 years ago

Sure, something like this: https://github.com/bytedeco/javacpp-presets/pull/1036