To insert user data unregistered SEI message in a H.264 bit stream

How to insert some user data unregistered SEI messages in H.264 compressed bit stream,  for example in a MP4 container? That is what I will talk about here.

The H.264 coding standard ISO/IEC 14496-10 defined the samentic and syntax of user data unregistered SEI message, but it did not talk about the usage of the message, and I would not talk about why I want to insert such messages in h.264 data, that is a secret. In fact, you can add any information you want in a user data unregistered SEI message.

I analysed a few h.264 files in mp4 format, according to the 14496-10 standard, I found such messages in these files. Here is a binary view of a mp4 file, the highlighted part is the SEI message.

 A SEI is packeged in a Non VCL NAL unit, represented by NAL Unit type 6. The NALs in mp4 file is not in byte stream format, but have a four bytes long header, which is the byte number of the whole NAL unit, in the example, the NAL length is 0x2AE, you should remember that this 32-bit number is big endian in memory!

 

The SEI syntax in the standard will help you to construct you own SEI message.

Then comes the problem that how to insert the message. Of course, you can try to insert your own SEI message just by binary file operation, but you must consider the mp4 container format and parsing the NAL unit in it. So I use ffmpeg library to do most of the thing for me.

The steps:

1. open the mp4 file, parsing and demux it to get every packet that hold one frame of compressed image(or audio, ...)

2. expand the size of packet to hold your own SEI message

3. append the message after the original packet

4. write new packet into the file container.

tip: you can use ffmepg to help you to check whether your message have bee inserted correctly.

> ffmpeg -show_data -show_packtes [your file]

 

That's all.

转载于:https://www.cnblogs.com/WeirdWiredThings/p/6183390.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值