zoukankan      html  css  js  c++  java
  • GStreamer 命令演示,音频视频播放及混流的演示 -- TerryHe

    GStreamer 是一个用于处理音视频的开源开发包,其中提供了很方便的命令行模式,可以使用命令快速测试音视频处理的效果,然后再用代码进行实现。

    GStreamer 基础知识的介绍可以参考这个文档:https://www.ibm.com/developerworks/cn/linux/l-gstreamer/

    GStreamer 的安装也很简单,在这里下载安装包 https://gstreamer.freedesktop.org/download/ 然后将安装目录下的 bin 文件夹设置到 PATH 环境变量中就可以了,如 D:gstreamer1.0x86_64in

    下面是一些音视频命令的处理范例,可以直接复制到命令行中运行。在 bash 命令行中可以直接运行,如果使用 windows cmd,需要把 和 回车 去除后运行

    注意感叹号后面必须要有一个空格,否则执行会报错

    播放当前目录下的音频或视频

    gst-launch-1.0 filesrc location=abc.mp3 ! decodebin ! audioconvert ! audioresample ! autoaudiosink
    gst-launch-1.0 filesrc location=111.mp4 ! decodebin ! autovideosink

    产生一个测试视频画面

    gst-launch-1.0 -v videotestsrc pattern=ball name=left ! autovideosink

    混流两个测试画面

    gst-launch-1.0 -v videotestsrc ! video/x-raw,format=AYUV,framerate=(fraction)5/1,width=320,height=240 ! 
    videomixer name=mix background=1 sink_0::alpha=1 sink_1::alpha=1 !
    videoconvert ! glimagesink
    videotestsrc pattern=1 !
    video/x-raw,format=AYUV,framerate=(fraction)10/1,width=100,height=100 !
    videobox border-alpha=0 top=-70 bottom=-70 right=-220 ! mix.

    分离一个 MP4 的视频和音频并分别播放

    gst-launch-1.0 filesrc location=a.mp4 ! qtdemux name=demux  demux.audio_0 ! queue ! decodebin ! audioconvert ! audioresample ! autoaudiosink 
    demux.video_0 ! queue ! decodebin ! videoconvert ! videoscale ! autovideosink

    只分离视频并播放

    gst-launch-1.0 filesrc location=a.mp4 ! qtdemux name=demux demux.video_0 ! queue ! decodebin ! videoconvert ! videoscale ! autovideosink

    只分离视频并设置 video 大小 和 videobox

    gst-launch-1.0 filesrc location=a.mp4 ! qtdemux name=demux demux.video_0 ! decodebin ! videoscale ! 
    video/x-raw,width=100,height=100 !
    videobox border-alpha=0 top=-70 bottom=-70 right=-220 !
    videoconvert ! autovideosink

    混流两个视频文件,一左一右

    gst-launch-1.0 filesrc location=a.mp4 ! qtdemux name=demux demux.video_0 ! queue ! decodebin ! videoscale ! videoconvert ! 
    video/x-raw,format=AYUV,width=200,height=200 !
    videobox border-alpha=0 top=-70 bottom=-70 right=-220 !
    videomixer name=mix background=1 sink_0::alpha=1 sink_1::alpha=1 !
    autovideosink
    filesrc location=b.mp4 ! qtdemux name=demux2 demux2.video_0 ! queue ! decodebin ! videoscale ! videoconvert !
    video/x-raw,format=AYUV,width=200,height=200 !
    videobox border-alpha=0 top=-70 bottom=-70 left=-220 ! mix.

    混流两个视频并播放声音

    gst-launch-1.0 filesrc location=a.mp4 ! qtdemux name=demux demux.video_0 ! queue ! decodebin ! videoscale ! videoconvert ! 
    video/x-raw,format=AYUV,width=200,height=200 !
    videobox border-alpha=0 top=-70 bottom=-70 right=-220 !
    videomixer name=mix background=1 sink_0::alpha=1 sink_1::alpha=1 !
    autovideosink
    filesrc location=b.mp4 ! qtdemux name=demux2 demux2.video_0 ! queue ! decodebin ! videoscale ! videoconvert !
    video/x-raw,format=AYUV,width=200,height=200 !
    videobox border-alpha=0 top=-70 bottom=-70 left=-220 ! mix.
    demux.audio_0 ! queue ! decodebin ! audioconvert ! audioresample ! autoaudiosink
    demux2.audio_0 ! queue ! decodebin ! audioconvert ! audioresample ! autoaudiosink
  • 相关阅读:
    linux性能调优总结
    mongodb之sharding原理
    Centos6.6搭建mongodb3.2.6副本集分片
    vmstat 命令详解
    SaltStack之Targeting
    saltstack之pillar详解
    saltstack之grains详解
    saltstack之yum简单部署lnmp
    Redis监控工具
    PHP实现选择排序
  • 原文地址:https://www.cnblogs.com/luckbird/p/GStreamer_Demo.html
Copyright © 2011-2022 走看看