From patchwork Fri May 18 00:04:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 9006 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp4681540jad; Thu, 17 May 2018 17:05:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqlGxaki60OnxueC1g11Ye70KU9rkJBo37DkICE2LsiTUsWOQQyKMvU5qWJ+PSWfZZf6MrL X-Received: by 2002:adf:90cd:: with SMTP id i71-v6mr5784235wri.136.1526601902857; Thu, 17 May 2018 17:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526601902; cv=none; d=google.com; s=arc-20160816; b=Hk+P8YHZPZNy19e6iwR1TB8c97/3GEwyqFflACZHXgBMV/NtZsKfoVeU1MsQlGkZk7 YJ9bxhLcVWU5C+2pfkqGRcUHH+taG2oWjKXBscHpwN70T+7PZcnpxpgVH5y0/+fi02Hf rC5V/JB+Zy3oEvQk4dVOWJANFBI3bMaQTeBs6y1tg5vfr/eFBEwO3bU8H2jFQ41tf9CF 3p/f00Z0bLwXL3P2wMI8B8SwcB9jT4gx6XChRBWuRBVzIS5nifg5gPWgOBXARCtAbWTP yBopXlGyKuxsb7KwDucYSSqvRmKh6Ua9HogzvgZLSo7Aan5ymVwUSJh/dxQTRn5NXZyH Iu5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=GlcpRDcp0tmWOQ8PT87UM0wP5A00WCFx6vKgltPIp+Q=; b=vJG9FiB4MyCyMuUvzSPur1kumA0F/QRd/y9R0gbolk3FbaZHfgg/LNI9cz/cJnvPJD 5Q0L16oqEWvBAh/Pf8I05qT2TFn+9VlRfVxoq9krD/2sinoR6/jCoTIAzwQj/QYY1Qgs TixXNZhqJYaoRQOVl0CLOjXsqajz4k5t0pSEK5bvRv3VuaO/FTmbpozO7sUDgGwwB8ha WJE4GwDMBbcXV4X95J+1MZox+mCrAhyrhQgas7lXEc8WLOh+qBXWb3ZI0qozd/U1en7r wArfq2cqVT/DrSgF4tdHkrD5t8Brtpsx3y2Jc75j+sh/kvoReo6P71hdeqaSMXG/Cd4m ok4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=h6PvW7rU; 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 i76-v6si5153548wme.5.2018.05.17.17.05.02; Thu, 17 May 2018 17:05:02 -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=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=h6PvW7rU; 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 5B46F68A53E; Fri, 18 May 2018 03:04:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl0-f41.google.com (mail-pl0-f41.google.com [209.85.160.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5D07068A52F for ; Fri, 18 May 2018 03:04:15 +0300 (EEST) Received: by mail-pl0-f41.google.com with SMTP id bi12-v6so3470838plb.12 for ; Thu, 17 May 2018 17:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=0JEyS/2QyluHH2yWNn49yGPnLp5mSZQgA+KPhu9ZbXg=; b=h6PvW7rUiR5vDpe/hgRXEr2YYtqlInDBFAaBTmhZddJ1J0E6XkfqEtEohZr9bEDaS4 NUCZub1l9qwvESz3/xCVkPrdVne7nSwfkYf1fzU0fs9d9pUQYV10v9aN5SO3xJKgB1mF adyYQBdpt00hSEb0lE1EBh7pXv9w4ZoTG6kMXaF1nGiQ1HzLSpP/6pMpC2BI42v2PDZw Y+OEmPLiFfsMWhTAfJyLL3ile7os9OJjNZcVOA2Tgc6FMAbtOF4XQ5XMoUJOd6gT6ppY XonCWZMR4B03t6nPuEtiaKoiqGIj35gho4Mgzh/HDdjkWYfU3l2OnxCkv6nsSwJsijvF XogA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=0JEyS/2QyluHH2yWNn49yGPnLp5mSZQgA+KPhu9ZbXg=; b=KA5kzuEzXS92iExx2XF3KnWEF64suDTeMRyGZPrIM++f2ri49GdlCyQe66IjdphVJA ti5fDtTHPZ6zJZuAlgFaoVWj/dJMDlevQ6zpqgo17kFtTOCG9CqnpanAhV3o+MfdLp+E HxaYlB7MuDXzdAN+1g4Wg+DwCe9h+kAVpvYbyYQ1ZxQOKm4Xrcn1wAEavOGqT7QNUM/f cX9LaDE0IwrGF0hAWx6YGY+UpnTo9EKD+XNe4cytgDMcsVyweozz1YSwcM9eXyA1coct 7EwYDYtTP2QIrQXD4GAViRDdin3pVODCojDOMfXl93aOnxE0Bb5rf+Oww0UoehgYDbBk dlmg== X-Gm-Message-State: ALKqPwe1+lYuv3xgtxIF7qJTPsbDzRlXJq92SMDJ0lWBJVkbMUV4RH+H AAj/gX9KJCO6ladbFlkpudNl+7dL X-Received: by 2002:a17:902:2006:: with SMTP id n6-v6mr7288389pla.125.1526601892582; Thu, 17 May 2018 17:04:52 -0700 (PDT) Received: from localhost.localdomain (c-69-181-54-242.hsd1.ca.comcast.net. [69.181.54.242]) by smtp.gmail.com with ESMTPSA id w12-v6sm13899435pfi.158.2018.05.17.17.04.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 May 2018 17:04:51 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 May 2018 17:04:44 -0700 Message-Id: <20180518000444.19218-1-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.14.2 Subject: [FFmpeg-devel] [PATCH] avformat/mpegts: add skip_unknown_pmt 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: Aman Gupta MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta Some filtered mpegts streams may erroneously include PMTs for programs that are not advertised in the PAT. This confuses ffmpeg and most players because multiple audio/video streams are created and it is unclear which ones actually contain data. See for example https://tmm1.s3.amazonaws.com/unknown-pmts.ts Before: Input #0, mpegts, from 'unknown-pmts.ts': Duration: 00:00:10.11, start: 80741.189700, bitrate: 9655 kb/s Program 4 Stream #0:2[0x41]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 11063 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc Stream #0:3[0x44](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s Stream #0:4[0x45](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 128 kb/s No Program Stream #0:0[0x31]: Video: mpeg2video ([2][0][0][0] / 0x0002), none(tv), 90k tbr, 90k tbn, 90k tbc Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 0 channels, fltp Stream #0:5[0x51]: Video: mpeg2video ([2][0][0][0] / 0x0002), none, 90k tbr, 90k tbn Stream #0:6[0x54](eng): Audio: ac3 (AC-3 / 0x332D4341), 0 channels With skip_unknown_pmt=1: Input #0, mpegts, from 'unknown-pmts.ts': Duration: 00:00:10.11, start: 80741.189700, bitrate: 9655 kb/s Program 4 Stream #0:0[0x41]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 11063 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc Stream #0:1[0x44](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s Stream #0:2[0x45](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 128 kb/s Signed-off-by: Aman Gupta --- doc/demuxers.texi | 3 +++ libavformat/mpegts.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index e7c2abce57..1d2ee5bf37 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -538,6 +538,9 @@ This demuxer accepts the following options: Set size limit for looking up a new synchronization. Default value is 65536. +@item skip_unknown_pmt +Skip PMTs for programs not defined in the PAT. Default value is 0. + @item fix_teletext_pts Override teletext packet PTS and DTS values with the timestamps calculated from the PCR of the first program which the teletext stream is part of and is diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index fc9bb3940e..18df1afd9d 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -143,6 +143,7 @@ struct MpegTSContext { int skip_changes; int skip_clear; + int skip_unknown_pmt; int scan_all_pmts; @@ -172,6 +173,8 @@ static const AVOption options[] = { {.i64 = 0}, 0, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY }, {"scan_all_pmts", "scan and combine all PMTs", offsetof(MpegTSContext, scan_all_pmts), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM }, + {"skip_unknown_pmt", "skip PMTs for programs not advertised in the PAT", offsetof(MpegTSContext, skip_unknown_pmt), AV_OPT_TYPE_BOOL, + {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, {"skip_changes", "skip changing / adding streams / programs", offsetof(MpegTSContext, skip_changes), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, 0 }, {"skip_clear", "skip clearing programs", offsetof(MpegTSContext, skip_clear), AV_OPT_TYPE_BOOL, @@ -2028,6 +2031,8 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len if (!ts->scan_all_pmts && ts->skip_changes) return; + if (ts->skip_unknown_pmt && !get_program(ts, h->id)) + return; if (!ts->skip_clear) clear_program(ts, h->id);