On the internet for a long time this aspect of the content, found that the online code is too old, the use of the old to even the latest version of the FFmpeg are not included, so for me this beginner is too pit pull. But after many times to find FFmpeg's header files and combined with the content of the Internet, finally successful can decode pull. Now put it out.The first is to initialize some of the parameters[CPP]View Plaincopy
The following initializes the
1. Network Abstraction Layer Unit type (NALU)Nalu is H264 used for network transmission of the unit type, a complete Nalu unit is generally 0x000001 or 0x00000001 start, followed by Nalu head and NALU data; When we were transmitting in the network, Will remove the start 0x000001 or 0x00000001, and you will typically need to replace them with the head of the RTP payload (1 bytes);Where NALU data is rbsp data;The Nalu header consists of a byte with the
To use mp4v2 for MP4 video recording, prepare the following information:
1. Obtain the mp4v2 source code and compile it into a library file. For mp4v2 compilation, see the previous article.Android compiles mp4v2 2.0.0 to generate a dynamic library;
2. Obtain the SPS and PPS data in h264 data. If not, you can view the previous article.Click the open link;
3. Obtain audio decoding information, which is used when mp4settrackesconfiguration is called. The
cvideoplayerutility API to play and control files or URLs.
Use your player to play local files.
Create your own player. Use cmdaaudiooutputstream for audio rendering (1) and use cdirectscreenaccess API for video rendering.
Use your own player to implement streaming video content.
Use Network APIs (rsocketserv, rconnection, rsocket) to connect to the network (2 ). Then, use cmdaaudiooutputstream for audio rendering and cdirectscreenaccess API for video rendering.
5
image quality and increase compression ratio, and can be used for sdtv, HDTV, and DVD. (3) extended profile: video and cabac are not supported, but some effective frame modes are added for bit stream switching, si switching I frame and SP switching P frame can effectively improve the ability to recover from errors. Its main application is video stream transmission applications on various networks.
2 h264 code stream Structure
2.1
This document uses the h264 video stream as an example to decode the stream data.
To highlight this point, this article only focuses on decoding video stream data and does not involve anything else (such as the configuration of the development environment ). If you need this information, please contact me.
Prepare Variables
Define avcodeccontext. If you use a class, you can define it as a class member. It is defined as a global variable.
Static av
It's easy to use openrtsp in live555 to save the h264 file.
However, the h264 file stored by the attacker cannot be directly played by VCL.
The h264 files stored in vcl of the same rtsp source can be directly played.
After research, it is found that openrtsp does notSDPIncludingSPSSave PPS data to a file
SetThe first two 00 00 01 data of the
There are three different basic loads (single Nal, non-interleaved, interleaved) in RTP of h264)
The application can use the first byte for recognition.
The properties of this session are also described in SDP.
SDP parameters
The following describes how to represent an H.264 stream in SDP:
. "M =" the media name in the row must be "video"
. The encoding name in the "A = rtpmap" line must be "h264 ".
. The
make the video transmission more fluent, now the video is used in compression coding. Here we will introduce the use of the X264 encoder to encode YUV420 data into H264 format video. YUV Data acquisition has been introduced in the previous:
V4l2 video capture and H264 coding 1-V4L2 collect JPEG data
V4l2 video capture and H264 code 2-V4L2 collect YUV data
V4l2 v
H264 code Stream parsing, online has a lot of open source files;
The general analysis is: Obtain Nalu,sps,pps,nalu type,slice type, obtain QP and so on;
The computation can be obtained by the bitwise operation of C + +, but the structure can be obtained directly.
Here is the WEBRTC in the H264 parsing Related:
In the WEBRTC, about the H264 related source files
This article was reproduced from: http://www.cnblogs.com/chutianyao/archive/2012/04/13/2446140.html
Recording program to add new features: Record CMMB TV shows, our cards are sent out of the RTP stream (H264 video and AAC audio), the recording program to do the work is:
(1) Receiving and parsing RTP packets, separating out H264 and AAC data streams;
(2) H264 vide
Here we first explain the structure of the following H264:
01/00 01->nal (1bytes)->slice-> macro block, motion estimation vector, XX.
If a prefix appears in the body of the H264, it is changed from 00 00 00 01/00 00 01 to 00 03 00 00 01/00 03 00 01.
We see commonly used naltype like sps= 0x07 pps= 0x08 sei = 0x06 i/p/b= 0x01/0x05 that is to say only Naltype = 0x01/0x05 is not judged out i/p/b frame type, n
slice header .).
Slice_alpha_c0_offset_div2: returns the offset value used to enhance α and tc0.
Filteroffseta = slice_alpha_c0_offset_div2
The range of slice_alpha_c0_offset_div2 is-6 to + 6.
Slice_beta_offset_div2: returns the offset value used to enhance β and tc0.
Filteroffsetb = slice_beta_offset_div2
The range of slice_beta_offset_div2 is-6 to + 6.
Conditions for the existence of these two elements: disable_deblocking_filter_idc! = 1. For these elements, you only need to know that they
Hierarchical structure of H264 elementsIn the bit stream of the encoder output, each bit is subordinate to a syntactic element. Syntactic elements are organized into hierarchical structures that describe each level of information.In H. Five, the syntactic elements are organized into sequences, images, slices, macro blocks, and Submacro blocks. In such a structure, the head of each layer and its data part form a strong dependency relationship between m
Use ffmpeg to encode the BMP image as a x264 video file and save the H264 video as a BMP image,The ffmpeg open-source library encodes bmp images into x264 files and decodes and saves the encoded H264 files as BMP files. Based on the blog code, you can build a test environment in vs2010. Resource download code:
# Define _ AFXDLL # include
The following information is reported when you test the code in the b
; // encode the video data cache int outbuf_size; // encode the output data de-size int ndatalen; // The length of the RGB image data area int width; // The output video width int height; // output video height public: void ffmpeg_encoder_init (); // initialize void ffmpeg_encoder_setpara (codecid mycodeid, int vwidth, int vheight); // set the parameter. The first parameter is the encoder, the second parameter is the width of the compressed video, and the third video is its height void ffmpeg_en
Well, memory leaks are bad. began to suspect that their own code problems, debugging for half a day, and repeatedly rewrite and optimize the code, or leak serious.Take the online ready-made ffmpeg H264 coded sample to test, the same leak is very serious.Baidu a bit, a lot of people encounter the same problem, they say is the memory leak of the code library itself .... , no words, ffmpeg, that H264 code can
These months have been doing the iphone audio and video things, because the individual is lazy, so has not tidied up, now idle egg pain, and later the project to be shelved, here to record what I do the iphone mobile push the stream of things.Projects are personal research and experimentation, there may be many bad or wrong places please forgive.1 Overview of features* Realization of audio and video data collection* Realize the encoding of audio and video data, video encoding into
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.