Compare commits

...

8 commits

3 changed files with 212 additions and 109 deletions

203
Cargo.lock generated
View file

@ -19,9 +19,9 @@ checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
[[package]]
name = "async-trait"
version = "0.1.52"
version = "0.1.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3"
checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600"
dependencies = [
"proc-macro2",
"quote",
@ -41,7 +41,23 @@ dependencies = [
"pin-project-lite",
"tokio",
"tokio-native-tls",
"tungstenite",
"tungstenite 0.16.0",
]
[[package]]
name = "async-tungstenite"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1b71b31561643aa8e7df3effe284fa83ab1a840e52294c5f4bd7bfd8b2becbb"
dependencies = [
"futures-io",
"futures-util",
"log",
"native-tls",
"pin-project-lite",
"tokio",
"tokio-native-tls",
"tungstenite 0.17.2",
]
[[package]]
@ -103,6 +119,15 @@ dependencies = [
"generic-array",
]
[[package]]
name = "block-buffer"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324"
dependencies = [
"generic-array",
]
[[package]]
name = "byteorder"
version = "1.4.3"
@ -118,7 +143,7 @@ checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
name = "cairo-rs"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#bf334f3c7f69b47499e02d74bb33c7846c5d86e6"
source = "git+https://github.com/gtk-rs/gtk-rs-core#cece39f48486ed724668e431f242a9b1ab849147"
dependencies = [
"bitflags",
"cairo-sys-rs",
@ -130,7 +155,7 @@ dependencies = [
[[package]]
name = "cairo-sys-rs"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#bf334f3c7f69b47499e02d74bb33c7846c5d86e6"
source = "git+https://github.com/gtk-rs/gtk-rs-core#cece39f48486ed724668e431f242a9b1ab849147"
dependencies = [
"glib-sys 0.16.0",
"libc",
@ -190,9 +215,9 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "cpufeatures"
version = "0.2.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469"
checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b"
dependencies = [
"libc",
]
@ -221,6 +246,16 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "crypto-common"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "crypto-mac"
version = "0.11.1"
@ -250,6 +285,16 @@ dependencies = [
"generic-array",
]
[[package]]
name = "digest"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506"
dependencies = [
"block-buffer 0.10.2",
"crypto-common",
]
[[package]]
name = "dirs-next"
version = "2.0.0"
@ -447,9 +492,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.5"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77"
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
dependencies = [
"cfg-if",
"libc",
@ -479,7 +524,7 @@ dependencies = [
[[package]]
name = "glib"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#bf334f3c7f69b47499e02d74bb33c7846c5d86e6"
source = "git+https://github.com/gtk-rs/gtk-rs-core#cece39f48486ed724668e431f242a9b1ab849147"
dependencies = [
"bitflags",
"futures-channel",
@ -514,7 +559,7 @@ dependencies = [
[[package]]
name = "glib-macros"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#bf334f3c7f69b47499e02d74bb33c7846c5d86e6"
source = "git+https://github.com/gtk-rs/gtk-rs-core#cece39f48486ed724668e431f242a9b1ab849147"
dependencies = [
"anyhow",
"heck",
@ -538,7 +583,7 @@ dependencies = [
[[package]]
name = "glib-sys"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#bf334f3c7f69b47499e02d74bb33c7846c5d86e6"
source = "git+https://github.com/gtk-rs/gtk-rs-core#cece39f48486ed724668e431f242a9b1ab849147"
dependencies = [
"libc",
"system-deps",
@ -558,7 +603,7 @@ dependencies = [
[[package]]
name = "gobject-sys"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#bf334f3c7f69b47499e02d74bb33c7846c5d86e6"
source = "git+https://github.com/gtk-rs/gtk-rs-core#cece39f48486ed724668e431f242a9b1ab849147"
dependencies = [
"glib-sys 0.16.0",
"libc",
@ -577,7 +622,7 @@ dependencies = [
"cc",
"chrono",
"either",
"gst-plugin-version-helper",
"gst-plugin-version-helper 0.9.0",
"gstreamer 0.19.0",
"gstreamer-base 0.19.0",
"gstreamer-video 0.19.0",
@ -595,14 +640,14 @@ name = "gst-plugin-rusoto"
version = "0.9.0"
source = "git+https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git?branch=transbin-accept-any-video-caps#bf1224511f24610716f69c5459b0473edf58f4a4"
dependencies = [
"async-tungstenite",
"async-tungstenite 0.16.1",
"atomic_refcell",
"base32",
"byteorder",
"bytes",
"crc",
"futures",
"gst-plugin-version-helper",
"gst-plugin-version-helper 0.9.0",
"gstreamer 0.19.0",
"gstreamer-base 0.19.0",
"nom",
@ -624,13 +669,22 @@ name = "gst-plugin-textwrap"
version = "0.9.0"
source = "git+https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git?branch=transbin-accept-any-video-caps#bf1224511f24610716f69c5459b0473edf58f4a4"
dependencies = [
"gst-plugin-version-helper",
"gst-plugin-version-helper 0.9.0",
"gstreamer 0.19.0",
"hyphenation",
"once_cell",
"textwrap",
]
[[package]]
name = "gst-plugin-version-helper"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a6a4dd1cb931cc6b49af354a68f21b3aee46b5b07370215d942f3a71542123f"
dependencies = [
"chrono",
]
[[package]]
name = "gst-plugin-version-helper"
version = "0.9.0"
@ -639,6 +693,23 @@ dependencies = [
"chrono",
]
[[package]]
name = "gst-plugin-vosk"
version = "0.1.0"
dependencies = [
"async-tungstenite 0.17.2",
"atomic_refcell",
"futures",
"gst-plugin-version-helper 0.7.3",
"gstreamer 0.18.6",
"gstreamer-base 0.18.0",
"once_cell",
"serde",
"serde_derive",
"serde_json",
"tokio",
]
[[package]]
name = "gstreamer"
version = "0.18.6"
@ -666,7 +737,7 @@ dependencies = [
[[package]]
name = "gstreamer"
version = "0.19.0"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#e6dc3f5b3ed70068fcb9f20d9b526226ed5ae701"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b7afdd4dd0b72d535cf20fc6199da4e111ddf6c9"
dependencies = [
"bitflags",
"cfg-if",
@ -733,7 +804,7 @@ dependencies = [
[[package]]
name = "gstreamer-base"
version = "0.19.0"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#e6dc3f5b3ed70068fcb9f20d9b526226ed5ae701"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b7afdd4dd0b72d535cf20fc6199da4e111ddf6c9"
dependencies = [
"bitflags",
"cfg-if",
@ -759,7 +830,7 @@ dependencies = [
[[package]]
name = "gstreamer-base-sys"
version = "0.19.0"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#e6dc3f5b3ed70068fcb9f20d9b526226ed5ae701"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b7afdd4dd0b72d535cf20fc6199da4e111ddf6c9"
dependencies = [
"glib-sys 0.16.0",
"gobject-sys 0.16.0",
@ -783,7 +854,7 @@ dependencies = [
[[package]]
name = "gstreamer-sys"
version = "0.19.0"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#e6dc3f5b3ed70068fcb9f20d9b526226ed5ae701"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b7afdd4dd0b72d535cf20fc6199da4e111ddf6c9"
dependencies = [
"glib-sys 0.16.0",
"gobject-sys 0.16.0",
@ -811,7 +882,7 @@ dependencies = [
[[package]]
name = "gstreamer-video"
version = "0.19.0"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#e6dc3f5b3ed70068fcb9f20d9b526226ed5ae701"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b7afdd4dd0b72d535cf20fc6199da4e111ddf6c9"
dependencies = [
"bitflags",
"cfg-if",
@ -841,7 +912,7 @@ dependencies = [
[[package]]
name = "gstreamer-video-sys"
version = "0.19.0"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#e6dc3f5b3ed70068fcb9f20d9b526226ed5ae701"
source = "git+https://gitlab.freedesktop.org/gstreamer/gstreamer-rs#b7afdd4dd0b72d535cf20fc6199da4e111ddf6c9"
dependencies = [
"glib-sys 0.16.0",
"gobject-sys 0.16.0",
@ -904,7 +975,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b"
dependencies = [
"crypto-mac",
"digest",
"digest 0.9.0",
]
[[package]]
@ -952,9 +1023,9 @@ dependencies = [
[[package]]
name = "hyper"
version = "0.14.17"
version = "0.14.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "043f0e083e9901b6cc658a77d1eb86f4fc650bbb977a4337dd63192826aa85dd"
checksum = "b26ae0a80afebe130861d90abf98e3814a4f28a4c6ffeb5ab8ebb2be311e0ef2"
dependencies = [
"bytes",
"futures-channel",
@ -1029,9 +1100,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "indexmap"
version = "1.8.0"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee"
dependencies = [
"autocfg",
"hashbrown",
@ -1060,9 +1131,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.120"
version = "0.2.121"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad5c14e80759d0939d013e6ca49930e59fc53dd8e5009132f76240c179380c09"
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
[[package]]
name = "log"
@ -1085,8 +1156,8 @@ version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15"
dependencies = [
"block-buffer",
"digest",
"block-buffer 0.9.0",
"digest 0.9.0",
"opaque-debug",
]
@ -1142,9 +1213,9 @@ checksum = "b5136edda114182728ccdedb9f5eda882781f35fa6e80cc360af12a8932507f3"
[[package]]
name = "native-tls"
version = "0.2.8"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d"
checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9"
dependencies = [
"lazy_static",
"libc",
@ -1287,7 +1358,7 @@ dependencies = [
[[package]]
name = "pango"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#bf334f3c7f69b47499e02d74bb33c7846c5d86e6"
source = "git+https://github.com/gtk-rs/gtk-rs-core#cece39f48486ed724668e431f242a9b1ab849147"
dependencies = [
"bitflags",
"glib 0.16.0",
@ -1299,7 +1370,7 @@ dependencies = [
[[package]]
name = "pango-sys"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#bf334f3c7f69b47499e02d74bb33c7846c5d86e6"
source = "git+https://github.com/gtk-rs/gtk-rs-core#cece39f48486ed724668e431f242a9b1ab849147"
dependencies = [
"glib-sys 0.16.0",
"gobject-sys 0.16.0",
@ -1310,7 +1381,7 @@ dependencies = [
[[package]]
name = "pangocairo"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#bf334f3c7f69b47499e02d74bb33c7846c5d86e6"
source = "git+https://github.com/gtk-rs/gtk-rs-core#cece39f48486ed724668e431f242a9b1ab849147"
dependencies = [
"bitflags",
"cairo-rs",
@ -1323,7 +1394,7 @@ dependencies = [
[[package]]
name = "pangocairo-sys"
version = "0.16.0"
source = "git+https://github.com/gtk-rs/gtk-rs-core#bf334f3c7f69b47499e02d74bb33c7846c5d86e6"
source = "git+https://github.com/gtk-rs/gtk-rs-core#cece39f48486ed724668e431f242a9b1ab849147"
dependencies = [
"cairo-sys-rs",
"glib-sys 0.16.0",
@ -1480,18 +1551,18 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.2.11"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c"
checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42"
dependencies = [
"bitflags",
]
[[package]]
name = "redox_users"
version = "0.4.2"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7776223e2696f1aa4c6b0170e83212f47296a00424305117d013dfe86fb0fe55"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
"getrandom",
"redox_syscall",
@ -1589,7 +1660,7 @@ dependencies = [
"base64",
"bytes",
"chrono",
"digest",
"digest 0.9.0",
"futures",
"hex",
"hmac",
@ -1656,9 +1727,9 @@ dependencies = [
[[package]]
name = "semver"
version = "1.0.6"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d"
checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4"
[[package]]
name = "serde"
@ -1697,23 +1768,34 @@ version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6"
dependencies = [
"block-buffer",
"block-buffer 0.9.0",
"cfg-if",
"cpufeatures",
"digest",
"digest 0.9.0",
"opaque-debug",
]
[[package]]
name = "sha-1"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f"
dependencies = [
"cfg-if",
"cpufeatures",
"digest 0.10.3",
]
[[package]]
name = "sha2"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800"
dependencies = [
"block-buffer",
"block-buffer 0.9.0",
"cfg-if",
"cpufeatures",
"digest",
"digest 0.9.0",
"opaque-debug",
]
@ -1989,7 +2071,27 @@ dependencies = [
"log",
"native-tls",
"rand",
"sha-1",
"sha-1 0.9.8",
"thiserror",
"url",
"utf-8",
]
[[package]]
name = "tungstenite"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d96a2dea40e7570482f28eb57afbe42d97551905da6a9400acc5c328d24004f5"
dependencies = [
"base64",
"byteorder",
"bytes",
"http",
"httparse",
"log",
"native-tls",
"rand",
"sha-1 0.10.0",
"thiserror",
"url",
"utf-8",
@ -2114,6 +2216,7 @@ dependencies = [
"gst-plugin-closedcaption",
"gst-plugin-rusoto",
"gst-plugin-textwrap",
"gst-plugin-vosk",
"gstreamer 0.18.6",
"gstreamer-app",
"gstreamer-base 0.18.0",

View file

@ -10,14 +10,11 @@ gst = { package = "gstreamer", version = "0.18.3" }
gstreamer-app = "0.18.0"
gstreamer-base = "0.18.0"
gstreamer-video = { version = "0.18.5", features = ["v1_16"] }
gst-plugin-rusoto = { git = "https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git", branch = "transbin-accept-any-video-caps", version = "0.9.0" }
gst-plugin-closedcaption = { git = "https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git", branch = "transbin-accept-any-video-caps", version = "0.9.0" }
gst-plugin-textwrap = { git = "https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git", branch = "transbin-accept-any-video-caps", version = "0.9.0" }
ctrlc = "3.2.1"
signal-hook = "0.3.13"
#tokio = { version = "1.17", features = ["full"] }
#axum = "0.4.5"
#tower = "0.4.12"
#tower-http = { version = "0.2.2", features = ["add-extension"] }
log = "0.4.14"
pretty_env_logger = "0.4.0"
gst-plugin-textwrap = { git = "https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git", branch = "transbin-accept-any-video-caps", version = "0.9.0" }
gst-plugin-rusoto = { git = "https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git", branch = "transbin-accept-any-video-caps", version = "0.9.0" }
gst-plugin-closedcaption = { git = "https://gitlab.freedesktop.org/rafaelcaricio/gst-plugins-rs.git", branch = "transbin-accept-any-video-caps", version = "0.9.0" }
gst-plugin-vosk = { path = "../../opensource/gst-plugin-vosk" }

View file

@ -3,80 +3,61 @@ use gstreamer_app as gst_app;
use log::{debug, error, info, trace, warn};
use std::process;
fn main() -> eyre::Result<()> {
pretty_env_logger::init();
pretty_env_logger::init_timed();
gst::init()?;
gstrstextwrap::plugin_register_static()?;
gstrusoto::plugin_register_static()?;
gstrsclosedcaption::plugin_register_static()?;
gstrstextwrap::plugin_register_static()?;
gstvosk::plugin_register_static()?;
// ristsrc name=rist_src address="0.0.0.0" ! rtpmp2tdepay name=rtmpdepay ! decodebin name=multiplexer
// uridecodebin name=demuxer uri=file:///Users/rafael.caricio/video.mkv
//
// demuxer. ! videorate ! video/x-raw,framerate=(fraction)30/1 ! ccextractor remove-caption-meta=true ! transcriberbin name=trans latency=30000
// demuxer. ! audio/x-raw ! audiorate ! audioconvert ! audioresample ! trans.sink_audio
let pipeline = gst::parse_launch(
r#"
souphttpsrc location="https://playertest.longtailvideo.com/adaptive/elephants_dream_v4/redundant.m3u8" ! hlsdemux name=demuxer
demuxer.src_0 ! decodebin ! cccombiner name=ccc_fr ! videoconvert ! x264enc ! video/x-h264,profile=main ! muxer.video_0
demuxer.src_1 ! decodebin ! audioconvert ! audioresample ! opusenc ! audio/x-opus,rate=48000,channels=2 ! muxer.audio_0
demuxer.src_2 ! decodebin ! audioconvert ! audioresample ! opusenc ! audio/x-opus,rate=48000,channels=2 ! muxer.audio_1
demuxer.src_3 ! decodebin ! audioconvert ! audioresample ! opusenc ! audio/x-opus,rate=48000,channels=2 ! muxer.audio_2
uridecodebin name=multiplexer uri=file:///Users/rafael.caricio/video.mkv
souphttpsrc location="https://playertest.longtailvideo.com/adaptive/elephants_dream_v4/media_b/french/ed.m3u8" ! hlsdemux ! subparse ! tttocea608 ! ccconverter ! closedcaption/x-cea-708,format=cc_data ! ccc_fr.caption
multiplexer. ! videorate ! video/x-raw,framerate=(fraction)30/1 ! ccextractor remove-caption-meta=true ! trans.sink_video
multiplexer. ! audio/x-raw ! audiorate ! audioconvert ! audioresample ! transcriberbin name=trans
trans.src_video ! cea608overlay black-background=1 ! autovideosink
trans.src_audio ! autoaudiosink
qtmux name=muxer ! filesink location=output_cae708_only_fr.mp4
"#,
)?
.downcast::<gst::Pipeline>()
.unwrap();
pipeline.set_async_handling(true);
// souphttpsrc location="https://playertest.longtailvideo.com/adaptive/elephants_dream_v4/media_b/chinese/ed.m3u8" ! hlsdemux ! subparse ! tttocea608 ! ccconverter ! closedcaption/x-cea-708,format=cc_data ! ccc_ch.caption
// souphttpsrc location="https://playertest.longtailvideo.com/adaptive/elephants_dream_v4/media_b/french/ed.m3u8" ! hlsdemux ! subparse ! tttocea608 ! appsink name=sink
info!("Starting pipeline...");
let demuxer = pipeline.by_name("demuxer").unwrap();
demuxer.connect_pad_added(|_, pad| {
let name = pad.name();
let caps = pad.caps().unwrap();
let caps_type = caps.structure(0).unwrap().name();
// dbg!(name);
debug!("Pad {} added with caps {}", name, caps_type);
});
// let app_sink = pipeline
// .by_name("sink")
// .unwrap()
// .downcast::<gst_app::AppSink>()
// .unwrap();
// app_sink.set_sync(false);
// app_sink.set_callbacks(
// gst_app::AppSinkCallbacks::builder()
// .new_sample(move |app| {
// let sample = app.pull_sample().unwrap();
// let buffer = sample.buffer().unwrap();
//
// // We don't care about buffers that are not video
// if buffer
// .flags()
// .contains(gst::BufferFlags::DECODE_ONLY | gst::BufferFlags::GAP)
// {
// return Ok(gst::FlowSuccess::Ok);
// }
//
// // let data = buffer.map_readable().unwrap();
// // let text = std::str::from_utf8(&data).unwrap();
// // println!("Subtext = {}", text);
// dbg!(buffer);
//
// Ok(gst::FlowSuccess::Ok)
// })
// .build(),
// );
// let demuxer = pipeline.by_name("demuxer").unwrap();
// demuxer.connect_pad_added(|_, pad| {
// let name = pad.name();
// let caps = pad.caps().unwrap();
// let caps_type = caps.structure(0).unwrap().name();
// info!("Pad {} added with caps {}", name, caps_type);
// });
let transcriber = gst::ElementFactory::make("gspeechtotext", None).expect("Could not instantiate Google transcriber");
transcriber.set_property("auth-json-file",
"/Users/rafael.caricio/development/live/google-cloud-playground/i-centralvideo-dictate-dev-c184dd68967a.json");
let transcriber_bin = pipeline.by_name("trans").expect("Trans bin");
transcriber_bin.set_property("transcriber", transcriber);
transcriber_bin.set_property("latency", 45_000_u32);
let context = glib::MainContext::default();
let main_loop = glib::MainLoop::new(Some(&context), false);
pipeline.set_state(gst::State::Playing)?;
let bus = pipeline.bus().unwrap();
bus.add_watch({
let main_loop = main_loop.clone();
@ -116,5 +97,27 @@ fn main() -> eyre::Result<()> {
pipeline.set_state(gst::State::Null)?;
// let mut out_wav_buffer = Cursor::new(Vec::new());
// let mut writer = WavWriter::new(
// &mut out_wav_buffer,
// WavSpec {
// channels: 1,
// sample_rate: 48000,
// bits_per_sample: 16,
// sample_format: hound::SampleFormat::Int,
// },
// )
// .unwrap();
//
// let mut raw_audio_content = Cursor::new(raw_audio_content.lock().unwrap().to_vec());
//
// while let Ok(sample) = raw_audio_content.read_i16::<LittleEndian>() {
// writer.write_sample(sample).unwrap();
// }
//
// drop(writer);
// let mut file = File::create("out.raw")?;
// file.write_all(&raw_audio_content.into_inner())?;
Ok(())
}