系统: fedora18
硬件平台: Intel Baytrail
Gstreamer: 1.0
一. 安装好Gstreamer的相关插件
yum install gstreamer-devel gstreamer-plugins-base-devel gstreamer-plugins-base-tools gstreamer-plugins-espeak gstreamer-plugins-base
gstreamer-python gstreamer-rtsp gstreamer-plugins-bad-free-devel gstreamer-tools gstreamer-plugins-bad-free gstreamer-plugins-good gstreamer-plugins-ugly
二. 播放视频文件
以MP4格式为例,其它格式可以 通过gst-inspect-1.0 | grep 查找对应的demux,decode,sink等插件,当然也可以使用auto开头的插件,或者playbin会自动选择播放,只是没有自己指定那么灵活,方便调试和验证一些功能。
- 硬解(vaapi)播放MP4文件:
gst-launch-1.0 filesrc location=FilePath/test.mp4 ! qtdemux ! vaapidecode ! vaapisink
2. 软解,只要将解码器vaapidecode换成avdec_h264,播放器vaapisink换成 ximagesink即可
三. 播放RTSP视频流
1. 硬解。
gst-launch-1.0 rtspsrc location=rtsp://username:passwd@ipaddr:port latency=0 ! rtph264depay ! capsfilter caps="video/x-h264" ! h264parse ! vaapidecode ! vaapipostproc width=800 height=600 ! vaapisink sync=false
2. 软解。
gst-launch-1.0 rtspsrc location=rtsp://username:passwd@ipaddr:port latency=0 ! rtph264depay ! capsfilter caps="video/x-h264" ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! video/x-raw,width=800,height=600 ! ximagesink
四. 播放Udp视频流
Udp播放需要根据发送端数据源封装格式来决定采用哪些Gstreamer插件,如果进行了RTP封装,则需要先用rtph264depay进行解包,如果包含自定义帧头的情况,应该编程对帧头进行处理,不然会显示异常,比如部分花屏现象,以下是对裸流进行播放。
1. 硬解
gst-launch-1.0 udpsrc port=2101 ! h264parse ! vaapidecode ! vaapisink
2. 软解
gst-launch-1.0 udpsrc port=2101 ! h264parse ! avdec_h264 ! autovideosink