zoukankan      html  css  js  c++  java
  • FFmpeg(12)-使用NDK通过GLSurfaceView完成视频的播放

    一.包含头文件和库文件

    这里采用的是NDK中的ANativeWindow来完成视频的播放,因为需要添加相关的库和头文件。

    CMakeLists

    target_link_libraries( # Specifies the target library.
                           native-lib
                           avcodec
                           avformat
                           avutil
                           swscale
                           swresample
                           android
    
                           # Links the target library to the log library
                           # included in the NDK.
                           ${log-lib} )

    添加头文件 

    #include <android/native_window.h>
    #include <android/native_window_jni.h>

    二.示例代码

    // 显示窗口初始化
        ANativeWindow *window = ANativeWindow_fromSurface(env, surface);
        if (!window) {
            LOGE("ANativeWindow_fromSurface create failed");
            return;
        }
        ANativeWindow_setBuffersGeometry(window, outWidth, outHeight, WINDOW_FORMAT_RGBA_8888);
        ANativeWindow_Buffer wbuf;
    if (h > 0) {
                            ANativeWindow_lock(window, &wbuf, 0);
                            uint8_t *dst = (uint8_t *)wbuf.bits; // 这个dst是用来交换的内存
                            memcpy(dst, rgb, outWidth*outHeight*4);
                            ANativeWindow_unlockAndPost(window);
                        }
  • 相关阅读:
    穷举和迭代
    for循环练习题
    case when then else end 用法
    如何将数据库账号(用户)解锁
    比赛安排
    How to spend you day ?
    异常-问题型
    重载和重写的区别
    new关键字的理解-问题型
    源辰项目-1
  • 原文地址:https://www.cnblogs.com/yongdaimi/p/9834843.html
Copyright © 2011-2022 走看看