环境:
1.0:
dnf install gstreamer1-plugins-base
dnf install gstreamer1-plugins-bad-free
dnf install gstreamer1-plugins-ugly
dnf install gstreamer1-plugins-good
dnf install gstreamer1
dnf install gstreamer1-libav(1.0以后版本用这个avdec_,0.1的版本用gst-ffmpeg(ffdec_),都是解码的组件)
装libav需要装两个源不然会找不到,下载下来,rpm -ivh *.rpm装一下就可以dnf install gstreamer1-libav了
0.1:
在版本换成0.1即可
硬解
如果要用intel_gpu硬解码需要安装
libva-intel-driver
gstreamer1-vaapi
intel_gpu_tools
观察是否用硬解的方法
top -H | grep vaapi 观察是否有vaapi-queue:src有的话说明已经用了硬解
或者
intel_gpu_top观察bitstream busy和blitter busy是否有白条在动都能判断是否用了硬解
有一个vainfo的工具,能查看是否有vaapi,需要安装
libva-utils(装好后直接输入vainfo就好了)
gst-launch用法
gst-launch-1.0 playbin uri=file:///root/video.mp4(依赖满足情况下硬解优先级最高)
gst-launch-1.0 filesrc location=/root/video.mp4 ! decodebin ! xvimagesink(依赖满足情况下硬解优先级最高)
gst-launch-1.0 filesrc location=/root/video.mp4 ! qtdemux ! vaapidecodebin ! vaapisink (依赖不满足会报错,满足的话硬解)
总的来说需要一个输入src一个输出sink
decodebin vaapidecodebin都是自动寻找合适的解码器,还有其他更多的插件可供选用。
https://www.cnblogs.com/luckbird/p/GStreamer_Demo.html //各种命令行例子
GStreamer下的音视频播放_yymcool的博客-优快云博客 // GStreamer下的音视频播放
qtdemux //qtdemux貌似只能解复用mov格式
gst-launch-1.0 filesrc location=test.mov ! qtdemux name=demux demux.audio_0 ! queue ! decodebin ! audioconvert ! audioresample ! autoaudiosink demux.video_0 ! queue ! decodebin ! videoconvert ! videoscale ! autovideosink
matroskademux //解复用mkv
gst-launch-1.0 -v filesrc location=/path/to/mkv ! matroskademux ! vorbisdec ! audioconvert ! audioresample ! autoaudiosink
实例:(可以将音视频分开播放)
gst-launch-1.0 filesrc location=test.mkv ! matroskademux name=demux demux.audio_0 ! queue ! decodebin ! audioconvert ! audioresample ! autoaudiosink demux.video_0 ! queue ! decodebin ! videoconvert ! videoscale ! autovideosink
解码带有dts的音视频并播放:
gst-launch-0.1 filesrc location=/root/test.dts ! dcaparse ! ffdec_dca ! autoaudiosink 正常播放音频
gst-launch-1.0 filesrc location=/root/test.dts ! dcaparse ! avdec_dca ! autoaudiosink 正常播放音频
gst-launch-1.0 playbin uri=file:///root/test.mkv 正常播放音视频
gst-launch-0.1 playbin uri=file:///root/test.mkv //这个他找不到用什么来播放声音所以只有视频没有音频(应该用上面的dcaparse ! ffdec_dca解码dts音频)
gst-inspect用法
若不是很清楚组件的全名是什么可以使用gst-inspect-1.0 | grep 你知道的部分名字 来查询当下插件中有没有叫这个名字的组件
若知道名字如:gst-launch-1.0 decodebin 可以查询这个组件的详细信息