From patchwork Sun Apr 26 20:26:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Manouchehri X-Patchwork-Id: 19272 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B7FFF44896F for ; Sun, 26 Apr 2020 23:26:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8F79F68C46D; Sun, 26 Apr 2020 23:26:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A68D668C406 for ; Sun, 26 Apr 2020 23:26:37 +0300 (EEST) Received: from capuchin.riseup.net (unknown [10.0.1.176]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Sectigo RSA Domain Validation Secure Server CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 499KF73z4hzFcdL for ; Sun, 26 Apr 2020 13:26:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1587932795; bh=UN/magPjTP0Y5gMY70kZOoQGWix1uF/onCnf7/bqAVg=; h=From:Date:Subject:To:From; b=RDGkP3qx47NI5SEftEdjxUogCWSA7/aefixlRkGczHHzQrT+TyStLFFJCn3P0GUaj tazjsfNOpMMT0vJBN+nMTKrKwEIDiM7DaYOnodGGNJpNjlUAIxQP6St9WFfMfLZHyO iFDRWgfywBNKS7jTe1j4HlLjsI9/UnAv8yByrV5E= X-Riseup-User-ID: 35F665F46E106FC2FECFFAE602035BAB0DA1FE46AEEC54382079D2FBB4D8508D Received: from [127.0.0.1] (localhost [127.0.0.1]) by capuchin.riseup.net (Postfix) with ESMTPSA id 499KF72rB7z8ty4 for ; Sun, 26 Apr 2020 13:26:35 -0700 (PDT) Received: by mail-io1-f42.google.com with SMTP id c2so1847674iow.7 for ; Sun, 26 Apr 2020 13:26:34 -0700 (PDT) X-Gm-Message-State: AGi0PubTznWNwkJdER34A4I3VfF69LLjZV+WOJWYfMl6VxmRxr2oRsAc JORhF86HPeHYs595J9A4QbTnusr8AAy/H9fW7QXCRw== X-Google-Smtp-Source: APiQypI+p0XH5m6AAwn2u8R0mmokNGX6YLBtt3XupaPdaLZEdca5ix9I466iDVaunpfNCxhom31I/Da9dHVbat1FCJY= X-Received: by 2002:a02:5184:: with SMTP id s126mr7231744jaa.81.1587932794465; Sun, 26 Apr 2020 13:26:34 -0700 (PDT) MIME-Version: 1.0 From: David Manouchehri Date: Sun, 26 Apr 2020 16:26:23 -0400 X-Gmail-Original-Message-ID: Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] avdevice/v4l2enc: Allow writing non-rawvideos to v4l2 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Resubmit of a previous patch, not sure why the diff didn't come through. From d125fea410dea1c2d4bd791a7472a72822de54a3 Mon Sep 17 00:00:00 2001 From: David Manouchehri Date: Sat, 4 Nov 2017 16:32:41 -0400 Subject: [PATCH] avdevice/v4l2enc: Allow writing non-rawvideos to v4l2. Signed-off-by: David Manouchehri --- libavdevice/v4l2enc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavdevice/v4l2enc.c b/libavdevice/v4l2enc.c index 1c36f81f90..f89ff50dbb 100644 --- a/libavdevice/v4l2enc.c +++ b/libavdevice/v4l2enc.c @@ -47,8 +47,7 @@ static av_cold int write_header(AVFormatContext *s1) } if (s1->nb_streams != 1 || - s1->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO || - s1->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) { + s1->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) { av_log(s1, AV_LOG_ERROR, "V4L2 output device supports only a single raw video stream\n"); return AVERROR(EINVAL); @@ -56,7 +55,13 @@ static av_cold int write_header(AVFormatContext *s1) par = s1->streams[0]->codecpar; - v4l2_pixfmt = ff_fmt_ff2v4l(par->format, AV_CODEC_ID_RAWVIDEO); + if(s1->streams[0]->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) { + v4l2_pixfmt = ff_fmt_ff2v4l(par->format, AV_CODEC_ID_RAWVIDEO); + } + else { + v4l2_pixfmt = ff_fmt_ff2v4l(AV_PIX_FMT_NONE, s1->streams[0]->codecpar->codec_id); + } + if (!v4l2_pixfmt) { // XXX: try to force them one by one? av_log(s1, AV_LOG_ERROR, "Unknown V4L2 pixel format equivalent for %s\n", av_get_pix_fmt_name(par->format)); -- 2.17.1