From patchwork Thu Mar 9 07:43:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 2849 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp215406vsy; Wed, 8 Mar 2017 23:44:21 -0800 (PST) X-Received: by 10.223.136.4 with SMTP id d4mr9319878wrd.44.1489045461201; Wed, 08 Mar 2017 23:44:21 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o4si7636380wrb.203.2017.03.08.23.44.20; Wed, 08 Mar 2017 23:44:21 -0800 (PST) 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 6DBAD688301; Thu, 9 Mar 2017 09:44:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbg320.qq.com (smtpbg320.qq.com [14.17.32.29]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1AD77680754 for ; Thu, 9 Mar 2017 09:43:55 +0200 (EET) X-QQ-mid: bizesmtp15t1489045403t2h9dkez Received: from localhost (unknown [47.90.47.25]) by esmtp4.qq.com (ESMTP) with id ; Thu, 09 Mar 2017 15:43:23 +0800 (CST) X-QQ-SSF: 01100000002000F0F820B00A0000000 X-QQ-FEAT: uQ7zd54tkGz/orZ1lHk5LC3Rf2mfwyQKhurmKKGF36O/L/j2y7HUq3bEFVt8k g52JC3YmuLWsr5zUwtygh1PX75p0WPBqi3O/A3po6kWpxc2CRiCOz1et9yL6cETylj6BhTc FdK7ORm72fxMr3Llz1U9UC1AvPk3nopa0g+P2UFeBbeB6ZIHbOX2rzraD1MFDmfoHsrqEfn 6+eJtqj/zLaH3qxaKK6zKqaJ3HoY7IsvetDQKQWqJ9P156lqj8yIXNBg2zC/vbkeflpXwFi IIOg== X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 Mar 2017 15:43:21 +0800 Message-Id: <20170309074321.31536-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.10.1.382.ga23ca1b.dirty X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] ffprobe: add show_video_keyframes option 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: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" add a option for show video keyframes info only when use show_packets or show_frames Signed-off-by: Steven Liu --- ffprobe.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ffprobe.c b/ffprobe.c index c85c3a1..3beceb2 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -81,6 +81,7 @@ static int do_show_programs = 0; static int do_show_streams = 0; static int do_show_stream_disposition = 0; static int do_show_data = 0; +static int do_show_video_keyframes = 0; static int do_show_program_version = 0; static int do_show_library_versions = 0; static int do_show_pixel_formats = 0; @@ -1820,6 +1821,12 @@ static void show_packet(WriterContext *w, InputFile *ifile, AVPacket *pkt, int p AVBPrint pbuf; const char *s; + if (do_show_video_keyframes) { + if ((st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) || !(pkt->flags & AV_PKT_FLAG_KEY)) { + return; + } + } + av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED); writer_print_section_header(w, SECTION_ID_PACKET); @@ -1899,6 +1906,12 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, const char *s; int i; + if (do_show_video_keyframes) { + if ((stream->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) || !(frame->key_frame)) { + return; + } + } + av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED); writer_print_section_header(w, SECTION_ID_FRAME); @@ -3225,6 +3238,7 @@ static const OptionDef real_options[] = { { "select_streams", OPT_STRING | HAS_ARG, {(void*)&stream_specifier}, "select the specified streams", "stream_specifier" }, { "sections", OPT_EXIT, {.func_arg = opt_sections}, "print sections structure and section information, and exit" }, { "show_data", OPT_BOOL, {(void*)&do_show_data}, "show packets data" }, + { "show_video_keyframes", OPT_BOOL, {(void*)&do_show_video_keyframes}, "show video keyframes info only" }, { "show_data_hash", OPT_STRING | HAS_ARG, {(void*)&show_data_hash}, "show packets data hash" }, { "show_error", 0, {(void*)&opt_show_error}, "show probing error" }, { "show_format", 0, {(void*)&opt_show_format}, "show format/container info" },