On Thu, Apr 14, 2011 at 01:32:44PM +0200, Luca Barbato wrote:
> ---
> libavformat/output-example.c | 28 ++++++++++++++++++++++++++--
> 1 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/output-example.c b/libavformat/output-example.c
> index 1a0a6db..ed68fb8 100644
> --- a/libavformat/output-example.c
> +++ b/libavformat/output-example.c
> @@ -441,18 +441,38 @@ static AVStream *add_data_stream(AVFormatContext *oc,
> enum CodecID codec_id)
> return st;
> }
>
> +static void open_data(AVFormatContext *oc, AVStream *st)
> +{
> + AVCodec *codec;
> + AVCodecContext *c;
> +
> + c = st->codec;
> +
> + /* find the video encoder */
> + codec = av_malloc(sizeof(AVCodec));
> + memset(codec, 0, sizeof(AVCodec));
> + codec->id = c->codec_id;
> +
> + /* open the codec */
> + c->codec = codec;
> +}
> +
> static void write_data_frame(AVFormatContext *oc, AVStream *st, char *text)
> {
> AVPacket pkt;
> av_init_packet(&pkt);
> pkt.flags |= AV_PKT_FLAG_KEY;
> - pkt.stream_index= st->index;
> + pkt.stream_index = st->index;
> pkt.data = text;
> - pkt.size= strlen(text);
> + pkt.size = strlen(text);
this belongs to patch introducing write_data_frame() (but formatting also the
place you've copied it from would be even better)
> av_interleaved_write_frame(oc, &pkt);
> }
>
> +static void close_data(AVFormatContext *oc, AVStream *st)
> +{
> + avcodec_close(st->codec);
> +}
>
> /**************************************************************/
> /* media file output */
> @@ -529,6 +549,8 @@ int main(int argc, char **argv)
> open_video(oc, video_st);
> if (audio_st)
> open_audio(oc, audio_st);
> + if (data_st)
> + open_data(oc, data_st);
>
> /* open the output file, if needed */
> if (!(fmt->flags & AVFMT_NOFILE)) {
> @@ -577,6 +599,8 @@ int main(int argc, char **argv)
> close_video(oc, video_st);
> if (audio_st)
> close_audio(oc, audio_st);
> + if (data_st)
> + close_data(oc, data_st);
>
> /* free the streams */
> for(i = 0; i < oc->nb_streams; i++) {
> --
but in general it may be good enough to work
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel