[FFmpeg-devel] [PATCH 2/3] wtvenc: use codec tag + MEDIASUBTYPE_BASE_GUID, if there is no suitable guid

Peter Ross pross at xvid.org
Mon Dec 23 10:39:31 CET 2013


This permits H264, AAC, AAC-LATM muxing.

Fixes ticket #536.

Signed-off-by: Peter Ross <pross at xvid.org>
---
 libavformat/wtvenc.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c
index ba0f178..c1066e1 100644
--- a/libavformat/wtvenc.c
+++ b/libavformat/wtvenc.c
@@ -268,6 +268,7 @@ static void put_videoinfoheader2(AVIOContext *pb, AVStream *st)
 static int write_stream_codec_info(AVFormatContext *s, AVStream *st)
 {
     const ff_asf_guid *g, *media_type, *format_type;
+    const AVCodecTag *tags;
     AVIOContext *pb = s->pb;
     int64_t  hdr_pos_start;
     int hdr_size = 0;
@@ -275,21 +276,18 @@ static int write_stream_codec_info(AVFormatContext *s, AVStream *st)
     if (st->codec->codec_type  == AVMEDIA_TYPE_VIDEO) {
         g = get_codec_guid(st->codec->codec_id, ff_video_guids);
         media_type = &ff_mediatype_video;
-        format_type = &ff_format_mpeg2_video;
+        format_type = st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO ? &ff_format_mpeg2_video : &ff_format_videoinfo2;
+        tags = ff_codec_bmp_tags;
     } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
         g = get_codec_guid(st->codec->codec_id, ff_codec_wav_guids);
         media_type = &ff_mediatype_audio;
         format_type = &ff_format_waveformatex;
+        tags = ff_codec_wav_tags;
     } else {
         av_log(s, AV_LOG_ERROR, "unknown codec_type (0x%x)\n", st->codec->codec_type);
         return -1;
     }
 
-    if (g == NULL) {
-        av_log(s, AV_LOG_ERROR, "can't get video codec_id (0x%x) guid.\n", st->codec->codec_id);
-        return -1;
-    }
-
     ff_put_guid(pb, media_type); // mediatype
     ff_put_guid(pb, &ff_mediasubtype_cpfilters_processed); // subtype
     write_pad(pb, 12);
@@ -308,7 +306,17 @@ static int write_stream_codec_info(AVFormatContext *s, AVStream *st)
     avio_seek(pb, -(hdr_size + 4), SEEK_CUR);
     avio_wl32(pb, hdr_size + 32);
     avio_seek(pb, hdr_size, SEEK_CUR);
-    ff_put_guid(pb, g);           // actual_subtype
+    if (g) {
+        ff_put_guid(pb, g);           // actual_subtype
+    } else {
+        int tag = ff_codec_get_tag(tags, st->codec->codec_id);
+        if (!tag) {
+            av_log(s, AV_LOG_ERROR, "unsupported codec_id (0x%x)\n", st->codec->codec_id);
+            return -1;
+        }
+        avio_wl32(pb, tag);
+        avio_write(pb, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12);
+    }
     ff_put_guid(pb, format_type); // actual_formattype
 
     return 0;
-- 
1.8.3.2

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131223/3c2c052c/attachment.asc>


More information about the ffmpeg-devel mailing list