One input and More output use 'tee'

2023-05-16

2008-05-22
In preparation for my Luma media player, I wanted to create a simple audio player with visualization. Based upon what I have read, this would require a "tee" when using gstreamer. The tee in gstreamers is much like a tee in piped shell commands; data gets copied at the tee and travels in multiple directions. In gstreamer, one needs to create a queue for each new direction that the data will flow down in the pipeline.

It took me a while to wrangle with the tee requirements for handling queues. I could see how, but I couldn't understand why. So anyway, this is what I came up with:
1. a tee in the pipeline gets a name
2. the end of a queue gets declared as part of the tee, and is given the name of the tee followed by a period
3. add a queue to the gstreamer pipeline
4. the end of the queue thingy gets placed at the end of the queues ( this doesn't seem to be required for the last queue)

My gstreamer pipeline looks like this:
#!/bin/sh
gst-launch
filesrc location=/path/to/audio/file
! decodebin ! audioconvert
! tee name=myT myT.
! queue ! autoaudiosink myT.
! queue ! goom ! ffmpegcolorspace ! autovideosink


sweet! Now on to a my pythonic version using pygst

#!/usr/bin/env python

import sys
import gst
import time
class myPlayer ():
    def __init__(self):
        self.pipeline = gst.Pipeline()
        self.src = gst.element_factory_make("filesrc", "src")
        self.decoder = gst.element_factory_make("decodebin", "decoder")
        self.decoder.connect("new-decoded-pad", self.onNewDecodedPad)
        self.goom = gst.element_factory_make("goom")
        self.colorspace = gst.element_factory_make("ffmpegcolorspace","color")
        self.conv = gst.element_factory_make("audioconvert", "conv")
        self.vidsink = gst.element_factory_make("autovideosink","videosink")
        self.asink = gst.element_factory_make("autoaudiosink", "aoutput")
        self.tee = gst.element_factory_make('tee', "tee")
        self.queuea = gst.element_factory_make("queue", "queuea")
        self.queuev = gst.element_factory_make("queue", "queuev")
        self.pipeline.add(self.src,self.decoder,self.conv,self.tee,self.queuea)
        self.pipeline.add(self.asink,self.queuev,self.goom, self.colorspace, self.vidsink)
        gst.element_link_many(self.src,self.decoder)
        gst.element_link_many(self.conv,self.tee)
        self.tee.link(self.queuea)
        self.queuea.link(self.asink)
        self.tee.link(self.queuev)
        gst.element_link_many(self.queuev, self.goom,self.colorspace, self.vidsink)
    def onNewDecodedPad(self,decodebin, pad, islast):
        #link the pad to the converter
        decodebin.link(self.conv)
        
    def playfile(self,file):
        self.src.set_property('location', file)
        self.pipeline.set_state(gst.STATE_PLAYING)
        pipelinestate = self.pipeline.get_state()
        
        while pipelinestate[1] == gst.STATE_PLAYING:
            time.sleep(1)
            pipelinestate = self.pipeline.get_state()
        sys.exit()

if __name__ == '__main__':
    if (len(sys.argv) > 1):
        file = sys.argv[1]
        player = myPlayer()
        player.playfile(file)
    else:
        print "you must select a tune"
   

The big difference here, at least to me, is that the decodebin isn't really a bin, but it represents a series of possible bins. So if one where to select a vorbis file to play, the decodebin will determine the correct type of bin needed to handle the file and would create an instance of that type of bin, the same is true for wav,flac,aac,mp3, etc; all of which have a specific decoder that I don't want to have to figure out, so I let the decodebin do it for me. This line: self.decoder.connect("new-decoded-pad", self.onNewDecodedPad), will call a function whenever a new bin is created by the decoder bin and it is in the onNewDecodedPad function that the decodebin links to the rest of the pipeline. Does that make sense?
Comments
Chaz6:
Thanks for the example. There is one minor typo...

"self.popeline.add" should be "self.pipeline.add"
jezra:
Thanks for the catch! The code has been updated.
tom:
Thanks for the great example - I spent an hour trying to fit a pipeline for goom... You saved me :-)
Now this works on my...drumroll...Nokia N900! Maemo forever :-)
jezra:
That is awesome Tom! I've always wanted to how well gstreamer runs on ARM based systems.

转载于:https://blog.51cto.com/general/313484

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

One input and More output use 'tee' 的相关文章

