@@ -3834,12 +3834,16 @@ static int read_thread(void *arg)
38343834 if (is -> video_st && is -> video_st -> codecpar ) {
38353835 AVCodecParameters * in_codecpar = is -> video_st -> codecpar ;
38363836 // if (in_codecpar->codec_type == AVMEDIA_TYPE_VIDEO && in_codecpar->codec_id == AV_CODEC_ID_H264) {
3837- if (pkt -> stream_index == is -> video_stream && in_codecpar -> codec_id == AV_CODEC_ID_H264 ) {
3837+ if (pkt -> stream_index == is -> video_stream ) {
38383838
38393839 uint8_t uuid [16 ];
3840- uint8_t * content ;
3841- int size ;
3842- ret = parse_sei (pkt , uuid , & content , & size );
3840+ uint8_t * content = NULL ;
3841+ int size = 0 ;
3842+ if (in_codecpar -> codec_id == AV_CODEC_ID_H264 ) {
3843+ ret = parse_sei (pkt , uuid , & content , & size );
3844+ }else if (in_codecpar -> codec_id == AV_CODEC_ID_HEVC ) {
3845+ ret = parse_sei_hevc (pkt , uuid , & content , & size );
3846+ }
38433847
38443848 if (ret == 0 && size > 0 && content != NULL ) {
38453849 // use content and uuid
@@ -5627,6 +5631,65 @@ int parse_sei(AVPacket *pkt, uint8_t *uuid, uint8_t **content, int *size)
56275631 }
56285632 return -1 ;
56295633}
5634+
5635+
5636+ int parse_sei_hevc (AVPacket * pkt , uint8_t * uuid , uint8_t * * content , int * size )
5637+ {
5638+ // printf("\n SEI===LENT===%d \n",pkt->size);
5639+
5640+ uint8_t * p = pkt -> data ;
5641+ uint8_t * p_end = p + pkt -> size ;
5642+ * content = NULL ;
5643+ * size = 0 ;
5644+
5645+ /* 打印 nalu
5646+ uint8_t *SEI_p = pkt->data;
5647+ uint8_t *SEI_p_end = SEI_p + pkt->size;
5648+ if (SEI_p[4] == 0x06 && SEI_p[5] == 0x05) {
5649+ while (SEI_p < SEI_p_end) {
5650+ printf("%02x ",*SEI_p);
5651+ SEI_p++;
5652+ }
5653+ }
5654+ //*/
5655+
5656+ uint32_t nalu_len = convert_hex_to_decimal (p );
5657+ // printf("\n SEI===nalu_len===%d \n",nalu_len);
5658+
5659+ while (p < p_end ) {
5660+ if (p [4 ] == 0x4E && p [5 ] == 0x05 && p + 2 < p_end ) { // found SEI NAL; payload_type = 5 表示 user_data_unregistered;
5661+
5662+ int payload_size = 0 ;
5663+
5664+ p += 6 ;//跳过len 和 06 05 解析payloadsize (annexB nalu跳过前4个字节)
5665+ while ( p [0 ] == 0xFF ){
5666+ payload_size += 255 ;
5667+ p ++ ;
5668+ }
5669+ payload_size += * p ++ ;
5670+
5671+
5672+ // printf("\n SEI===PAYLOADLENT===%d \n",payload_size);
5673+ if (payload_size < 16 )
5674+ return -1 ;
5675+
5676+ memcpy (uuid , p , 16 );
5677+
5678+ * content = p + 16 ;
5679+ * size = payload_size - 16 ;
5680+
5681+ return 0 ;
5682+ }else { // not found contuie
5683+ p = p + 4 + nalu_len ;
5684+ nalu_len = convert_hex_to_decimal (p ); //更新为下一个nalu len
5685+ continue ;
5686+ }
5687+
5688+ // p = p_end; // skip SEI for now
5689+ }
5690+ return -1 ;
5691+ }
5692+
56305693
56315694void ffp_set_property_int64 (FFPlayer * ffp , int id , int64_t value )
56325695{
0 commit comments