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 ESMTPS id 0C8014D680 for ; Fri, 21 Feb 2025 15:13:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BD07C68C767; Fri, 21 Feb 2025 17:13:38 +0200 (EET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B46368C45A for ; Fri, 21 Feb 2025 17:13:27 +0200 (EET) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-22128b7d587so43649205ad.3; Fri, 21 Feb 2025 07:13:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740150805; x=1740755605; darn=ffmpeg.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=vWJmgS2uxeF7Oqxo2vyFtsd66q4q+D4mvn6AAwm8vqY=; b=lNzZ7cTUaEdvdSkZ46Icr4DTTGxLGhFEyxBf/5a1Z2vM/P9KeUuHRK6LSMGdJgyuOe QHUUex80n/UbH32OdjyjDpeoig6uKeqeVIjDQX0XmYio7kRgAC3ITBSF+Af5tUEJ3lE4 u6WV7uazeCSaVZa1p076L/Q+drW4i9d3fWcyKZgKayrBSXqEqG7XpEvImIo/O9VLYtxY bWHGVAdOSx9/1YB6rnhBiO9rrnGiKjscP9G/bdmoV/IE8Y1RzzbEEB9CfRKnk1EcTs8B sKgKIDEmoPxhNjXSIFz3hnL2T4M3UNtKmcZpeUF7KeOuQvhKSdaRyKMpA8TNgsatHxFs TQrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740150805; x=1740755605; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vWJmgS2uxeF7Oqxo2vyFtsd66q4q+D4mvn6AAwm8vqY=; b=uLuxhyBrUlVt+8mC37R7KcFwSeXtDCgzrRcUFfQUb2DVk8gDG3LvEk9nHub0KR4ueS /oRujcV6BZkHe8kIAAtFN8AlWgs3e7+3o4UO2ujlB7f4QCNeyV51sA591+wqjt1iNvxn n3Mg7VTc0Xx8yBlW2aChsliD34JMHUpmrzc90tpiYhGnGlX/clzy2PZW5fqhE67j6OeR 7NgfT3jykMSQl7HBYfQPysqI4tn36aFT5lfWa4BT7jN/ewP6aVJuqpjPni8c2eLAYQMY w52WRzRaczCKyCQ3ML5GMlMTIkFFQqZzljRyD+SM1SWKWaQKjioUdkkyZAWi4mZZsmn+ A4HQ== X-Forwarded-Encrypted: i=1; AJvYcCUa4W/IoD0wZEXdEG+dSGEEk7kfnAOgS3vqknNBqa8EhNmGEmJK02rqh42/OLippEu3dmCEvNEAavt/Tws+xo6/iCDWn4lNQtA=@ffmpeg.org X-Gm-Message-State: AOJu0YziL9e6H/U3qan+mTOsd7gdTEUIGbD8HP1i0PfEl9RIc8hOdj/D keu6u3F75u7J9k0x959pXK1CVpj5ASn4qLdHby8YOM+FV9tdNH9M1m7BQQ== X-Gm-Gg: ASbGncuWV5rhkgdu0jIP+AUd6/GfUPSehOh0Abxx7rPPKzmoMjxvshO/2q1NB/V0nA2 G3u+XREgLUbp5rx0o+LLEp4T27bHZU1YSCtsYzO2ltTwEB4tDbUIgjj5zmy/fOuV7Dls/xJ2Egn ckpeyUOIr///W3X1Fvz98nwM4RtMX1VOUZxGakKiVVxQ4MdwROvDO/gNkYNrT5SZy8108i4OZ/m Fd1JbuosuXie8RPd0/cmaTlQiGcZhVVO0bPKKLoir973jcgVlST56AkCOoiv2UULQzBoFUbWU6D Ap4di+VOH5332181CIHOZ5LBzQKMACGcsrlycN1GDltG X-Google-Smtp-Source: AGHT+IH4ZT4Z8phNx08+bBGYOru5pSZiq+d9jwLhi3U27qjtw0x1WlAmFf0mjyvkvNvAjstC4ebOmQ== X-Received: by 2002:a05:6a20:8426:b0:1ee:833a:3990 with SMTP id adf61e73a8af0-1eef3c49075mr8022076637.7.1740150804081; Fri, 21 Feb 2025 07:13:24 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-732511dfd9esm14549388b3a.67.2025.02.21.07.13.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Feb 2025 07:13:23 -0800 (PST) Message-Id: In-Reply-To: References: From: ffmpegagent Date: Fri, 21 Feb 2025 15:13:20 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v2 0/2] avformat/hls demuxer: Add WebVTT subtitle support 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 Cc: Soft Works , softworkz , Andreas Rheinhardt 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: This add support for WebVTT subtitles in HLS streams. similar like for separate audio streams, it supports all available WebVTT streams in all renditions. No new options are added, it just works and provides subtitles streams like other demuxers. The code prevents downloading subtitle segments which are much farther in the future than the main segments to avoid loading hundreds of subtitle segments in advance. orig, 2022/10; scenarios tested: ffmpeg transcoding, ffprobe, MPV player Example command for testing: ffmpeg -i https://playertest.longtailvideo.com/adaptive/elephants_dream_v4/index.m3u8 -map v:0 -map a:0 -map s:1 -map s:0 -c:v copy -c:a copy -c:s srt -to 120s test1.mkv ...produces an MKV with two SRT sub tracks from WebVTT subs via HLS. Update V2 * Remove unnecessary assignment * Fixed indentation, reorder if-block * Inline string constant in code (as per review by Andreas Reinhardt) softworkz (2): avformat/hls demuxer: Add WebVTT subtitle support avformat/webvttdec: Add webvtt extension and MIME type libavformat/hls.c | 213 +++++++++++++++++++++++++++++++++------- libavformat/webvttdec.c | 3 +- 2 files changed, 178 insertions(+), 38 deletions(-) base-commit: e18f87ed9f9f61c980420b315dc8ecb308831bc5 Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-53%2Fsoftworkz%2Fsubmit_hlsvtt-v2 Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-53/softworkz/submit_hlsvtt-v2 Pull-Request: https://github.com/ffstaging/FFmpeg/pull/53 Range-diff vs v1: 1: c2e1404a42 ! 1: 3f9ee79232 avformat/hls demuxer: Add WebVTT subtitle support @@ Commit message Signed-off-by: softworkz ## libavformat/hls.c ## -@@ - #define MPEG_TIME_BASE 90000 - #define MPEG_TIME_BASE_Q (AVRational){1, MPEG_TIME_BASE} - -+static char *vtt_sample = "WEBVTT\n"; -+ - /* - * An apple http stream consists of a playlist with media segment files, - * played sequentially. There may be several playlists with the same @@ libavformat/hls.c: struct playlist { * playlist, if any. */ int n_init_sections; @@ libavformat/hls.c: struct playlist { }; /* -@@ libavformat/hls.c: static struct playlist *new_playlist(HLSContext *c, const char *url, - return NULL; - } - pls->seek_timestamp = AV_NOPTS_VALUE; -+ pls->is_subtitle = 0; - - pls->is_id3_timestamped = -1; - pls->id3_mpegts_timestamp = AV_NOPTS_VALUE; @@ libavformat/hls.c: static struct rendition *new_rendition(HLSContext *c, struct rendition_info *inf return NULL; } @@ libavformat/hls.c: static struct rendition *new_rendition(HLSContext *c, struct rend->playlist = new_playlist(c, info->uri, url_base); - if (rend->playlist) + if (rend->playlist) { - dynarray_add(&rend->playlist->renditions, -- &rend->playlist->n_renditions, rend); -+ &rend->playlist->n_renditions, rend); + if (type == AVMEDIA_TYPE_SUBTITLE) { + rend->playlist->is_subtitle = 1; + rend->playlist->is_id3_timestamped = 0; + } + dynarray_add(&rend->playlist->renditions, + &rend->playlist->n_renditions, rend); + } } @@ libavformat/hls.c: reload: + } + return ret; +} -+ + +static int read_data_continuous(void *opaque, uint8_t *buf, int buf_size) +{ + struct playlist *v = opaque; @@ libavformat/hls.c: reload: + ret = reload_playlist(v, c); + if (ret < 0) + return ret; - ++ + seg = current_segment(v); + + if (!v->input || (c->http_persistent && v->input_read_done)) { @@ libavformat/hls.c: static int hls_read_header(AVFormatContext *s) - ffio_init_context(&pls->pb, pls->read_buffer, INITIAL_BUFFER_SIZE, 0, pls, - read_data, NULL, NULL); + if (pls->is_subtitle) -+ ffio_init_context(&pls->pb, (unsigned char*)av_strdup(vtt_sample), (int)strlen(vtt_sample), 0, pls, -+ NULL, NULL, NULL); ++ ffio_init_context(&pls->pb, (unsigned char*)av_strdup("WEBVTT\n"), (int)strlen("WEBVTT\n"), 0, pls, ++ NULL, NULL, NULL); + else + ffio_init_context(&pls->pb, pls->read_buffer, INITIAL_BUFFER_SIZE, 0, pls, + read_data_continuous, NULL, NULL); 2: aff0dd2be2 = 2: 7550e41042 avformat/webvttdec: Add webvtt extension and MIME type -- ffmpeg-codebot _______________________________________________ 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".