随机推荐

  • 如何在Debian Linux上安装配置ISC DHCP服务器

    动态主机控制协议 DHCP 给网络管理员提供了一种便捷的方式 xff0c 为不断变化的网络主机或是动态网络提供网络层地址 xff0c 其中最常用的 DHCP 服务工具是 ISC DHCP Server DHCP 服务的目的是给主机提供必要的
  • SQL学习笔记1

    以下内容是我在学习SQL xff08 http www w3school com cn sql index asp xff09 的时候的学习笔记 学习时使用的数据库软件是MySQL 数据库可视化工具 SQLyogEnt 如果大家有发现什么不
  • BAT-使用BAT方法结束进程(删除进程)

    64 echo off taskkill f im GAM exe taskkill f im GCL10 exe
  • 解决访问apache中文乱码的问题

    解决访问 apache 中文乱码的问题 修改 apache 的配置文件 Vi etc httpd conf httpd conf 在 AddDefaultCharset UTF 8 下面添加 AddDefaultCharset UTF 8
  • linux远程灰屏,Ubuntu 15.10安装VNC灰屏问题解决

    1 在Ubuntu上首先需要安装vnc4server apt get install vnc4server 2 第一次执行vncserver的时候需要为客户端连接设置8位的密码 3 打开服务后 xff0c 根据客户端号连接 也可以指定客户端
  • Android IOS WebRTC 音视频开发总结(十五)-- 培训课程大纲

    Android IOS WebRTC 音视频开发总结 xff08 十五 xff09 培训课程大纲 最近在给公司做内部培训 xff0c 主要是关于即时通讯和移动视频通话 xff0c 包括android与android xff0c ios与io
  • Docker 1.12 : 使用 Swarm 的新姿势

    本文首发于我的博客 原文链接 xff1a Docker 1 12 新特性 Docker1 12 版本做出了很大的改动 xff0c 特别是增加了对 swarm 的原生支持 xff0c 下面对新版的使用做一个总结 xff0c 供大家查阅 doc
  • 用CSS写一个简单的幻灯片效果页面

    这里是修真院前端小课堂 xff0c 每篇分享文从 背景介绍 知识剖析 常见问题 解决方案 编码实战 扩展思考 更多讨论 参考文献 八个方面深度解析前端知识 技能 xff0c 本篇分享的是 xff1a 用CSS写一个简单的幻灯片效果页面 1
  • Go程序Windows运行时不显示cmd窗口

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 非常简单 xff0c 编译时候加参数 go build ldflags 61 34 H windowsgui 34 转载于 https my oschina net pok
  • Python3 创建虚拟环境

    目的 使用虚拟环境是为了隔离不同项目之间的Python库 创建虚拟环境 Python3 内置了venv模块 xff0c 首先创建项目目录 xff0c 进入目录后 xff0c 执行 python3 m venv venv 激活虚拟环境 在开始
  • Ubuntu18.04LTS 文件系统简记

    Ubuntu18 04LTS 文件系统 了解Linux文件系统是熟悉掌握使用Linux系统的第一步 首先安装名为tree的工具 sudo apt install tree 运行 tree help 查看tree命令的详细用法 运行 tree
  • windows下nvm安装node之后npm命令找不到问题解决办法

    主要关键解解决办法 xff1a 61 61 61 适 用于所有东西的安装 安装有关环境配置类的软件及其他 xff0c 一般情况下切记不要安装到c盘programfiles下 xff0c 否则会出现各种问题的报错 xff01 xff01 xf
  • [问题2014S14] 复旦高等代数II(13级)每周一题(第十四教学周)

    问题2014S14 设 V 为酉空间 证明 不存在 V 上的非零线性变换 varphi 使得对 V 中任一向量 v 均有 varphi v v 61 0 注 本题是复旦高代教材 P326 习题 9 1 5 的推广
  • 8B10B编解码及FPGA实现

    概述 在使用ALTERA的高速串行接口时 xff0c GXB模块里硬件实现了8B10B编码 xff0c 用户只是 傻瓜 式的使用 xff0c 笔者也一直没有弄清楚 网上搜索了一些学习资料 xff0c 结合参考文献希望能够对其进行消化 另外
  • 零碎记录- spring security oauth2 资源服务器中设置放行路径

    在资源服务器配置类中重写configure方法 xff0c 添加放行信息 使用了 64 EnableResouceServer xff0c 且继承了ResourceServerConfigurerAdapter的类作为资源服务器配置信息类
  • Golang 新手可能会踩的 50 个坑

    译文 xff1a Golang 新手可能会踩的 50 个坑 原文 xff1a 50 Shades of Go Traps Gotchas and Common Mistakes 翻译已获作者授权 xff0c 转载请注明来源 不久前发现在知乎
  • 手把手教你使用TF服务将TensorFlow模型部署到生产环境 ...

    介 绍 将机器学习 xff08 ML xff09 模型应用于生产环境已成为一个火热的的话题 许多框架提供了旨在解决此问题的不同解决方案 为解决这一问题 xff0c 谷歌发布了TensorFlow xff08 TF xff09 服务 xff0
  • Centos/Linux下如何查看网关地址/Gateway地址

    Centos Linux下如何查看网关地址 Gateway地址 xff1f Linux下查看网关的命令还是很多的 xff0c 不过如果IP是DHCP获取 xff0c 那么有些命令是不适用的 xff0c 当然也有通用的查询网关命令 1 ifc
  • 教你Java生成文件时怎么设置编码格式

    OutputStreamWriter允许用户指定编码方式 xff0c 代码为 xff1a FileInputStream fis 61 new FileInputStream 34 文件路径 34 xff1b OutputStreamWri
  • One input and More output use 'tee'

    2008 05 22 In preparation for my Luma media player I wanted to create a simple audio player with visualization Based upo