mux: avformat: add support for RGB
authorFrancois Cartegnie <fcvlcdev@free.fr>
Mon, 24 Sep 2018 16:39:48 +0000 (18:39 +0200)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Tue, 25 Sep 2018 14:22:14 +0000 (16:22 +0200)
modules/codec/avcodec/fourcc.c
modules/demux/avformat/mux.c

index 7711090..293ead5 100644 (file)
@@ -62,7 +62,12 @@ static const struct vlc_avcodec_fourcc video_codecs[] =
     { VLC_CODEC_SP5X, AV_CODEC_ID_SP5X },
     { VLC_CODEC_JPEGLS, AV_CODEC_ID_JPEGLS },
     { VLC_CODEC_MP4V, AV_CODEC_ID_MPEG4 },
-    /* AV_CODEC_ID_RAWVIDEO */
+    { VLC_CODEC_RGB32, AV_CODEC_ID_RAWVIDEO },
+    { VLC_CODEC_RGB24, AV_CODEC_ID_RAWVIDEO },
+    { VLC_CODEC_RGB16, AV_CODEC_ID_RAWVIDEO },
+    { VLC_CODEC_RGB8, AV_CODEC_ID_RAWVIDEO },
+    { VLC_CODEC_RGBA, AV_CODEC_ID_RAWVIDEO },
+    { VLC_CODEC_ARGB, AV_CODEC_ID_RAWVIDEO },
     { VLC_CODEC_DIV1, AV_CODEC_ID_MSMPEG4V1 },
     { VLC_CODEC_DIV2, AV_CODEC_ID_MSMPEG4V2 },
     { VLC_CODEC_DIV3, AV_CODEC_ID_MSMPEG4V3 },
@@ -559,6 +564,8 @@ vlc_fourcc_t GetVlcFourcc( unsigned i_ffmpeg_codec )
 {
     for( size_t i = 0; i < ARRAY_SIZE(video_codecs); i++ )
     {
+        if( i_ffmpeg_codec == AV_CODEC_ID_RAWVIDEO )
+            return VLC_CODEC_UNKNOWN;
         if( video_codecs[i].i_codec == i_ffmpeg_codec )
             return video_codecs[i].i_fourcc;
     }
index c280249..215bcfb 100644 (file)
@@ -32,6 +32,7 @@
 #include <vlc_common.h>
 #include <vlc_block.h>
 #include <vlc_sout.h>
+#include <vlc_es.h>
 
 #include <libavformat/avformat.h>
 
@@ -285,6 +286,15 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         stream->sample_aspect_ratio.num = codecpar->sample_aspect_ratio.num;
         stream->time_base.den = i_frame_rate;
         stream->time_base.num = i_frame_rate_base;
+        if(i_codec_id == AV_CODEC_ID_RAWVIDEO)
+        {
+            video_format_t vfmt;
+            video_format_Copy(&vfmt, &fmt->video);
+            video_format_FixRgb(&vfmt);
+            if(GetFfmpegChroma(&codecpar->format, &vfmt))
+                msg_Warn(p_mux, "can't match format RAW video %4.4s", &vfmt.i_chroma);
+            video_format_Clean(&vfmt);
+        }
         if (fmt->i_bitrate == 0) {
             msg_Warn( p_mux, "Missing video bitrate, assuming 512k" );
             i_bitrate = 512000;