[mythtv] Difficulties with FFmpeg and mediacodec

Peter Bennett pb.mythtv at gmail.com
Mon Jun 4 15:15:38 UTC 2018


I am trying to get hardware assisted decoding working on android.

I added to the ffmpeg configure the parameters --enable-mediacodec and 
--enable-jni. Also for good measure I added 
--enable-hwaccel=h264_mediacodec.

The configure and make of ffmpeg are successful but the configure output 
shows nothing under the heading "Enabled hwaccels:", nothing under 
"External libraries providing hardware acceleration:". It does show 
"mediacodec" under "External libraries:". Under "Enabled Decoders:" it 
does show h264_mediacodec, hevc_mediacodec, mpeg2_mediacodec and several 
others with _mediacodec.

Should it not list mediacodec under "Enabled hwaccels"? In normal Linux 
builds it lists vdpau, vaapi and crystalhd there.

I used this code to find a hwaccel for my video:

enumAVHWDeviceType type =AV_HWDEVICE_TYPE_MEDIACODEC;
for(inti =0;; i++) {
constAVCodecHWConfig *config =avcodec_get_hw_config(codec, i);
if(!config) {
LOG(VB_PLAYBACK, LOG_INFO, LOC +
QString("Decoder %1 does not support device type %2.")
.arg(codec->name).arg(av_hwdevice_get_type_name(type)));
break;
}
if(config->methods&AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX &&
config->device_type==type) {
fmt =config->pix_fmt;
break;
}
}

The codec was created from the AVStream in the normal way. codec->name 
was h264. config was null on the first iteration (index 0), indicating 
that there is no hardware acceleration available.

The code comes from the ffmpeg sample program hw_decode.c.

Perhaps there is a different way I should be doing it? Is there any 
mediacodec sample code? Perhaps there is some android library that is 
needed but not found?

On a side note - I tested playback through MythTV without hardware 
assist - The NVidia Shield plays 1920x1080 content perfectly without 
hardware assist, but playing 3840x2160 is slow and jerky. Playing the 
3840x2160 video with Kodi on the Shield is perfect. Playing 3840x2160 
through MythTV on Linux is also fine, with or without hardware assist 
(vaapi).

Attached are patches if anybody want to try it. One patch for mythtv and 
one for packaging.

Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-dev/attachments/20180604/69c22ba2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20180604_1108_packaging.patch
Type: text/x-patch
Size: 832 bytes
Desc: not available
URL: <http://lists.mythtv.org/pipermail/mythtv-dev/attachments/20180604/69c22ba2/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20180601_1901_mediacodec.patch
Type: text/x-patch
Size: 18375 bytes
Desc: not available
URL: <http://lists.mythtv.org/pipermail/mythtv-dev/attachments/20180604/69c22ba2/attachment-0001.bin>


More information about the mythtv-dev mailing list