使用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");
相关推荐
紫金修道1 天前
【编解码】RK3588 平台基于 FFmpeg RKMPP 硬解的多路 RTSP 抓帧插件实战
ffmpeg·rkmpp
QMCY_jason1 天前
RK3588 交叉编译ffmpeg提示rockchip_mpp>=1.3.9 错误的问题
ffmpeg
Memory_荒年3 天前
FFmpeg:音视频界的“万能瑞士军刀”
ffmpeg
QJtDK1R5a3 天前
V4L2 vs GStreamer vs FFmpeg:Linux多媒体处理的三个层级
linux·运维·ffmpeg
AI视觉网奇6 天前
webrtc 硬编码
ffmpeg·webrtc
九转成圣6 天前
避坑指南:彻底解决 FFmpeg drawtext 烧录多行文本出现“方块(□)”乱码的终极方案
ffmpeg
bbq烤鸡6 天前
ffmpeg精确极速剪辑方案
ffmpeg
小镇学者6 天前
【python】 macos 安装ffmpeg 命令行工具
python·macos·ffmpeg
QMCY_jason6 天前
RK3588平台编译 ffmpeg-rockchip 使用rkmpp rkrga 进行硬件转码
ffmpeg
悢七7 天前
单机部署 OceanBase 集群
数据库·ffmpeg·oceanbase