bilibili / ijkplayer

Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.
GNU General Public License v2.0
32.41k stars 8.11k forks source link

Finding and assigning hardware decoder #4797

Open spaul13 opened 5 years ago

spaul13 commented 5 years ago

I am trying to assign a hardware video decoder and then use that decoder to decode my video frames.

_pCodec = avcodec_find_decoder_by_name("mediacodec-avc"); pCodecCtx = avcodec_alloc_context3(pCodec); if(avcodec_copy_context(pCodecCtx, pCodecCtxOrig) != 0) { ALOGD(stderr, "Couldn't copy codec context"); return -1; // Error copying codec context } if(avcodecopen2(pCodecCtx, pCodec, NULL)<0) { ALOGD("Video: Could not open codec\n"); return -1; } But it keeps showing the error message No codec is provided to avcodec_open2. Can anyone please tell me how can I find and assign hardware-decoder for android?

befovy commented 5 years ago

ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 1);

spaul13 commented 5 years ago

Hi, @befovy really thanks for the reply. Just one little help, Can u please tell me why after decoding using the ijkplayer code in queue_picture() [in ff_ffplay.c] the AVFrame *src_frame has no data[0], data[1], data[2] (they are all NULL, although the pix_fmt is YUVJ420P).

I can't see three dataplanes and linesizes for the decoded frames. can u please tell me why?

xccwxc commented 5 years ago

"mediacodec-avc" replace with "h264_mediacodec"