使用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");
相关推荐
水獭比特8 小时前
自动成片没报错,为什么音画还会漂?
ffmpeg
Yeauty8 小时前
2026 年在 Rust 里处理音视频,该走哪条路?
rust·ffmpeg·音视频·视频
勿忘初心12211 天前
【Windows流媒体实战1】FFmpeg+Nginx-RTMP Windows详细搭建教程
ffmpeg·nginx-rtmp·windows流媒体搭建·rtmp直播
Yeauty4 天前
你那条 ffmpeg 命令,一键翻成 Rust builder 代码
开发语言·rust·ffmpeg
Yeauty5 天前
用 Whisper 转录前,你不用再离开 Rust
开发语言·rust·ffmpeg·音视频·视频
paokuflying6 天前
ffmpeg提取视频中的音频
ffmpeg·音视频
Tirzano6 天前
java 精简使用ffmpeg
java·开发语言·ffmpeg
兵叔物联8 天前
基于FFmpeg的短视频自动剪辑工具
ffmpeg·音视频
霸道流氓气质10 天前
视频预览链路三件套:ZLMediaKit · MediaMTX · FFmpeg 完全指南
ffmpeg·音视频
xgc_java10 天前
在Java里把ONNX/OpenCV/FFmpeg跑稳:28篇bytedeco实战小册完整指南
java·opencv·ffmpeg