[FFmpeg-trac] #6629(avdevice:new): Assertion failed when specifying h264 format on v4l2 device that does NOT support h264
FFmpeg
trac at avcodec.org
Thu Aug 31 06:19:18 EEST 2017
#6629: Assertion failed when specifying h264 format on v4l2 device that does NOT
support h264
-------------------------------------+-------------------------------------
Reporter: Mr-Dave | Type: defect
Status: new | Priority: normal
Component: avdevice | Version: git-
Keywords: avdevice | master
v4l2 input_format | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Summary of the bug:
When opening the format context to a v4l2 device and have specified a
format which the device does NOT support, the avformat_open_input
assertion fails.
How to reproduce:
Sample code using a device that does NOT support h264
{{{
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <libavformat/avformat.h>
#include <libavdevice/avdevice.h>
#include <libavutil/avutil.h>
int main (int argc, const char **argv) {
AVFormatContext *format_context;
AVDictionary *opts = 0;
int retcd;
char errstr[128];
char optfmt[8];
av_register_all();
avcodec_register_all();
avformat_network_init();
avdevice_register_all();
format_context = avformat_alloc_context();
format_context->iformat = av_find_input_format("video4linux2");
sprintf(optfmt, "%s","h264");
av_dict_set(&opts, "input_format", optfmt, 0);
retcd = avformat_open_input(&format_context, "/dev/video0", NULL,
&opts);
fprintf(stderr,"Format context is open: \n");
if (retcd < 0){
av_strerror(retcd, errstr, sizeof(errstr));
fprintf(stderr,"error opening file: %s \n",errstr);
av_dict_free(&opts);
return -1;
}
fprintf(stderr,"Device is open: \n");
avformat_close_input(&format_context);
return 0;
}
}}}
Output:
{{{
./sample
[video4linux2,v4l2 @ 0x3d4a420] Cannot find a proper format for codec
'h264' (id 28), pixel format 'none' (id -1)
Assertion *codec_id != AV_CODEC_ID_NONE failed at libavdevice/v4l2.c:808
Aborted (core dumped)
}}}
Expected result:
avformat_open_input would return a error code.
ffmpeg version:
{{{
/home/dave/ffmpeg_33/bin/ffmpeg
ffmpeg version 3.3 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/home/dave/ffmpeg_33 --pkg-config-flags=--static
--extra-cflags=-I/home/dave/ffmpeg_33/include --extra-
ldflags=-L/home/dave/ffmpeg_33/lib --bindir=/home/dave/ffmpeg_33/bin
--enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options]
outfile}...
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/6629>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list