问题
I am currently developing an application which produces certain metadata with respect to preview frames coming from the camera. I can see this metadata being produced properly and I have no problems here.
However, I have to embed this metadata to these frames of interest (frames are processed by a native algorithm to produce this metadata). I am using ffmpeg with x264 to encode the frames into H.264. I have checked x264.h and some documentations but failed to find what I seek.
My question is; is there any unused portion of H.264 syntax that I can embed my metadata to encoded frames?
I hope I was clear enough. Thanks in advance.
回答1:
Most video elementary streams have a provision for "user data". In h.264 this is part of the SEI nal unit. You can add one before every frame you want to associate it with. I don't think that x264 has support to add user data from outside.
Two choices:
- Modify x264 / ffmpeg to add the SEI message where ever you want it taking input in some form you like.
- Create your stream, create your metadata. Now write a small program separately to read your metadata and parse the files and push a SEI NAL before the frame you want.
For SEI syntax you should be able to google and get it. The best place to look though is the H.264 standard. A easier way is to just look at the code in x264. It does insert one user data at the begining (the encoding parameters).
来源:https://stackoverflow.com/questions/12320604/embedding-metadata-to-h-264-encoded-file