OLD | NEW |
1 /* | 1 /* |
2 * nut muxer | 2 * nut muxer |
3 * Copyright (c) 2004-2007 Michael Niedermayer | 3 * Copyright (c) 2004-2007 Michael Niedermayer |
4 * | 4 * |
5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
6 * | 6 * |
7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 441 |
442 static int add_info(ByteIOContext *bc, const char *type, const char *value){ | 442 static int add_info(ByteIOContext *bc, const char *type, const char *value){ |
443 put_str(bc, type); | 443 put_str(bc, type); |
444 put_s(bc, -1); | 444 put_s(bc, -1); |
445 put_str(bc, value); | 445 put_str(bc, value); |
446 return 1; | 446 return 1; |
447 } | 447 } |
448 | 448 |
449 static int write_globalinfo(NUTContext *nut, ByteIOContext *bc){ | 449 static int write_globalinfo(NUTContext *nut, ByteIOContext *bc){ |
450 AVFormatContext *s= nut->avf; | 450 AVFormatContext *s= nut->avf; |
451 AVMetadataTag *title, *author, *copyright; | 451 AVMetadataTag *t = NULL; |
452 ByteIOContext *dyn_bc; | 452 ByteIOContext *dyn_bc; |
453 uint8_t *dyn_buf=NULL; | 453 uint8_t *dyn_buf=NULL; |
454 int count=0, dyn_size; | 454 int count=0, dyn_size; |
455 int ret = url_open_dyn_buf(&dyn_bc); | 455 int ret = url_open_dyn_buf(&dyn_bc); |
456 if(ret < 0) | 456 if(ret < 0) |
457 return ret; | 457 return ret; |
458 | 458 |
459 title = av_metadata_get(s->metadata, "Title" , NULL, 0); | 459 while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) |
460 author = av_metadata_get(s->metadata, "Author" , NULL, 0); | 460 count += add_info(dyn_bc, t->key, t->value); |
461 copyright = av_metadata_get(s->metadata, "Copyright", NULL, 0); | |
462 | |
463 if(title ) count+= add_info(dyn_bc, "Title" , title->value); | |
464 if(author ) count+= add_info(dyn_bc, "Author" , author->value); | |
465 if(copyright) count+= add_info(dyn_bc, "Copyright", copyright->value); | |
466 if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) | |
467 count+= add_info(dyn_bc, "Encoder" , LIBAVFORMAT_IDENT)
; | |
468 | 461 |
469 put_v(bc, 0); //stream_if_plus1 | 462 put_v(bc, 0); //stream_if_plus1 |
470 put_v(bc, 0); //chapter_id | 463 put_v(bc, 0); //chapter_id |
471 put_v(bc, 0); //timestamp_start | 464 put_v(bc, 0); //timestamp_start |
472 put_v(bc, 0); //length | 465 put_v(bc, 0); //length |
473 | 466 |
474 put_v(bc, count); | 467 put_v(bc, count); |
475 | 468 |
476 dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf); | 469 dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf); |
477 put_buffer(bc, dyn_buf, dyn_size); | 470 put_buffer(bc, dyn_buf, dyn_size); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 return 0; | 790 return 0; |
798 } | 791 } |
799 | 792 |
800 static int write_trailer(AVFormatContext *s){ | 793 static int write_trailer(AVFormatContext *s){ |
801 NUTContext *nut= s->priv_data; | 794 NUTContext *nut= s->priv_data; |
802 ByteIOContext *bc= s->pb; | 795 ByteIOContext *bc= s->pb; |
803 | 796 |
804 while(nut->header_count<3) | 797 while(nut->header_count<3) |
805 write_headers(nut, bc); | 798 write_headers(nut, bc); |
806 put_flush_packet(bc); | 799 put_flush_packet(bc); |
| 800 ff_nut_free_sp(nut); |
| 801 av_freep(&nut->stream); |
| 802 av_freep(&nut->time_base); |
807 | 803 |
808 return 0; | 804 return 0; |
809 } | 805 } |
810 | 806 |
811 AVOutputFormat nut_muxer = { | 807 AVOutputFormat nut_muxer = { |
812 "nut", | 808 "nut", |
813 NULL_IF_CONFIG_SMALL("NUT format"), | 809 NULL_IF_CONFIG_SMALL("NUT format"), |
814 "video/x-nut", | 810 "video/x-nut", |
815 "nut", | 811 "nut", |
816 sizeof(NUTContext), | 812 sizeof(NUTContext), |
817 #if CONFIG_LIBVORBIS | 813 #if CONFIG_LIBVORBIS |
818 CODEC_ID_VORBIS, | 814 CODEC_ID_VORBIS, |
819 #elif CONFIG_LIBMP3LAME | 815 #elif CONFIG_LIBMP3LAME |
820 CODEC_ID_MP3, | 816 CODEC_ID_MP3, |
821 #else | 817 #else |
822 CODEC_ID_MP2, | 818 CODEC_ID_MP2, |
823 #endif | 819 #endif |
824 CODEC_ID_MPEG4, | 820 CODEC_ID_MPEG4, |
825 write_header, | 821 write_header, |
826 write_packet, | 822 write_packet, |
827 write_trailer, | 823 write_trailer, |
828 .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, | 824 .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, |
829 .codec_tag= (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tag
s, ff_nut_subtitle_tags, 0}, | 825 .codec_tag= (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tag
s, ff_nut_subtitle_tags, 0}, |
| 826 .metadata_conv = ff_nut_metadata_conv, |
830 }; | 827 }; |
OLD | NEW |