In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces how to carry out FFmpeg H264 code stream analysis and playback, the content is very detailed, interested friends can refer to, hope to be helpful to you.
1) Analysis of h364_probe function
Function call
Avformat_open_input
S-> iformat- > read_header (s)
Function description
/ * *
Read the format header and initialize the AVFormatContext
Structure. Return 0 if OK. 'avformat_new_stream' should be
Called to create new streams.
/
Int (read_header) (struct AVFormatContext *)
Call from the read_header function to detect the stream format of h364
Code description
Static int h364_probe (AVProbeData * p)
{
Uint32_t code =-1; / / code = 0xffffffff
Int sps = 0, pps = 0, idr = 0, res = 0, sli = 0
Int i, ret
Int pps_ ids [Max _ PPS_COUNT+1] = {0}
Int sps_ ids [Max _ SPS_COUNT+1] = {0}
Unsigned pps_id, sps_id
GetBitContext gb
For (I = 0; I + 2)
< p->Buf_size; iTunes +) {
Code = (code buf [I])
/ / separate the NAL start code 00 00 00 01 and analyze the NAL type
If ((code & 0xffffff00) = = 0x100) {
Int ref_idc = (code > > 5) & 3
Int type = code & 0x1F
Static const int8_t ref_zero [] = {
2, 0, 0, 0, 0, 1, 1, 1
-1, 1, 1, 1, 1,-1, 2, 2
2, 2, 2, 0, 2, 2, 2, 2
2, 2, 2, 2, 2, 2, 2, 2
}
If (code & 0x80) / / forbidden_bit
Return 0
If (ref_ Zero [type] = = 1 & & ref_idc)
Return 0
If (ref_ Zero [type] =-1 & &! ref_idc)
Return 0
If (ref_ Zero [type] = = 2) {
If (! (code = = 0x100 & &! p-> buf [I + 1] & &! p-> buf [I + 2]))
Res++
}
Ret = init_get_bits8 (& gb, p-> buf + I + 1, p-> buf_size-I-1)
If (ret
< 0) return 0; switch (type) { case 1: case 5: get_ue_golomb_long(&gb); if (get_ue_golomb_long(&gb) >9U)
Return 0
Pps_id = get_ue_golomb_long (& gb)
If (pps_id > MAX_PPS_COUNT)
Return 0
If (! pps_ IDS [PPS _ id])
Break
If (type = = 1)
Sli++
Else
Idr++
Break
Case 7:
Skip_bits (& gb, 14)
If (get_bits (& gb, 2))
Return 0
Skip_bits (& gb, 8)
Sps_id = get_ue_golomb_long (& gb)
If (sps_id > MAX_SPS_COUNT)
Return 0
Sps_ IDS [SPS _ id] = 1
Sps++
Break
Case 8:
Pps_id = get_ue_golomb_long (& gb)
If (pps_id > MAX_PPS_COUNT)
Return 0
Sps_id = get_ue_golomb_long (& gb)
If (sps_id > MAX_SPS_COUNT)
Return 0
If (! sps_ ids [SPS _ id])
Break
Pps_ IDS [PPS _ id] = 1
Pps++
Break
}
}
}
Ff_tlog (NULL, "sps:%d pps:%d idr:%d sli:%d res:%d\ n", sps, pps, idr, sli, res)
If (sps & & pps & & (idr | | sli > 3) & & res < (sps + pps + idr))
Return AVPROBE_SCORE_EXTENSION + 1; / / 1 more than .mpg
Return 0
}
2) play
VLC media player does not support playing H264 data streams by default.
The version that currently uses VLC is 2.2.4Weatherwax
Operation steps
1 tools for opening the menu bar
2 Select preferences
3 there are two radio boxes in the lower left corner of the interface TAB page, which are concise and have a reset parameter next to them.
4 Click all
5 Click the input / edit × × menu, click on the demultiplexer in the drop-down list, but do not need to expand the drop-down list of the demultiplexer
6 in the upper right corner, select H264 video demultiplexer in the demultiplexing module
On how to carry out FFmpeg H264 stream analysis and playback is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.