两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 |
public:it:ffmpeg [2023/08/15 14:48] – [FFmpeg] oakfire | public:it:ffmpeg [2024/12/27 13:40] (当前版本) – [Tips] oakfire |
---|
pFormatCtx->flags = AVFMT_FLAG_NOBUFFER; | pFormatCtx->flags = AVFMT_FLAG_NOBUFFER; |
int ret = avformat_open_input(&pFormatCtx, ...);</code> | int ret = avformat_open_input(&pFormatCtx, ...);</code> |
* ''avformat_open_input'' 默认是阻塞的,如果是 tcp 连接,可设置 ''listen_timeout''(单位秒) 或者 ''stimeout''(单位微秒) 来达到超时处理;如果是 udp 连接,则可以设置中断回调 ''pFormatCtx->interrupt_callback'' | * ''avformat_open_input'' 默认是阻塞的,如果是 tcp 连接,<del>可设置 ''listen_timeout''(单位秒) 或者 ''stimeout''(单位微秒) 来达到超时处理</del>, 参考官网具体协议文档来设置tcp超时,比如 rtsp: https://ffmpeg.org/ffmpeg-protocols.html#rtsp;如果是 udp 连接,则可以设置中断回调 ''pFormatCtx->interrupt_callback'' |
* 关于视频流初始解析时间: | * 关于视频流初始解析时间: |
* ''avformat_find_stream_info'' 的返回时间和 ''pFormatCtx->probesize'' 与 ''pFormatCtx->max_analyze_duration'' 相关,哪个先达到就返回。 | * ''avformat_find_stream_info'' 的返回时间和 ''pFormatCtx->probesize'' 与 ''pFormatCtx->max_analyze_duration'' 相关,哪个先达到就返回。 |
* ''avcodec_flush_buffers'' 可直接清除解码器缓存帧,用于 seek 操作或切换流操作。 | * ''avcodec_flush_buffers'' 可直接清除解码器缓存帧,用于 seek 操作或切换流操作。 |
* ffmpeg 在 android 上解码音频:[[https://medium.com/@donturner/using-ffmpeg-for-faster-audio-decoding-967894e94e71|using-ffmpeg-for-faster-audio-decoding]] | * ffmpeg 在 android 上解码音频:[[https://medium.com/@donturner/using-ffmpeg-for-faster-audio-decoding-967894e94e71|using-ffmpeg-for-faster-audio-decoding]] |
| * ''avformat_open_input'' 会自动 free 第四个非空参数 ''*options'', 并把找不到的选项重新申请内存并返还给 ''*options'',所有需要手动判断 ''*options'' 是否非空并释放, 否则内存泄露 |
| |
| |