Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the avformat_open_input() do?

Tags:

c

ffmpeg

I am following this code to work with FFmpeg library in C. FFmpeg library has very little documentation and it is difficult to understand what each function exactly does.

I understand the code (what is being done). But I am lacking clarity. Can anyone help me out please?

Q1) A **struct AVFrameContext **** and filename (the minimum non-NULL parameters required) are passed to the function avformat_open_input(). As the name suggests, the input file is 'opened'. How ?

like image 534
progammer Avatar asked Jan 03 '13 07:01

progammer


2 Answers

The main things that gets done in file_open are

  • Allocate memory for AVFormatContext.
  • Read the probe_size about of data from the file (input url)
  • Tries to guess the input file format, codec parameter for the input file. This is done by calling read_probe function pointer for each of the demuxer
  • Allocate the codec context, demuxed context, I/O context.
like image 65
rajneesh Avatar answered Oct 11 '22 23:10

rajneesh


You can look it up in FFmpeg's libavformat\utils.c what is really taking place there:

int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
{
    AVFormatContext *s = *ps;
    int ret = 0;
    AVDictionary *tmp = NULL;
    ID3v2ExtraMeta *id3v2_extra_meta = NULL;

    if (!s && !(s = avformat_alloc_context()))
        return AVERROR(ENOMEM);
        // on and on
like image 22
Roman R. Avatar answered Oct 12 '22 01:10

Roman R.