From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id AF8514415C for ; Mon, 29 Aug 2022 14:17:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5B90868BAA8; Mon, 29 Aug 2022 17:17:05 +0300 (EEST) Received: from smtp.outgoing.loopia.se (smtp.outgoing.loopia.se [93.188.3.37]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B5BB068BA9F for ; Mon, 29 Aug 2022 17:16:59 +0300 (EEST) Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id B19022F4FC64 for ; Mon, 29 Aug 2022 16:16:58 +0200 (CEST) Received: from s981.loopia.se (unknown [172.22.191.5]) by s807.loopia.se (Postfix) with ESMTP id A30782E2859D for ; Mon, 29 Aug 2022 16:16:58 +0200 (CEST) Received: from s470.loopia.se (unknown [172.22.191.5]) by s981.loopia.se (Postfix) with ESMTP id A0F3522B197A for ; Mon, 29 Aug 2022 16:16:58 +0200 (CEST) X-Virus-Scanned: amavisd-new at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1 X-Spam-Level: X-Spam-Status: No, score=-1 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1] autolearn=disabled Received: from s979.loopia.se ([172.22.191.6]) by s470.loopia.se (s470.loopia.se [172.22.190.10]) (amavisd-new, port 10024) with LMTP id 9GRlqo1GOvIN for ; Mon, 29 Aug 2022 16:16:58 +0200 (CEST) X-Loopia-Auth: user X-Loopia-User: peter@zebuhr.se X-Loopia-Originating-IP: 46.59.58.112 Received: from smtpclient.apple (h-46-59-58-112.A213.priv.bahnhof.se [46.59.58.112]) (Authenticated sender: peter@zebuhr.se) by s979.loopia.se (Postfix) with ESMTPSA id 2E09E10BC67C for ; Mon, 29 Aug 2022 16:16:58 +0200 (CEST) From: =?utf-8?Q?Peter_Zeb=C3=BChr?= Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Message-Id: <30245E67-C26D-4DD0-879E-CEF516AD52BF@zebuhr.se> Date: Mon, 29 Aug 2022 16:16:57 +0200 To: FFmpeg development discussions and patches X-Mailer: Apple Mail (2.3696.120.41.1.1) Subject: [FFmpeg-devel] Matroska and output_ts_offset X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Hello, I noticed the other day that if I try to mux opus in webm with a timestamp offset set I don't get the expected timestamps out on my packets. Example: ffmpeg -f lavfi -i "sine=frequency=1000:duration=60" -output_ts_offset 200ms -c:a libopus sine_200ms_offset.webm Now if I inspect the packets with ffprobe on the produced output the first packet has a PTS of 186. My expectation would be that it would be: 200 - 6.5 (opus encoder delay) ~= 193. Looking at the output with mkvinfo also indicates that it starts at 193ms (186 + encoder delay I assume here). At first I thought it looked like the encoder delay gets added twice, but after some more pondering I think what is happening here is: 1. Opus outputs packets starting with the priming samples, that ends up with a negative PTS (rounded to -7) 2. In mux.c the output_ts_offset takes effect before the call to "handle_avoid_negative_ts" 3. PTS -7 gets shifter by the requested ts_offset to 193 4. Matroska muxer writes the side data about encoder delay. 5. The produced stream now effectively starts one encoder delay distance too early. I played around locally with moving the call to "handle_avoid_negative_ts" in mux.c/write_packet to right before the ts_offset handling instead of right after and that seems to fix this particular problem. But, I am unsure what other potential consequences that would have. Would appreciate if someone more familiar with this can help fix this issue. Regards, Peter _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".