From patchwork Thu May 31 22:58:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Timo_Ter=C3=A4s?= X-Patchwork-Id: 9216 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp191614jad; Thu, 31 May 2018 16:06:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIXwD61DCMcHOvJRXh9jr9H5SiaCp3S4vYcySvyDdheOKXH7Zw9w2FEzmjY0QOFieqwBXFN X-Received: by 2002:a1c:58ce:: with SMTP id m197-v6mr984762wmb.110.1527807994238; Thu, 31 May 2018 16:06:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527807994; cv=none; d=google.com; s=arc-20160816; b=S0DfpB9TRFWZCw/YqHW0kRe8BVxtgNC7iTgOg/h3rQ2nbgmAbApker88PFTlF67Z4l VGgQsx6vvujcrSy1l8/kbrzofsnOIMdixPCjZSPMaSWjR8vFjdoIe+dkiJ88l1qcxyqo pJawCiuPqxmtkoXqHLS9kkSuwiWPZAs3704nY9Tovb5mc6nIo5JwR8Rug/M45UKVjXr5 f/qMvF+f3rju0Cb1R5jmJfY45xHqRkHf7XKoGppFrvmziyEFryIhPRrEoPAZ5K7fmLc4 sHO3o3zsSvrbA6/TzlcdC9O5vxHWCT+JwSkoIazRE1xaUlIYi9vI+BUjelib7cKbRkH1 cdbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to:arc-authentication-results; bh=FrdRLupQd80xFPnuet4oC8WBPpGS8FjM44u1BZIX+NI=; b=Xxtd9vialDtiFuOXcqmenqSasWluvl/uvRuOjuDyVod4u8++u40Ldh+m7AHDECKdwv jt6DtiCrK2B7L4Z0dVHixii+vX/NHs1XLiFIKZS+LuAOi8ZMWg7Vnx9VLtreAg/y1PdF xokXrmtvxX4XatFmYQI+o2Rf7s2m2LfAMpV8mgVhEzUv7lvkWr5kI3PYyhaFH0sDYG9i SbR0G8D+2C8Utdtls5AfTG2TuLnK9aYID5Rrq5h7ca+qhMtlBTyB7xIPnWCSt3wP1k3/ jRaIJSASwh+tYsta0GApFIDE2R2SuvRMzR2f42fjiJXFy9vn8d3/BILOdtQmZZon4uml 6FPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t6-v6si7845226wrp.90.2018.05.31.16.06.33; Thu, 31 May 2018 16:06:34 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 53BCA68A453; Fri, 1 Jun 2018 02:05:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f193.google.com (mail-qt0-f193.google.com [209.85.216.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 71C64689767 for ; Fri, 1 Jun 2018 02:05:41 +0300 (EEST) Received: by mail-qt0-f193.google.com with SMTP id c2-v6so29952472qtn.9 for ; Thu, 31 May 2018 16:06:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NC6iW1nJ722u3S8GrjjGTkTd9NhpIC+X3/daWb4dKts=; b=Ko/3nPC5ez80FDljY3EI5g6fwv8BhZ7QYvBTKykR3/7A8/5WEnEFNJSxBO3J3J1eSX Dmn2JRDmqF7AcvMBsTKlPx/TqG6RY3pfTHtFY6H5XuMq+7fWtS4xVZNag5vLdSdQDqOh tDln++Z81qjBGQowY9PYi5pfZB3FDkQoj6X7F86KCgKD0gKy9TdvnoEl0K7OOytvYyY3 t3lZVsKw/4qLcsMBsW6AsTUYuee8cKWUya0NPRIqJQ0hYoYl174pmebXWomCOX9XCPz8 oTWyyi8hbqMsDnkeAQRG9oAsWxMI5DCSXUXsmW9IPqTVphmnrJgVNF2HHAWL4lV+MA4o 97zw== X-Gm-Message-State: APt69E1Sf7mpHiZObf13SNkuTGfP7J3NBQyAgNmi1ChI7SDPQZbC+RQS xQeHaTUZWSHbyWpJ+VbzY9Hdw0+L X-Received: by 2002:ac8:6106:: with SMTP id a6-v6mr8659520qtm.54.1527807587915; Thu, 31 May 2018 15:59:47 -0700 (PDT) Received: from localhost.localdomain ([208.74.140.117]) by smtp.gmail.com with ESMTPSA id x28-v6sm31785876qtx.95.2018.05.31.15.59.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 15:59:47 -0700 (PDT) From: =?UTF-8?q?Timo=20Ter=C3=A4s?= To: FFmpeg development discussions and patches , Rostislav Pehlivanov Date: Fri, 1 Jun 2018 01:58:47 +0300 Message-Id: <20180531225847.10479-1-timo.teras@iki.fi> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/movenc: properly handle cover image codecs 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 Cc: =?UTF-8?q?Timo=20Ter=C3=A4s?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Find codec tag for attached images using appropriate list of supported image formats. This fixes writing the cover image to m4v/m4a and other container formats that do not allow these codecs as a track. Signed-off-by: Timo Teräs --- This replaces the previous patch: PATCH] [RFC] avformat/movenc: support covert images for ipod muxer It appears that query_codec() is used only to figure out which stream to select as the default copy stream. Fixing it properly for movenc attached pictures is difficult, as the stream disposition would need to be passed through the call stack. Additionally, it would make sense to rewrite the selection logic open_output_file() to not use APIC special tag and be based on the input/output dispositions. So this just adds proper handling of the codecs in mov_init() phase which fixes most of the usability issues. Please backport to 4.0 stable branch too. libavformat/movenc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7e616e866f..8c370ee7b9 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1557,10 +1557,20 @@ static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track) return tag; } +static const AVCodecTag codec_cover_image_tags[] = { + { AV_CODEC_ID_MJPEG, MKTAG('A','P','I','C') }, + { AV_CODEC_ID_PNG, MKTAG('A','P','I','C') }, + { AV_CODEC_ID_BMP, MKTAG('A','P','I','C') }, + { AV_CODEC_ID_NONE, 0 }, +}; + static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track) { int tag; + if (track->st->disposition & AV_DISPOSITION_ATTACHED_PIC) + return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id); + if (track->mode == MODE_MP4 || track->mode == MODE_PSP) tag = track->par->codec_tag; else if (track->mode == MODE_ISM)