使用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");
相关推荐
Echo_NGC22371 天前
【FFmpeg 使用指南】Part 3:码率控制策略与质量评估体系
人工智能·ffmpeg·视频·码率
xmRao2 天前
Qt+FFmpeg 实现 PCM 音频转 AAC 编码
qt·ffmpeg·pcm
xmRao2 天前
Qt+FFmpeg 实现录音程序(pcm转wav)
qt·ffmpeg
阿里巴啦3 天前
python+yt-dlp开源项目,支持 YouTube, Bilibili, TikTok/抖音,快手 等多个平台的视频/音频/字幕下载/ai摘要等功能
python·ffmpeg·whisper·音视频·视频处理·ai摘要·音视频转录
来鸟 鸣间4 天前
linux下ffmpeg源码编译
linux·运维·ffmpeg
Echo_NGC22374 天前
【FFmpeg使用指南】Part 2:滤镜图架构与信号处理
架构·ffmpeg·音视频·信号处理
Echo_NGC22374 天前
【FFmpeg使用指南】Part 1:核心架构与媒体流处理
ffmpeg·音视频·媒体·视频
ssxueyi4 天前
用 Claude Code 从零开发自己的Direct3D 硬件加速播放器
ffmpeg·ai编程·directx·视频播放器·从零开始·claude code·csdn征文活动
Yan_uuu4 天前
ubuntu18.04 安装 x264、ffmpeg、nv-codec-hearers 支持GPU硬件加速
c++·图像处理·ubuntu·ffmpeg
runner365.git4 天前
做一个基于ffmpeg的AI Agent智能体
人工智能·ffmpeg·大模型