[mythtv-commits] Ticket #13186: Replace deprecated ffmpeg functions
MythTV
noreply at mythtv.org
Tue Dec 12 20:30:59 UTC 2017
#13186: Replace deprecated ffmpeg functions
------------------------------+-----------------------------
Reporter: pbennett | Owner: pbennett
Type: Developer Task | Status: accepted
Priority: minor | Milestone: 30.0
Component: MythTV - General | Version: Master Head
Severity: medium | Resolution:
Keywords: | Ticket locked: 0
------------------------------+-----------------------------
Comment (by pbennett):
Patch 005 - deprecated AVStream::codec and avcodec_close
In the old method, ffmpeg automatically creates an AVCodecContext for
every AVStream. The context can be opened and closed again any number of
times. This is deprecated and the application code is now responsible for
creating and freeing an AVCodecContext when needed. The AVCodecContext
that the application creates may not be opened and closed more than once.
The deprecated function avcodec_close must not be called on an
AVCodecContext that you create, instead you have to free the
AVCodecContext (using avcodec_free_context) and allocate a new one if you
want to read the stream again.
"codec" no longer shows in the online documentation for AVStream. It is
only defined in ffmpeg if you define FF_API_LAVF_AVCTX when compiling
ffmpeg. See external/FFmpeg/libavformat/version.h, which has a list of
defines that will be set in future to disable this and others. For more
information google FF_API_LAVF_AVCTX. Instead of AVStream::codec, the
AVStream::codecpar structure contains the information you need to allocate
your own AVStream.
Old code for AVStream::codec
{{{
AVCodecContext *avctx = stream->codec;
}}}
new code using AVStream::codecpar
{{{
AVCodec *pCodec = avcodec_find_decoder(stream->codecpar->codec_id);
AVCodecContext *avctx = avcodec_alloc_context3(pCodec);
avcodec_parameters_to_context(avctx, stream->codecpar);
av_codec_set_pkt_timebase(avctx, stream->time_base);
}}}
The avctx must saved and the same value used for subsequent calls with
that stream. Existing code which uses stream->codec must instead keep
track of the axctx value to use each time a packet is received.
Old Code for avcodec_close:
{{{
avcodec_close(st->codec);
}}}
New code using avcodec_free_context:
{{{
avcodec_free_context(&avctx);
}}}
Note the old code must still be used for any AVCodecContext obtained from
stream->codec.
DVD menu highlighting on the title menu has been working intermittently
for some time. That makes it very difficult to navigate a DVD. It seems to
be working consistently correctly after these changes, although I could
not identify which change made the difference.
The patch is tested with Standard decoding(ffmpeg), VAAPI, VDPAU, OpenMAX
(Raspberry pi). Tested playback of recordings, Live TV, Videos, DVD's'.
Some areas not yet changed and not tested. In particular, crystal HD,
Windows, and Apple MAC playback may not work. Also transcode has not yet
been updated.
--
Ticket URL: <https://code.mythtv.org/trac/ticket/13186#comment:5>
MythTV <http://www.mythtv.org>
MythTV Media Center
More information about the mythtv-commits
mailing list