You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Null Codec here means "use vst for the codec selection" and needed only for some corner cases, when codec overriding are needed:
... CodecContext2()...
...
Codec c = codec;
if (codec.isNull())
{
if (st.direction() == Direction::Decoding)
c = findDecodingCodec(codecId);
else
c = findEncodingCodec(codecId);
}
...
Open routine can be simplified to:
vdec.open(ec);
This mostly same to
vdec.open(Codec(), ec);
For opening this routine are used:
void CodecContext2::open(const Codec &codec, AVDictionary **options, OptionalErrorCode ec)
{
clear_if(ec);
if (isOpened() || !isValid()) {
throws_if(ec, isOpened() ? Errors::CodecAlreadyOpened : Errors::CodecInvalid);
return;
}
int stat = avcodec_open2(m_raw, codec.raw(), options);
if (stat < 0)
throws_if(ec, stat, ffmpeg_category());
}
You may be confused, that avcodec_open2() calls with NULL codec. But, look into avcodec_open2() description:
* @param codec The codec to open this context for. If a non-NULL codec has been
* previously passed to avcodec_alloc_context3() or
* for this context, then this parameter MUST be either NULL or
* equal to the previously passed codec.
We are initialized VideoDecoderContext with the Stream reference. And already pass correct codec to the avcodec_alloc_context3(). So, now you have two ways:
Add extra unuseful code to pass correct codec into open()
Hello!
I am examining your project and decode/encode examples.
I found some strange places in the examples
Decode:
During initialization of VideoDecoderContext your code initializes Codec object and sets the code to the context
After that you call
open()
function with new objectCodec()
.However, in the example from ffmpeg documentation the codec initialized with
avcodec_find_decoder
is passed to theavcodec_open2
.The similar strange thing is with encode example:
You create
ocodec
, but pass to encoder some new object.Could you please explain why do you use uninitialized Codec object when you open decoder and encoder ?
The text was updated successfully, but these errors were encountered: