From patchwork Mon Jan 11 14:20:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 24895 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 788C044AE96 for ; Mon, 11 Jan 2021 16:26:12 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5497068AA95; Mon, 11 Jan 2021 16:26:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB4D568AA87 for ; Mon, 11 Jan 2021 16:26:05 +0200 (EET) Received: by mail-ej1-f45.google.com with SMTP id b9so25124125ejy.0 for ; Mon, 11 Jan 2021 06:26:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=DbkOzbx5LRFuHQO/XcBmlXpOg1CXM3PzIZQ50QXGK48=; b=eHvyqdDe8o0T8dGBD7zR4CA3ov5cRPRlbxPXPFXRS0Z5HoTPVvmeuzKMQvICIhBqgA R1iOe686AXiRfQUm3yj6KVlrZUm5yTM7KEQu3MUMJ5kXiKs3WQ43Kl541WOM4d+Utl/b I4Bozc02n6ac1hPAzkTZ2n3IQuu6YUzZF3SDA59wuTZ414gx9wmo9pEdA98azRsyu0oc 82OI9A7xAvAuCziSjmSmc5e+sodTsmDFS/8RGCSl2Pbx0+mnovI7jp9Jjr1s6tx40OKQ RKC3zqBLFiYRgFF2yKGlSZLZ306Ens2PRgFjO0hKg/htd/klwpxsJZCnJ+xJzojMKrqJ du8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=DbkOzbx5LRFuHQO/XcBmlXpOg1CXM3PzIZQ50QXGK48=; b=HylCnb8QHH+2op1oL86bdRmk8RVfYPNHVETw+XVtFh3ncbzWKJwDV2dJniXfTu4Am2 aPBkgi3ua/ZMAKGvmoYsAoNXLUfhRgN80qkFYnwofmWyNIXuj6kvgbGlciUZqd2lIHK4 bVPF3N+BWH/6v9NECtJvZMRUKqsdQ6VXyCCPB4PajY8GjbGyEAzkrJlRPxB0rbpVz6Rl wX/xSEnjTDUuqgSdUsXgOJD4M2IHF9ifP7Ne6Co8HkOxdN/EnMqhFCHdtQINKYrlYQCE dbfw0Wk8PJig2X2RB8m9IrWO5wt9i3QhckBLCR2BltecBkzwzJaENQLjknrEAiafzvrN O1Sw== X-Gm-Message-State: AOAM533jr5R+4RtQpvXfhYvNDpYGnCB91X6ixyrtWDFPjHDkTJ+F3ewN 8hps0MDQdTNoBM0nJItmhpC029Ogcq8= X-Google-Smtp-Source: ABdhPJwQMKXKJGDBe6qYVQE2/76QUPGKnvDcwjCthuPqUn9n7z65BhqAtrjLVYQiyWO63niqtb+3Iw== X-Received: by 2002:a2e:b4d3:: with SMTP id r19mr7107771ljm.419.1610374823864; Mon, 11 Jan 2021 06:20:23 -0800 (PST) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id n20sm3113081lfh.133.2021.01.11.06.20.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 06:20:22 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Jan 2021 16:20:17 +0200 Message-Id: <20210111142020.24303-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 0/3] Initial implementation of TTML encoding/muxing 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" I've intentionally kept this initial version simple (no styling etc) to focus on the basics. As this goes through review, additional features can be added (I had initial PoC for styling implemented some time around previous VDD), and there is another patch set in my queue which would then add support for muxing TTML into MP4. Changes from the initial version: - Switched to the initial idea posted on IRC that by having *any* extradata the muxing mode is switched to document based as opposed to paragraph based in the muxer. Additionally, the muxer now blocks writing of multiple documents into a single output. My alternative idea would have been to attach side data specifying that this is a TTML paragraph (as opposed to a full XML document that would come out of demuxing) to the returned AVPacket, but it seems like I keep forgetting that subtitle encoding currently does not return AVPackets, but buffers. - Improved error codes (AVERROR_BUFFER_TOO_SMALL, EINVAL instead of ENOSYS, error handling in ttml_encode_init) - Switched to av_strlcpy in order to properly null-terminate the output buffers from the TTML encoder. - Renamed AVStream called s to st as it indeed was confusing. - Switched to utilizing avio_w8 when writing a single byte in the muxer. Jan Jan Ekström (2): ffprobe: switch to av_bprint_escape for XML escaping {avcodec,avformat}: add TTML encoder and muxer Stefano Sabatini (1): avutil/{avstring,bprint}: add XML escaping from ffprobe to avutil Changelog | 1 + doc/general_contents.texi | 1 + fftools/ffprobe.c | 29 ++---- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/ttmlenc.c | 178 +++++++++++++++++++++++++++++++++++++ libavcodec/version.h | 4 +- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/ttmlenc.c | 166 ++++++++++++++++++++++++++++++++++ libavformat/version.h | 4 +- libavutil/avstring.h | 1 + libavutil/bprint.c | 14 +++ tests/fate/subtitles.mak | 3 + tests/ref/fate/sub-ttmlenc | 122 +++++++++++++++++++++++++ tools/ffescape.c | 1 + 16 files changed, 503 insertions(+), 25 deletions(-) create mode 100644 libavcodec/ttmlenc.c create mode 100644 libavformat/ttmlenc.c create mode 100644 tests/ref/fate/sub-ttmlenc