avcpp icon indicating copy to clipboard operation
avcpp copied to clipboard

How to use api2-decode-encode-video

Open jeroen opened this issue 6 years ago • 3 comments

I am trying to build a tool to convert a bunch of png's into a video. I figured the best place to start was the example api2-decode-encode-video.cpp but I don't understand how to use the example. I compiled it using homebrew ffmpeg 4.0.2 on MacOS and then run with:

./api2-decode-encode-video input.png out.mkv

The line above always crashes when initiating the VideoEncoderContext with an error:

libc++abi.dylib: terminating with uncaught exception of type av::Exception: Codec context invalid media type

I tried other output names but get the same error. How am I supposed to use this example?

jeroen avatar Aug 22 '18 15:08 jeroen

Seems that codecpar using required new way for creation streams and codec contexts :-\ In current way codecpar keeps uninitialized, as result - media_type is UNKNOWN and exception is thrown.

h4tr3d avatar Aug 24 '18 01:08 h4tr3d

Heh, currently I have no time for correct fix. Quick WA is replace line:

#define USE_CODECPAR (LIBAVFORMAT_VERSION_MAJOR >= 58)

to

#define USE_CODECPAR (0)

at the https://github.com/h4tr3d/avcpp/blob/master/src/avutils.h

h4tr3d avatar Aug 30 '18 05:08 h4tr3d

WA was committed: https://github.com/h4tr3d/avcpp/commit/20b296b7c6d7bded8dd222f6e7efa838fe0c3eb4

h4tr3d avatar Aug 30 '18 05:08 h4tr3d