From patchwork Wed Jul 12 18:31:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis O'Bryan X-Patchwork-Id: 4311 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp1166584vsb; Wed, 12 Jul 2017 11:32:10 -0700 (PDT) X-Received: by 10.28.23.1 with SMTP id 1mr3754860wmx.106.1499884330416; Wed, 12 Jul 2017 11:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499884330; cv=none; d=google.com; s=arc-20160816; b=XwSkHzLPdP/avWjwGRe+TdakYafcLxPLE+jX3PNuUI1TA++ta5vxpxiXOZAgNzEMeh QOOimupeVXomzI94FMElfmNd4RDixSl8xoe+gzITYs5sn0YmLJbmy8RDnvdKo2TpQi/E LATFDfaxxSopnRBljBV1YLQdAcMaM9stFrrbrIzJ+A1C4D9Ta30dY+E+99H7U3bHE9Jn iq4GI5AENiLTaZU/emyyd2zTzzfOiQm4lPXDP/0l9+d407/iFVdMfBZGTz2wfInrOcJa LOWB5NYJ3j5ifCWOUmUUXUmmePbclzOUyw621UQWMyzM0reQ5x5qDWF1ixu0XZHjn/M+ SPTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:to:message-id:date:from:references:in-reply-to :mime-version:dkim-signature:delivered-to:arc-authentication-results; bh=AL7AUU/uaOc/4LTRJerx7EzlBG42yMYb2mqQivLH904=; b=KodeWeiKk4dbb1zAsZR0aox3KHgXwyBBpWa7RY6s/Mqa/SZNkn/EkHG+2nvd45RGXr /0bkKq6607fywhnmSbuysqZrTs8y1NpOSAIUnAyjnawn5usjQBL6ZZPA/nHOnREctxFo cdtxpjOHfPerlCesOUojZu4ehukzplpnyQODbkHZFMovb8zrLZifOCUkLJkyXKdw6pjM FzV/MmOQZJnTjBLPZkod74/a1DSYgYPy5iXT2a2zL+5IHTRN0OUKhIZLBWI9/6oNT1mq TlZYuHtlZFxLKWnDdop7Lw10svFpFmk7Kve/3ROixDl5xmgZCKscwtVOb53PylCnv5Sf 9/GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.b=II8J0vPp; 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 g2si2328223wrc.311.2017.07.12.11.32.09; Wed, 12 Jul 2017 11:32:10 -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; dkim=neutral (body hash did not verify) header.i=@google.com header.b=II8J0vPp; 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 69A67689721; Wed, 12 Jul 2017 21:32:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A06AD688302 for ; Wed, 12 Jul 2017 21:31:55 +0300 (EEST) Received: by mail-wm0-f50.google.com with SMTP id 62so2466774wmw.1 for ; Wed, 12 Jul 2017 11:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=M1pE1KiGDxrsr84OL75SfQKF08q/2XX1F5T+EvWEBBg=; b=II8J0vPp/lRguPaFqnC2XbEpWFw5bEQPDDpWOMHXN7TK2S6sUPLgmEnA6pXOQLcBw1 l0QcjiDKsWNg3Xocq86PKYUAKP3WrQn3+KuM4NlSwBYZ6YjsBT8mBKRAxJxo7BfkWSb1 6Uo7ZoL02x/AWLONCsPdu0wowadRdCuznLylvni7Ig4TErt850I/4Hfb/OkABGyN2550 QjN/mY0DdcjagAU0k1EMlHIvEPB+KNxNbp5RBAL4TsUcPhSuHNsmocXiMDXuVMHfNf6i SKo4SAwN5KGTaLQ8t8mDu3X3DIsw/YWkAbDQq4OAREurYX5+AWhGL862HRjtDdqUWELN f+lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=M1pE1KiGDxrsr84OL75SfQKF08q/2XX1F5T+EvWEBBg=; b=nQJipm38zCgZ2gVT+y1RIHat5SBAOHgEo7svorCTJIotvrU0b1P5v/mXbbjzMh6SQ/ Aj/ZdnikLGKmbV2C+dnC9GoNs70oElIyXHYKf+pazFcRIDNoEU3/GUwNQXu6bJpSVW8U 234lXh/Pw5E2bZBj5UXkR5p5Fz8iRObQ4UCTg/eAwFKRV+cH6ovY0JPjPsT9asJFB55t LSYDAH/xl2wookccLnGO4tjfjEkq/WwKEBSHMh23k1hXPDDbuAyJ2tyofJG/oHcsamCY esstuqfTaZRnbKhRgvP9yXZIPuj1xW6QGoGfsBRmf14GHTxlpCQIBvbmbljZL5EEMkoN Lj9Q== X-Gm-Message-State: AIVw111vNpEPHcN+XjpyGEcJhsLBtw10LeNwtQOX4FNTfTzhv0uNX12g ar4Cuz5QozK81DALeN2XVRo2HcLb2XPWETI6vQ== X-Received: by 10.28.95.137 with SMTP id t131mr3720262wmb.102.1499884319656; Wed, 12 Jul 2017 11:31:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.142.74 with HTTP; Wed, 12 Jul 2017 11:31:58 -0700 (PDT) In-Reply-To: References: <20170707003639.27739-1-louiso@louiso0.mtv.corp.google.com> <20170707003639.27739-2-louiso@louiso0.mtv.corp.google.com> <20170707124544.56c4ae0c@debian> <20170710104826.61cbbeaf@debian> <20170712095043.51265f3b@debian> From: "Louis O'Bryan" Date: Wed, 12 Jul 2017 11:31:58 -0700 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH 1/1] This change adds an encoder for Camera metadata motion. This is a type of sensor data associated with video, such as GPS, acceleration, gyro, and camera orientation. It does not encode video itself, but rather, this metadata. 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" On Wed, Jul 12, 2017 at 9:16 AM, Louis O'Bryan wrote: > On Wed, Jul 12, 2017 at 12:50 AM, wm4 wrote: > >> On Tue, 11 Jul 2017 16:17:33 -0700 >> "Louis O'Bryan" wrote: >> >> > If I need to write a new atom under stsd for my stream in the mov muxer >> > >> > (mov_write_stsd_tag), >> > is it appropriate to indicate that through the AVStream metadata rather >> > than the codec_tag? >> >> It seemed to have lots of unrelated changes, but maybe I'm missing >> something. If those codec tag refactors are needed, they should >> probably be split into a separate patch. >> >> But it looks like most of those changes were unintended (Moritz >> suspected that too). The tag addition itself is probably fine. >> >> Also, please don't top post on mailing lists. >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > > That file had unrelated changes that shouldn't have been there, please > ignore them. > Now that there is no codec associated with the stream, there shouldn't be > a codec tag at all, I would assume. (Another issue I need to deal with is > that the MOV muxer also doesn't support streams without a codec, but that > is separate.) > My goal is to modify the MOV/MP4 muxer so that I can mux the new stream with video and audio streams. Part of that is writing a new sample entry box under the stsd box. Since I no longer plan to use an encoder for the stream, I was wondering if the AVStream::metadata would be an appropriate way to recognize that stream. Other cases in the mov_write_stsd_tag function use the codec tag. I have the following sample of that idea here, which allows me to use the new stream and write the sample entry box: --- libavformat/movenc.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) { int64_t pos = avio_tell(pb); @@ -2077,6 +2094,8 @@ static int mov_write_stsd_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext mov_write_rtp_tag(pb, track); else if (track->par->codec_tag == MKTAG('t','m','c','d')) mov_write_tmcd_tag(pb, track); + else if (stream_has_metadata(track->st, "camm")) + mov_write_camm_tag(pb); return update_size(pb, pos); } @@ -2443,6 +2462,9 @@ static int mov_write_hdlr_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra } else if (track->par->codec_tag == MKTAG('t','m','c','d')) { hdlr_type = "tmcd"; descr = "TimeCodeHandler"; + } else if (stream_has_metadata(track->st, "camm")) { + hdlr_type = "camm"; + descr = "CameraMetadataMotionHandler"; } else { av_log(s, AV_LOG_WARNING, "Unknown hldr_type for %s, writing dummy values\n", @@ -5875,7 +5897,7 @@ static int mov_init(AVFormatContext *s) track->language = 0; track->mode = mov->mode; track->tag = mov_find_codec_tag(s, track); - if (!track->tag) { + if (!track->tag && !stream_has_metadata(st, "camm")) { av_log(s, AV_LOG_ERROR, "Could not find tag for codec %s in stream #%d, " "codec not currently supported in container\n", avcodec_get_name(st->codecpar->codec_id), i); diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 88f2f2c819..8d57a18864 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -109,6 +109,13 @@ static const AVClass flavor ## _muxer_class = {\ static int get_moov_size(AVFormatContext *s); +static int stream_has_metadata(AVStream *st, const char *metadata_key) { + if (!st->metadata) { + return 0; + } + return av_dict_get(st->metadata, metadata_key, NULL, 0) != NULL; +} + static int utf8len(const uint8_t *b) { int len = 0; @@ -2060,6 +2067,16 @@ static int mov_write_tmcd_tag(AVIOContext *pb, MOVTrack *track) return update_size(pb, pos); } +static int mov_write_camm_tag(AVIOContext *pb) { + int64_t pos = avio_tell(pb); + avio_wb32(pb, 0); /* size */ + ffio_wfourcc(pb, "camm"); + avio_wb32(pb, 0); /* Reserved */ + avio_wb16(pb, 0); /* Reserved */ + avio_wb16(pb, 1); /* Data-reference index */ + return update_size(pb, pos); +} + static int mov_write_stsd_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)