FFMPEG and SDL APIs

Source: Internet
Author: User
FFMPEG and SDL APIs

Video decoding and display using the ffmpeg api and sdl api seem to be a bit technical. I recently received some emails asking about video decoding and display, today, hanyionet provides a blog article to briefly describe how to use these Apis. In fact, it is not difficult to use these Apis. Do not be afraid of complicated descriptions. All we need to do is first understand the process of video decoding and display, and then understand the role of each API.

The reality of decoding and video is generally like this:
Initialization-> decoding-> image scaling-> video display

The following is a simple process flow chart, which provides some important APIs in each step.

As you can see,The implementation of different steps is to find and use the corresponding API.

The API description in the figure is provided today.

FFmpeg API

Description

Av_register_all ()

Initializes libavformat and registers all the muxers, demuxers and protocols.

Avcodec_find_decoder (...)

Finds a decoder with a matching codec ID.

Avcodec_alloc_context ()

Allocates an avcodeccontext and sets its fields to default values.

Avcodec_alloc_frame ()

Allocates an avframe and sets its fields to default values.

Sws_getcontext (...)

Returns an swscontext to be used in sws_scale ().

Sws_scale (...)

Scales the data in source according to our settings in our swscontext C. srcstride and dststride are the Source and Destination linesize.

Avcodec_decode_video (...)

Decodes a video frame from buffer into picture.

 

SDL API

Description

Sdl_setvideomode ()

Set up a video mode with the specified width, height, and bits-per-pixel.

Sdl_createyuvoverlay ()

It is used to create a YUV overlay of the specified width, height and format for the provided display.

Sdl_blitsurface ()

This performs a fast bits from the source surface to the destination surface.

Sdl_freesurface ()

Frees (deletes) a SDL surface.

Sdl_updaterect ()

Makes sure the given area is updated on the given screen.

Sdl_flip ()

It is used to swap screen buffers. on hardware that supports double-buffering, this function sets up a flip and returns.

Sdl_freeyuvoverlay ()

Free a YUV video overlay.

In fact, to understand the ffmpeg api, another important thing is to understand the specific content of various data structures, such as avframe and avcodeccontext. I personally think these two structures are important.

After learning how to use these APIs, we should look for an example, such as ffplay. C or http://dranger.com/ffmpeg/. this example will be used, and the last example will be created based on this example.Video PlaybackProgram.

Enjoy!

This entry was posted in Streaming Media Technology

 

(Hanyionet)

This site Article All

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.