使用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");
相关推荐
小希smallxi10 小时前
Java 程序调用 FFmpeg 教程
java·python·ffmpeg
小希smallxi12 小时前
FFmpeg: 免费、开源、跨平台的多媒体处理工具集
ffmpeg·开源
智算菩萨15 小时前
FFMpeg全解析:从“万能媒体转换器”到工程化音视频管线的底层逻辑
ffmpeg·音视频·媒体
weixin_462446232 天前
Python + FFmpeg 批量提取视频音频(支持 Windows / macOS / Linux)
python·ffmpeg·音视频
一点晖光2 天前
ffmpeg实现图片转视频缩放效果
ffmpeg·音视频
blog.pytool.com2 天前
LVGL 驱动地址自动变更为32 位的问题
ffmpeg
知南x2 天前
【物联网视频监控系统----韦东山老师视频总结】(4)流媒体方案的实现之ffmpeg
ffmpeg·音视频
kkoral2 天前
FFmpeg 零基础入门教程
ffmpeg
小Tomkk4 天前
⭐️ StarRocks Web 使用介绍与实战指南
前端·ffmpeg