ffmpeg-打开媒体文件-avio_open_dir-avio_read_dir

vio_open_dir


avio_read_dir


avio_free_directory_entry


avio_close


Code
#include
void dir_function(void)
{
AVIOContext * ctx = NULL; // 目录操作上下文
AVIODirEntry * entry = NULL; // 目录项
av_log_set_level(AV_LOG_DEBUG); // 设置日志等级
int ret = avio_open_dir(&ctx, "./A", NULL);
if (ret < 0)
{
av_log(NULL, AV_LOG_ERROR, "cant open dir %s\n", av_err2str(ret));
goto __fail;
}
#if 0
ret = avio_read_dir(ctx, &entry);
av_log(NULL, AV_LOG_INFO,
"File Name:%s, File Size:%ld\n", entry->name, entry->size);
avio_free_directory_entry(&entry);
avio_free_directory_entry(&entry);
goto __fail;
#endif
while (1)
{
ret = avio_read_dir(ctx, &entry);
if (ret < 0)
{
av_log(NULL, AV_LOG_ERROR, "Cant read dir\n");
goto __fail;
}
// 如果entry是NULL,则代表目录到末尾退出
if (!entry)
break;
av_log(NULL, AV_LOG_INFO,
"File Name:%s, File Size:%ld\n", entry->name, entry->size);
avio_free_directory_entry(&entry);
}
__fail:
avio_close(&ctx);
}

参考链接

posted @   steve的miao  阅读(83)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
点击右上角即可分享
微信分享提示