havlenapetr / FFMpeg

this is port of ffmpeg for android (this is app, but in future i will do android lib from it and then system will be able to convert videos automatically)
881 stars 419 forks source link

How to show the video frame? #40

Closed easycui closed 13 years ago

easycui commented 13 years ago

There is such a code "Output::VideoDriver_updateSurface();" in "void MediaPlayer::decode(AVFrame* frame, double pts)". I guess it would show the decoded frame( sPlayer->mFrame). But i cannot realize that how it works and how it sends the data of frame to video driver. Could you give me some help?

havlenapetr commented 13 years ago

Hi I am creating bitmap with ffmpeg screen size, than I pull pixels from this bitmap and pass them to ffmpeg, so ffmpeg is drawing directly into android's bitmap(this solution should be the most fastest). This code initializes pixels:

void* pixels; if (Output::VideoDriver_getPixels(stream->codec->width, stream->codec->height, &pixels) != ANDROID_SURFACE_RESULT_SUCCESS) { return INVALID_OPERATION; }

mFrame = avcodec_alloc_frame();
if (mFrame == NULL) {
    return INVALID_OPERATION;
}
// pass pixels from android bitmap into ffmpeg
avpicture_fill((AVPicture *) mFrame,
               (uint8_t *) pixels,
               PIX_FMT_RGB565,
               stream->codec->width,
               stream->codec->height);
easycui commented 13 years ago

Get it. Thanks a lot!