使用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");
相关推荐
天天进步201512 小时前
Pixelle-Video 源码解析 #4:快速启动流程:uv、Streamlit、ffmpeg 分别负责什么?
ffmpeg·uv
HY小宝F12 小时前
从 APP 层打穿到传感器:树莓派 FFmpeg 底层学习笔记(一)V4L2/ALSA 踩坑与认知重构
笔记·学习·ffmpeg
proware2 天前
ffmpeg 初始化配置及基本概念与套路
ffmpeg·mpp·rockchip·rga
程序员老陆2 天前
FFmpeg的AVFrame全部数据操作函数详解
ffmpeg·音视频·avframe
glumes2 天前
从《牛来》到 DCP:一部电影是怎么走进电影院的?
ffmpeg·音视频开发
程序员老陆3 天前
FFmpeg RTSP 解复用器(rtsp demuxer)完全解析:从「能播」到「稳播」的参数圣经
ffmpeg·音视频·拉流·rtsp
诸葛大钢铁5 天前
视频转音频怎么转换?在线工具、VLC、FFmpeg 三种方法详解
ffmpeg·音视频·mp4转mp3·视频转音频·视频转mp3·视频提取音频
qingmiaozhuan5 天前
电脑录屏软件追剧高光截取:FFmpeg帧裁剪与可视化方案对比
ffmpeg·电脑·音视频开发·录屏技术·电脑录屏
程序员老陆5 天前
FFmpeg6操作 RTMP参数详解
ffmpeg·音视频·rtmp
戒了,最后一次5 天前
Windows 安装 FFmpeg 完整教程(附环境变量配置 + 常用命令示例)
windows·ffmpeg