使用ffmpeg访问FileProvider 提供出去的content uri 问题

直接使用ffmpeg访问FileProvider 提供出去的content uri会报protocol not support,正确的方式是使用ffmpeg访问uri 转换后的 fd

cpp 复制代码
//---- 读、seek 回调 ----
static int readFn(void *opaque, uint8_t *buf, int buf_size) {
    int fd = (int) (intptr_t) opaque;
    return read(fd, buf, buf_size);
}

static int64_t seekFn(void *opaque, int64_t offset, int whence) {
    int fd = (int) (intptr_t) opaque;
    return lseek(fd, offset, whence);
}



// 1. AVIO
uint8_t *ioBuf = (uint8_t *) av_malloc(32768);
LOGI("extractFrameUri ++++++++++++++++++++++++ 3");
avio = avio_alloc_context(
        ioBuf, 32768, 0, (void *) (intptr_t) fd,
        readFn, nullptr, seekFn);
if (!avio) {
    LOGE("avio_alloc_context fail");
    goto cleanup;
}
LOGI("extractFrameUri ++++++++++++++++++++++++ 4");
// 2. 打开封装
fmt = avformat_alloc_context();
LOGI("extractFrameUri ++++++++++++++++++++++++ 5");
fmt->pb = avio;
if (avformat_open_input(&fmt, nullptr, nullptr, nullptr) < 0) {
    LOGE("avformat_open_input fail");
    goto cleanup;
}
LOGI("extractFrameUri ++++++++++++++++++++++++ 6");

// 开始进行抽帧处理
result = extract_video_with_time_range(fmt,
                                       outputDir,
                                       sectionList,
                                       frame_interval,
                                       clip_row_cnt, clip_column_cnt,
                                       use_soft_decode);
LOGI("extractFrameUri ++++++++++++++++++++++++ 7");
相关推荐
luoqice2 天前
RTMP视频流的帧格式分析
网络·ffmpeg
老姚---老姚2 天前
编译支持HEVC/H.265 over RTMP / Enhanced RTMP 的 ffmpeg
ffmpeg·h.265·hevc·rtmp·enhanced
码流怪侠4 天前
FFmpeg 开发实战全解析:从入门到精通(附完整代码示例)
ffmpeg·音视频开发·视频编码
圆弧YH4 天前
FFmpeg
ffmpeg
luoqice4 天前
FLV文件格式详解
ffmpeg
happybasic5 天前
在CMD下使用FFmpeg将.wav文件转换成指定的格式~
ffmpeg
shao9185165 天前
第10章 Streaming(上):初级音频应用(1)——项目三:自建服务器的Mini-Omni实时语音聊天机器人
ffmpeg·whisper·asr·mini-omni·自建语音服务器
Leon_Chenl5 天前
【已开源】【嵌入式 Linux 音视频+ AI 实战项目】瑞芯微 Rockchip 系列 RK3588-基于深度学习的人脸门禁+ IPC 智能安防监控系统
深度学习·opencv·yolo·ffmpeg·音视频·边缘计算·人脸识别+检测
antzou6 天前
视频图片/文字水印
ffmpeg·视频水印·批量水印
AC赳赳老秦7 天前
DBA 专属方案:用 OpenClaw 实现 SQL 语句优化、慢查询分析、数据库备份巡检全自动化
服务器·前端·数据库·ffmpeg·自动化·deepseek·openclaw