From patchwork Sun Apr 15 11:57:06 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: 8452 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp2622012jad; Sun, 15 Apr 2018 04:57:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx49+A5eU/QXewtIeMRRfoLMFdWeMdQqxh5dSM4BXz5g5Cz0F0VlKaaQY22xNSwaxC6XLJlYL X-Received: by 10.223.187.13 with SMTP id r13mr2583078wrg.12.1523793443214; Sun, 15 Apr 2018 04:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523793443; cv=none; d=google.com; s=arc-20160816; b=nPqzH6KOBu3r24dkGLkTZLPLiPaaiVEoNrt+mEOl9glC2MTEClMvPqecQ8fCZtToWV FZfJOyy/Yj9+OaXQy7gqLCtoVie0T7mpE0h1YyJhtG5wGreTmaBR4WeR8knxqClI7Db8 7qAuqs1t/7PPEo+2ODHWojgFb5MQ45TUrvcb7WtXsOncuCg1zd+3HTHHd6O0Au/hIHuR dBGAZvCM6Wen+SVw0jRaJJWgO+aPVEWei23mg1Tje6eZugwrHkyHKZ1Nxf03AwB0QLMI aB0tg7j9upMSnc26Pe2mDLUvv/HYN5Rw32WORjkIHXtFJiszWB2ertGx9cwGNgY6e0rt XelA== 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=hTRU/0xOxMc5j+idjcaPjagU7nPtAIctXQbLf9+/OFo=; b=FvNq7aIjPt7yPDh0E65GIwA6qDd2PkJ+H1KhbE7AhS8TvUYefgY842DBg8OcZZxtPH E6twIBxYrAr+Xh8yMtiyOQGNduElM1KbJZvIqov9YuUfHE8U3b8l9SQSciJgQUzvtKLk NShJGSYJIvQQH9nbHMUs+FPQC/uuNxrH0Ln3PiGQdml9+/q47racflYi1YgBQugbzidE 8uGdSW39PYTLEaZOHA+j1yzhIy3EodLrMRaI+oY7ZnQb2OSZyFJcpJftY1uq/gU9T68K oDgN4eAH8avluQ24lihlWYNYD3YtF9mo9simoVIFcRAlLASagK37zomQJYtgY54VOHYV +0rQ== 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 j4si7358471wrd.69.2018.04.15.04.57.22; Sun, 15 Apr 2018 04:57:23 -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 B2DE7689DB6; Sun, 15 Apr 2018 14:56:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D13436805E8 for ; Sun, 15 Apr 2018 14:56:47 +0300 (EEST) Received: by mail-lf0-f66.google.com with SMTP id m200-v6so18187006lfm.4 for ; Sun, 15 Apr 2018 04:57:13 -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=tfrUtdgV4xv0Pt5Gr43zebjA3occrTGBdY04KqDAhuI=; b=EKVk9Miil5Cox/ueRuOiueE8FjL3JH4wcNVwa6aRRwr7XTfVWY4/XAKPffGX2ZxvVc c9jYAg02PQJwQNWdmNbN7qI7d/0j+cBwbD9XBYEKFkqXu3wFpN5VIFh03jg8gXekAieP QlclZAwObaMz1NN1gGxsYtUn0bz2AECgqERdswwHFb2lTBnOEJCl4PYcDc9ZLIEkv7Cw sDKLYrjMq7AKaIw1DjG9kmEiMAJ5KpzHJPHHkUzPDJR13yw5wELEs2gXRQ3UKzAgKKiN QngNMhdywdtzALXRJxe4HLB05tzwDd3sn8xbpDongn1ixoWvzqsp393OD5JfpebSQB2u TS9w== X-Gm-Message-State: ALQs6tB52f0+slE8PCkaaNIiWaL7UreXlNw2TPx/KHWf09yGCH3CCoPj XmdTri5QUiV2YCSiIPIIxJX8grn/ X-Received: by 2002:a19:97d5:: with SMTP id z204-v6mr9622514lfd.132.1523793433026; Sun, 15 Apr 2018 04:57:13 -0700 (PDT) Received: from localhost.localdomain ([83.145.235.201]) by smtp.gmail.com with ESMTPSA id 17sm219747ljr.17.2018.04.15.04.57.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Apr 2018 04:57:12 -0700 (PDT) From: =?UTF-8?q?Timo=20Ter=C3=A4s?= To: FFmpeg development discussions and patches , Michael Niedermayer , Rostislav Pehlivanov Date: Sun, 15 Apr 2018 14:57:06 +0300 Message-Id: <20180415115706.17172-1-timo.teras@iki.fi> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/1] [RFC] ffprobe: report DAR even if SAR is undefined 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" Calculate DAR with assumed SAR 1:1 when SAR is undefined. Same assumption is done in ffplay to create the play window. Usually DAR is more useful metadata than SAR when e.g. choosing which media of multiple versions to use to fit the display. Normally undefined SAR means 1:1. E.g. in mov/mp4 files there's 'pasp' atom to explicitly define SAR. If that is not specified, the video codec's SAR should be used. Should it be also undefined, the SAR should be assumed to be 1:1. It makes sense to not change SAR in the demux info, so ffmpeg can make copies with matching atom structure and codec extra data. So the simplest way to report DAR is assume SAR 1:1 when undefined. Signed-off-by: Timo Teräs --- This applies on top of the previous DAR/SAR reporting fix: https://ffmpeg.org/pipermail/ffmpeg-devel/2018-April/228141.html For more details behind this patch, see: https://ffmpeg.org/pipermail/ffmpeg-devel/2018-April/228146.html This seemed to be the most simple and logical fix. Alternatively, we could add a new 'effective_display_aspect_ratio' or add a flag to enable this assumption if the existing functionality should be kept unchanged. I felt this would be the most sensible thing to do. I am happy this if there's a more desirable approach to the issue. Hopefully this and the DAR/SAR reporting fix can be applied before next release tag. Thanks for considering! fftools/ffprobe.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 8b2a18b6b1..f7022bd3c2 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2523,15 +2523,15 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id sar = av_guess_sample_aspect_ratio(fmt_ctx, stream, NULL); if (sar.num) { print_q("sample_aspect_ratio", sar, ':'); - av_reduce(&dar.num, &dar.den, - par->width * sar.num, - par->height * sar.den, - 1024*1024); - print_q("display_aspect_ratio", dar, ':'); } else { print_str_opt("sample_aspect_ratio", "N/A"); - print_str_opt("display_aspect_ratio", "N/A"); + sar = (AVRational){ 1, 1 }; } + av_reduce(&dar.num, &dar.den, + par->width * sar.num, + par->height * sar.den, + 1024*1024); + print_q("display_aspect_ratio", dar, ':'); s = av_get_pix_fmt_name(par->format); if (s) print_str ("pix_fmt", s); else print_str_opt("pix_fmt", "unknown");