日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

ffmpeg開發(fā)讀取目錄列表

作者:reg183 更新時(shí)間: 2022-03-14 編程語言

新建文件ffmpeg_dir.c

#include<stdio.h>
#include<libavutil/avutil.h>
#include<libavformat/avformat.h>
int main(int argc,char* argv[]){
        int ret;
        av_register_all();
        AVIODirContext *ctx=NULL;
        AVIODirEntry *entry=NULL;
        av_log_set_level(AV_LOG_INFO);
        ret=avio_open_dir(&ctx,"../",NULL);

        if(ret<0){
                av_log(NULL,AV_LOG_ERROR,"can not open dir:%s\n",av_err2str(ret));
                goto __fail;
        }
        while(1){
                ret = avio_read_dir(ctx,&entry);
                if(ret<0){
                        av_log(NULL,AV_LOG_ERROR,"can not read dir:%s\n",av_err2str(ret));
                        goto __fail;
                }
                if(!entry){
                        break;
                }

                av_log(NULL,AV_LOG_INFO,"%12"PRId64" %s \n",entry->size,entry->name);
                avio_free_directory_entry(&entry);
        }
__fail:
        avio_close_dir(&ctx);
        return 0;
}

編譯

[root@localhost c]# gcc -g -o ffmpeg_dir ffmpeg_dir.c `pkg-config --libs --cflags libavutil libavformat`

執(zhí)行完成沒有報(bào)錯(cuò)證明編譯成功
查看是否生成了可執(zhí)行文件ffmpeg_dir

執(zhí)行下面的命令,執(zhí)行結(jié)果如下,表明程序執(zhí)行成功
在這里插入圖片描述
這里列出了我的上一級(jí)目錄的所有文件

原文鏈接:https://blog.csdn.net/chendongpu/article/details/123248134

欄目分類
最近更新