目前我正在使用libav*对H.264视频进行编码。我想要将KLVPackets添加到位流中,但不知道在哪里实现它。
avcodec中有一个struct,但我不确定如何将其写到帧元数据中
typedef struct {
UID key;
int64_t offset;
uint64_t length;
} KLVPacket;
当前FFMPEG代码(仅留下相关代码):
av_register_all();
pOutputFormat = av_guess_format(NULL, fileName, NULL);
pFormatCtx=avformat_alloc_context();
pVideoStream = av_new_stream(pFormatCtx,0);
pCodecCtx=pVideoStream->codec;
...
av_dump_format(pFormatCtx, 0, fileName,1);
pCodec = avcodec_find_encoder(pCodecCtx->codec_id);
avio_open(&pFormatCtx->pb, fileName, AVIO_FLAG_READ_WRITE)
avformat_write_header(pFormatCtx, &pDict);
...
avcodec_encode_video(pCodecCtx,outbuf,outbuf_size,ppicture);
...
int ret = av_interleaved_write_frame(pFormatCtx, &pkt);
有没有人知道我可以借鉴的例子?
发布于 2013-06-28 13:33:20
KLV元数据意味着独立于视频的流。您可以将流多路复用到具有其自己的PID的MPEG-2传输流中。
另一种实现方式是将KLV作为单独的流发送。也就是说,在一个IP/Port上播放您的视频,而在另一个IP/Port上播放KLV。
无论哪种方式,您最大的问题将是将KLV数据同步到视频。我还没有找到一个开源库,可以很好地将KLV转换为视频。有几个库你可以付钱,但我还没有使用它们中的任何一个。
https://stackoverflow.com/questions/14140590
复制相似问题