meego上gstreamer的使用

本文介绍了如何在Meego系统中使用Gstreamer进行多媒体处理,包括播放mp3、wav文件,以及实现h.264编码的RTP传输。同时提供了客户端和服务器端的脚本示例,展示如何通过RTP进行远程视频流的发送和接收。
摘要由CSDN通过智能技术生成

转载时请注明出处和作者联系方式
文章出处:http://blog.csdn.net/jack0106
作者联系方式:冯牮 fengjian0106@yahoo.com.cn


     最近拿到了新版本的meego镜像,安装了fluendo-codecs-0.1-1.i586.rpm,终于可以在meego上调试一些gstreamer的东西了,简单记录了一下。

 

前提,我是用ssh远程连接到开发板上调试的,需要先在ssh终端下设置一下DISPLAY=:0.0环境变量,另外,还需要先杀掉进程mdecorator,这样,视频才能正常显示。


1 播放mp3文件,命令如下:

gst-launch filesrc location=test.mp3 ! flump3dec ! pulsesink


2 播放wav文件,命令如下(不知道该用哪个解码器,先使用decodebin):

gst-launch filesrc location=uptowngirl.wav ! decodebin ! pulsesink


3 h.264解码+rtp传输,PC做为服务器端,采集视频,通过rtp发送,CDK做为client,接受rtp视频,解码并显示,脚本如下:

client端--

#!/bin/sh
# the destination machine to send RTCP to. This is the address of the sender and
# is used to send back the RTCP reports of this receiver. If the data is sent
# from another machine, change this address.
DEST=191.8.1.157

# this adjusts the latency in the receiver
LATENCY=200

# the caps of the sender RTP stream. This is usually negotiated out of band with
# SDP or RTSP. normally these caps will also include SPS and PPS but we don't
# have a mechanism to get this from the sender with a -launch line.
VIDEO_CAPS="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264"
AUDIO_CAPS="application/x-rtp,media=(string)audio,clock-rate=(int)8000,encoding-name=(string)PCMA"

gst-launch-0.10 -v gstrtpbin name=rtpbin latency=$LATENCY /
udpsrc caps=$VIDEO_CAPS port=5000 ! rtpbin.recv_rtp_sink_0 /
rtpbin. ! rtph264depay ! fluh264dec ! xvimagesink /
udpsrc port=5001 ! rtpbin.recv_rtcp_sink_0 /
rtpbin.send_rtcp_src_0 ! udpsink port=5005 host=$DEST sync=false async=false /
/
udpsrc caps=$AUDIO_CAPS port=5002 ! rtpbin.recv_rtp_sink_1 /
rtpbin. ! rtppcmadepay ! alawdec ! audioconvert ! audioresample ! autoaudiosink /
udpsrc port=5003 ! rtpbin.recv_rtcp_sink_1 /
rtpbin.send_rtcp_src_1 ! udpsink port=5007 host=$DEST sync=false async=false

server端--

#!/bin/sh
# change this to send the RTP data and RTCP to another host
#DEST=127.0.0.1
DEST=191.8.1.237

# tuning parameters to make the sender send the streams out of sync. Can be used
# ot test the client RTCP synchronisation.
#VOFFSET=900000000
VOFFSET=0
AOFFSET=0

# H264 encode from the source
VELEM="v4l2src"
#VELEM="videotestsrc is-live=1"
VCAPS="video/x-raw-yuv,width=640,height=480,framerate=15/1"

VSOURCE="$VELEM ! $VCAPS ! queue ! videorate ! ffmpegcolorspace"

VENC="x264enc byte-stream=true bitrate=300 ! rtph264pay"

VRTPSINK="udpsink port=5000 host=$DEST ts-offset=$VOFFSET name=vrtpsink"
VRTCPSINK="udpsink port=5001 host=$DEST sync=false async=false name=vrtcpsink"
VRTCPSRC="udpsrc port=5005 name=vrtpsrc"



# PCMA encode from the source
AELEM="autoaudiosrc"
#AELEM="audiotestsrc is-live=1"
ASOURCE="$AELEM ! queue ! audioresample ! audioconvert"
AENC="alawenc ! rtppcmapay"

ARTPSINK="udpsink port=5002 host=$DEST ts-offset=$AOFFSET name=artpsink"
ARTCPSINK="udpsink port=5003 host=$DEST sync=false async=false name=artcpsink"
ARTCPSRC="udpsrc port=5007 name=artpsrc"

gst-launch-0.10 -v gstrtpbin name=rtpbin /
$VSOURCE ! $VENC ! rtpbin.send_rtp_sink_0 /
rtpbin.send_rtp_src_0 ! $VRTPSINK /
rtpbin.send_rtcp_src_0 ! $VRTCPSINK /
$VRTCPSRC ! rtpbin.recv_rtcp_sink_0 /
/
$ASOURCE ! $AENC ! rtpbin.send_rtp_sink_1 /
rtpbin.send_rtp_src_1 ! $ARTPSINK /
rtpbin.send_rtcp_src_1 ! $ARTCPSINK /
$ARTCPSRC ! rtpbin.recv_rtcp_sink_1


4 播放ogv文件

gst-launch filesrc location=big-buck-bunny.ogv ! decodebin2 name=jack jack. ! xvimagesink jack. ! pulsesink

或gst-launch playbin uri=file:///home/meego/Videos/big-buck-bunny.ogv

或gst-launch filesrc location=big-buck-bunny.ogv ! oggdemux name=demux demux. ! queue ! decodebin ! xvimagesink demux. ! queue ! decodebin ! pulsesink


5 播放mp4

gst-launch filesrc location=trailer-bigbuckbunny-wg.mp4 ! avidemux name=demux demux.audio_00 ! queue ! decodebin ! pulsesink demux.video_00 ! queue ! decodebin ! xvimagesink

或gst-launch filesrc location=trailer-bigbuckbunny-wg.mp4 ! avidemux name=demux demux.audio_00 ! queue ! decodebin2 ! audioconvert ! audioresample ! pulsesink demux.video_00 ! queue ! flumpeg4vdec ! xvimagesink

或gst-launch filesrc location=trailer-bigbuckbunny-wg.mp4 ! avidemux name=demux demux.audio_00 ! queue ! flump3dec ! audioconvert ! audioresample ! pulsesink demux.video_00 ! queue ! flumpeg4vdec ! xvimagesink


另一个mp4文件

gst-launch filesrc location=yuebin.mp4 ! qtdemux name=demux demux.audio_00 ! queue ! decodebin ! pulsesink demux.video_00 ! queue ! decodebin ! xvimagesink


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值