From patchwork Fri Sep 9 03:14:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 485 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp106598vsd; Thu, 8 Sep 2016 20:14:49 -0700 (PDT) X-Received: by 10.194.83.33 with SMTP id n1mr619061wjy.36.1473390889211; Thu, 08 Sep 2016 20:14:49 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u129si984735wmb.96.2016.09.08.20.14.48; Thu, 08 Sep 2016 20:14:49 -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=@gmail.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; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B097368A05D; Fri, 9 Sep 2016 06:14:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f182.google.com (mail-qk0-f182.google.com [209.85.220.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3597D689FCA for ; Fri, 9 Sep 2016 06:14:29 +0300 (EEST) Received: by mail-qk0-f182.google.com with SMTP id w204so65757764qka.0 for ; Thu, 08 Sep 2016 20:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:cc; bh=fBh70q9bBc0KGJUiTe/ZFTW/QnWr3SK654nx0GIWHKE=; b=0lgV4sqfJFM/loxd7aATFr2G0Ek9YLOsMpb7T9GVVj/JA1qDSeoIY2Egjq20uo+jxf N2oofGPhM+0bHu2zDCffVuNm0Yihh1nGX08o/jf/wTDAVLjcd9tkmkxQw+IlqKFtfOGZ 5nmcDHLEJLYHfzuQnC4UHLPKeOApmoRLgrp1EG5F2rVCQQ+9xHEo+/y4amhVzV3NXhOZ BSejLe5rS+CyYKRjs7lAvzlwdLKRoy+id8J6co4lAokm86QkMmfE2G/NnQkevJopSRfv 4lvzMY1CnUr+l0QNoI8z4vz3B0DZr6uwKxksicoKTsOlVWotahbDXumXclognm5DJAN/ xlpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=fBh70q9bBc0KGJUiTe/ZFTW/QnWr3SK654nx0GIWHKE=; b=CUytO/9IAcHD3DsKRsjrGO9iwxzBG1vSixUf1ZlDhZ4Vpgv6hU3RLvbYraWRJt8Cx0 jf39+0duWwcRRwtdSqKoJtiHuAZo/IbvXdtOQqs+o+aIlC07VaL3GtpMGHDKCzWQriu/ tAx7L2BcPyDlfQ7b/o69nGdlcT0VfnWi4zEAPmSTRsZJusHPit8e07LE3U1tsJpYikDK W4zJaq2lGU1v7BhwsafJnCUDcAZcOhFC6gn9Ytrdv37oJj7hybEot+AIuVAWYVQex39H dXrCW0pIvdxWgmWxPv69Wcb5nluU/bpM1e8WrdpfCwj4yGbcuAzQRZ+y9+WiXsTre887 JyOQ== X-Gm-Message-State: AE9vXwO3L4cVrj05TjIpQb+in/mcG7Xw6Fv6Xxs0q3hwgjscRNh+YAemffg22Fxvq7i31m+pT5wiloVGZjmMSw== X-Received: by 10.55.147.1 with SMTP id v1mr1510923qkd.188.1473390878310; Thu, 08 Sep 2016 20:14:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.56.42 with HTTP; Thu, 8 Sep 2016 20:14:37 -0700 (PDT) From: Steven Liu Date: Fri, 9 Sep 2016 11:14:37 +0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] avformat/segment: fix the duration error of use output_ts_offset 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This patch can merge with 1da00be009aa74400042bf470b9a5ffbd82a1c5e i have checked this modify: ./ffmpeg -i ~/facebook.mp4 -c copy -f segment -segment_time 2 -output_ts_offset 80 -segment_list output-test.m3u8 -v debug output-test-%03d.ts #EXTM3U #EXT-X-VERSION:3 #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-ALLOW-CACHE:YES #EXT-X-TARGETDURATION:10 #EXTINF:4.120000, output-test-000.ts #EXTINF:7.840000, output-test-001.ts #EXTINF:4.200000, output-test-002.ts #EXTINF:2.920000, output-test-003.ts #EXTINF:1.840000, output-test-004.ts #EXTINF:2.240000, output-test-005.ts #EXTINF:2.000000, output-test-006.ts #EXTINF:3.560000, [root@localhost linux]# ffmpeg -i output-test.m3u8 ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17) configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264 --enable-libfaac --enable-gpl --enable-nonfree libavutil 55. 28.100 / 55. 28.100 libavcodec 57. 48.102 / 57. 48.102 libavformat 57. 41.100 / 57. 41.100 libavdevice 57. 0.102 / 57. 0.102 libavfilter 6. 47.100 / 6. 47.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 1.100 / 2. 1.100 libpostproc 54. 0.100 / 54. 0.100 Input #0, hls,applehttp, from 'output-test.m3u8': Duration: 00:03:21.04, start: 81.400000, bitrate: 0 kb/s Program 0 Metadata: variant_bitrate : 0 Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s At least one output file must be specified [root@localhost linux]# ffmpeg -i output-test-000.ts -i output-test-001.ts ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17) configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264 --enable-libfaac --enable-gpl --enable-nonfree libavutil 55. 28.100 / 55. 28.100 libavcodec 57. 48.102 / 57. 48.102 libavformat 57. 41.100 / 57. 41.100 libavdevice 57. 0.102 / 57. 0.102 libavfilter 6. 47.100 / 6. 47.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 1.100 / 2. 1.100 libpostproc 54. 0.100 / 54. 0.100 Input #0, mpegts, from 'output-test-000.ts': Duration: 00:00:04.12, start: 81.400000, bitrate: 1299 kb/s Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #0:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s Input #1, mpegts, from 'output-test-001.ts': Duration: 00:00:07.90, start: 85.464000, bitrate: 1679 kb/s Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #1:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream #1:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s At least one output file must be specified [root@localhost linux]# this commit is used for fix commit 1da00be009aa74400042bf470b9a5ffbd82a1c5e because the option initial_offset will deprecated Signed-off-by: Steven Liu --- libavformat/segment.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) AV_TIME_BASE_Q); + seg->cur_entry.end_time = seg->cur_entry.start_time; } av_log(s, AV_LOG_DEBUG, "stream:%d start_pts_time:%s pts:%s pts_time:%s dts:%s dts_time:%s", -- 1.7.1 diff --git a/libavformat/segment.c b/libavformat/segment.c index 33a5cf0..252f8b1 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -885,6 +885,11 @@ calc_times: av_log(s, AV_LOG_VERBOSE, "segment:'%s' starts with packet stream:%d pts:%s pts_time:%s frame:%d\n", seg->avf->filename, pkt->stream_index, av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), seg->frame_count); + seg->cut_pending = 0; + seg->cur_entry.index = seg->segment_idx + seg->segment_idx_wrap * seg->segment_idx_wrap_nb; + seg->cur_entry.start_time = (double)pkt->pts * av_q2d(st->time_base); + seg->cur_entry.start_pts = av_rescale_q(pkt->pts, st->time_base,