[FFmpeg-cvslog] avformat/yuvmpegenc: add support for rawvideo input

James Almer git at videolan.org
Thu May 18 23:31:36 EEST 2023


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed May 17 11:21:52 2023 -0300| [a2a0a81184df586d7b567d7b60d55d0e86376963] | committer: James Almer

avformat/yuvmpegenc: add support for rawvideo input

The demuxer exports rawvideo, so there's no reason for the muxer to only
work with wrapped_avframe.

Reviewed-by: Ronald S. Bultje <rsbultje at gmail.com>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a2a0a81184df586d7b567d7b60d55d0e86376963
---

 libavformat/yuv4mpegenc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
index 2fa5ee2714..968ba2fa13 100644
--- a/libavformat/yuv4mpegenc.c
+++ b/libavformat/yuv4mpegenc.c
@@ -189,6 +189,11 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
 
     avio_printf(s->pb, Y4M_FRAME_MAGIC "\n");
 
+    if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
+        avio_write(pb, pkt->data, pkt->size);
+        return 0;
+    }
+
     width  = st->codecpar->width;
     height = st->codecpar->height;
     desc   = av_pix_fmt_desc_get(st->codecpar->format);
@@ -218,7 +223,8 @@ static int yuv4_init(AVFormatContext *s)
     if (s->nb_streams != 1)
         return AVERROR(EIO);
 
-    if (s->streams[0]->codecpar->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) {
+    if (s->streams[0]->codecpar->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME &&
+        s->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) {
         av_log(s, AV_LOG_ERROR, "ERROR: Codec not supported.\n");
         return AVERROR_INVALIDDATA;
     }



More information about the ffmpeg-cvslog mailing list