zoukankan      html  css  js  c++  java
  • FFMPEG 打印AVFrame的一些信息

    FFMPEG 打印AVFrame的一些信息

    
    void printFrameInfo(AVFrame *frame, const char *str, int log_level);
    
    void printf_hw_frame_ctx(AVHWFramesContext* hw_frame_ctx, const char * tagstr);
    
    void printf_device_ctx(AVCUDADeviceContext* device_hwctx, const char * tagstr);
    
    void printFrameInfo(AVFrame *frame, const char *str, int log_level)
    {
        if (av_log_get_level() >= log_level){
            if(!frame){
                fprintf(stderr,"%s is NULL
    ", str);
                return ;
            }
            AVFrame * f = frame;
            int is_video = frame->height>200 ;
            const char* ftype_str =  is_video ? "Video" : "Audio";
            fprintf(stderr, "%s %s data: %p %p %p , Pts:%09ld, Size:(%d %d) Linesize=(%d,%d,%d) Fmt:%d Frame:%p ",
                    str, ftype_str,f->data[0], f->data[1], f->data[2], f->pts, f->width, f->height, f->linesize[0], f->linesize[1], f->linesize[2], f->format, f);
            if (is_video){
                uint8_t * data = f->data[0];
                if( frame->format != AV_PIX_FMT_CUDA ){
                    if( data ){
                        fprintf(stderr, "Data: %03d %03d %03d %03d ",data[0], data[1], data[2], data[3]);
                    }else{
                        fprintf(stderr, "Data: NULL ",data[0], data[1], data[2], data[3]);
                    }
                }
            }
            else  {
                short *data = (short *)f->data[0];
                if(data){
                    fprintf(stderr, "SampleRate:%d Channel:%d Layout:%ld Data: %d %d %d %d ", f->sample_rate, f->channels, f->channel_layout, data[0], data[1], data[2], data[3]);
                }
            }
            fprintf(stderr, "
    ");
        }
    }
    
    
    void printf_hw_frame_ctx(AVHWFramesContext* hw_frame_ctx, const char * tagstr)
    {
        fprintf(stderr, "%s: ", tagstr);
        AVHWFramesContext* ctx = hw_frame_ctx;
        fprintf(stderr, "hwctx:%p ", hw_frame_ctx);
        AVCUDADeviceContext *device_hwctx = hw_frame_ctx->device_ctx->hwctx;
        int deviceid = -1;
        device_hwctx->internal->cuda_dl->cuDeviceGet(&deviceid, 0);
    
        if( hw_frame_ctx != NULL ) {
            ctx->width;
            ctx->sw_format;
            fprintf(stderr, "Size(%d,%d) Fmt:%d Device:%d", ctx->width, ctx->height, ctx->sw_format, deviceid);
        }
    
        fprintf(stderr, "
    ");
    }
    
    void printf_device_ctx(AVCUDADeviceContext* device_hwctx, const char * tagstr)
    {
        fprintf(stderr, "%s: ", tagstr);
        if( device_hwctx != NULL ) {
            size_t i;
            for(  i=0; i!= sizeof(AVCUDADeviceContext); ++i ){
                printf("%x ", ((uint8_t *)device_hwctx)[i]);
            }
        }
        printf("
    ");
    }
    
  • 相关阅读:
    数据库分表之Mybatis+Mysql实践
    mysql中You can't specify target table for update in FROM clause错误
    SQL中的limit用法
    在电脑端打开apk文件
    mysql进阶(五)数据表中带OR的多条件查询
    Java之——汉字转换拼音(大小写)
    数据库查询模糊匹配
    produces在@requestMapping中的使用方式和作用
    JSONP跨域请求数据报错 “Unexpected token :”的解决办法
    C# TcpClient的Connect超时处理(Timeout)
  • 原文地址:https://www.cnblogs.com/luoyinjie/p/14471523.html
Copyright © 2011-2022 走看看