gst-plugins-rs/video/closedcaption/src/transcriberbin/mod.rs

60 lines
1.8 KiB
Rust
Raw Normal View History

// Copyright (C) 2021 Mathieu Duponchelle <mathieu@centricular.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// <https://mozilla.org/MPL/2.0/>.
//
// SPDX-License-Identifier: MPL-2.0
use gst::glib;
use gst::prelude::*;
mod imp;
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
#[repr(u32)]
#[enum_type(name = "GstTranscriberBinCaptionSource")]
pub enum CaptionSource {
Both,
Transcription,
Inband,
}
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq, glib::Enum)]
#[repr(u32)]
#[enum_type(name = "GstTranscriberBinMuxMethod")]
enum MuxMethod {
#[default]
Cea608,
Cea708,
}
glib::wrapper! {
transcriberbin: add support for consuming secondary audio streams In some situations, a translated alternate audio stream for a content might be available. Instead of going through transcription and translation of the original audio stream, it may be preferrable for accuracy purposes to simply transcribe the secondary audio stream. This MR adds support for doing just that: * Secondary audio sink pads can be requested as "sink_audio_%u" * Sometimes audio source pads are added at that point to pass through the audio, as "src_audio_%u" * The main transcription bin now contains per-input stream transcription bins. Those can be individually controlled through properties on the sink pads, for instance translation-languages can be dynamically set per audio stream * Some properties that originally existed on the main element still remain, but are now simply mapped to the always audio sink pad * Releasing of secondary sink pads is nominally implemented, but not tested in states other than NULL An example launch line for this would be: ``` $ gst-launch-1.0 transcriberbin name=transcriberbin latency=8000 accumulate-time=0 \ cc-caps="closedcaption/x-cea-708, format=cc_data" sink_audio_0::language-code="es-US" \ sink_audio_0::translation-languages="languages, transcript=cc3" uridecodebin uri=file:///home/meh/Music/chaplin.mkv name=d d. ! videoconvert ! transcriberbin.sink_video d. ! clocksync ! audioconvert ! transcriberbin.sink_audio transcriberbin.src_video ! cea608overlay field=1 ! videoconvert ! autovideosink \ transcriberbin.src_audio ! audioconvert ! fakesink \ uridecodebin uri=file:///home/meh/Music/chaplin-spanish.webm name=d2 \ d2. ! audioconvert ! transcriberbin.sink_audio_0 \ transcriberbin.src_audio_0 ! fakesink ``` Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1546>
2024-04-19 18:12:46 +00:00
pub struct TranscriberBin(ObjectSubclass<imp::TranscriberBin>) @extends gst::Bin, gst::Element, gst::Object, @implements gst::ChildProxy;
}
glib::wrapper! {
pub struct TranscriberSinkPad(ObjectSubclass<imp::TranscriberSinkPad>) @extends gst::GhostPad, gst::ProxyPad, gst::Pad, gst::Object;
}
glib::wrapper! {
pub struct TranscriberSrcPad(ObjectSubclass<imp::TranscriberSrcPad>) @extends gst::GhostPad, gst::ProxyPad, gst::Pad, gst::Object;
}
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
#[cfg(feature = "doc")]
{
CaptionSource::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
MuxMethod::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
transcriberbin: add support for consuming secondary audio streams In some situations, a translated alternate audio stream for a content might be available. Instead of going through transcription and translation of the original audio stream, it may be preferrable for accuracy purposes to simply transcribe the secondary audio stream. This MR adds support for doing just that: * Secondary audio sink pads can be requested as "sink_audio_%u" * Sometimes audio source pads are added at that point to pass through the audio, as "src_audio_%u" * The main transcription bin now contains per-input stream transcription bins. Those can be individually controlled through properties on the sink pads, for instance translation-languages can be dynamically set per audio stream * Some properties that originally existed on the main element still remain, but are now simply mapped to the always audio sink pad * Releasing of secondary sink pads is nominally implemented, but not tested in states other than NULL An example launch line for this would be: ``` $ gst-launch-1.0 transcriberbin name=transcriberbin latency=8000 accumulate-time=0 \ cc-caps="closedcaption/x-cea-708, format=cc_data" sink_audio_0::language-code="es-US" \ sink_audio_0::translation-languages="languages, transcript=cc3" uridecodebin uri=file:///home/meh/Music/chaplin.mkv name=d d. ! videoconvert ! transcriberbin.sink_video d. ! clocksync ! audioconvert ! transcriberbin.sink_audio transcriberbin.src_video ! cea608overlay field=1 ! videoconvert ! autovideosink \ transcriberbin.src_audio ! audioconvert ! fakesink \ uridecodebin uri=file:///home/meh/Music/chaplin-spanish.webm name=d2 \ d2. ! audioconvert ! transcriberbin.sink_audio_0 \ transcriberbin.src_audio_0 ! fakesink ``` Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1546>
2024-04-19 18:12:46 +00:00
TranscriberSinkPad::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
TranscriberSrcPad::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
}
gst::Element::register(
Some(plugin),
"transcriberbin",
2023-11-02 12:10:59 +00:00
gst::Rank::NONE,
TranscriberBin::static_type(),
)
}