diff mbox series

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

Message ID 20230517142320.336-1-jamrial@gmail.com
State Accepted
Commit a2a0a81184df586d7b567d7b60d55d0e86376963
Headers show
Series [FFmpeg-devel] avformat/yuvmpegenc: add support for rawvideo input | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

James Almer May 17, 2023, 2:23 p.m. UTC
The demuxer exports rawvideo, so there's no reason for the muxer to only
work with wrapped_avframe.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/yuv4mpegenc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Ronald S. Bultje May 18, 2023, 7:54 p.m. UTC | #1
Hi,

On Wed, May 17, 2023 at 10:23 AM James Almer <jamrial@gmail.com> wrote:

> The demuxer exports rawvideo, so there's no reason for the muxer to only
> work with wrapped_avframe.
>
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavformat/yuv4mpegenc.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>

Works for me, thanks - and LGTM.

Ronald
James Almer May 18, 2023, 8:31 p.m. UTC | #2
On 5/18/2023 4:54 PM, Ronald S. Bultje wrote:
> Hi,
> 
> On Wed, May 17, 2023 at 10:23 AM James Almer <jamrial@gmail.com> wrote:
> 
>> The demuxer exports rawvideo, so there's no reason for the muxer to only
>> work with wrapped_avframe.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>   libavformat/yuv4mpegenc.c | 8 +++++++-
>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>
> 
> Works for me, thanks - and LGTM.
> 
> Ronald

Pushed, thanks.
diff mbox series

Patch

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;
     }