一. av_guess_format()函数
原型
AVOutputFormat *av_guess_format(const char *short_name,
const char *filename,
const char *mime_type);
av_guess_format中支持的short_name格式可以通过下面命令获取
[root@node_94 cmake-build-debug-remote-host]# ffmpeg -formats|grep jpeg
ffmpeg version 3.4.7 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
configuration: --enable-gpl --enable-libx264 --enable-vaapi --enable-avresample --enable-shared --enable-cuda --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
D jpeg_pipe piped jpeg sequence
D jpegls_pipe piped jpegls sequence
DE mjpeg raw MJPEG video
D mjpeg_2000 raw MJPEG 2000 video
DE mpjpeg MIME multipart JPEG
E singlejpeg JPEG single image
DE smjpeg Loki SDL MJPEG
[root@node_94 cmake-build-debug-remote-host]#
可以看出jpeg编码支持的格式为
mjpeg
mpjpeg
singlejpeg
smjpeg
二. av_log_set_callback
在使用FFMPEG库的时候,如果有使用上的错误,FFMPEG 通过av_log 可以打印相应的消息到标准输出里。但有时候我们并没有标准输出,那么这个时候应该怎么处理呢?
方法:使用 av_log_set_callback 获取 av_log的打印输出。
示例如下:
void Init()
{
av_log_set_callback(&FFMPEG_Callback);
}
void FFMPEG_Callback(void* ptr, int level, const char* fmt, va_list vl)
{
// 可以根据level的级别选择要打印显示的内容
if (level <= AV_LOG_INFO)
{
char buffer[1024];
vsprintf(buffer, fmt, vl);
LOG_A("msg : [%d] %s", level, buffer);
}
}
三. avformat_open_input阻塞操作中断的支持
avformat_open_input默认是阻塞操作,如果不加控制,等待时间可能会达到30s以上,对于有些情况,等待30s的体验是无法接受的。
ffmpeg支持interrupt_callback机制,可以对输入(或输