gstreamer的gst-inspect 和gst-launch


用gstreamer架構做對媒體開發時,gst-inspect 和gst-launch是兩個非常使用的小工具,前者是用於查詢庫中已經包含的所有element以及他們的詳細信息,后者用於快速構建一條pipeline,這個命令最爽,因為只要一句話,你就可以感受到播放的快感。廢話不多說,直接看示例:

1 gst-inspect用法:

首先進入命令行下,然后鍵入:

gst-inspect, 所有element都顯示;

gst-inspect >d:/c.txt 將所有element都導出到d盤根目錄下的c。txt文件中,這個命令在你想要查找某個element但有不確定其全名時很有用

gst-inspect ffmpeg >d/c.txt 同上,只是導出的element范圍縮小到ffmpeg范圍內

gst-inspect ffdec_h264 . 顯示ffdec-h264的詳細信息,你可以輸入想要查詢的任何element,只要已經存在,就可以找到

2 gst-launch 構建鏈路用法:

最開始要構建鏈路,當然用playbin、playbin2,decodebin, decodebin2,uridecodebin這類上層的element是最簡單省事的了。

比如,你想播放一個flv文件,位於d:/test_videos/1.flv,首先進入命令行下,然后鍵入:

gst-launch filesrc location=d:/test_videos/1.flv !decodebin !autovideosink         利用了filesrc decodebin 和autovideosink 3個element,其中設置了filesrc的location屬性值為文件路徑
gst-launch filesrc location=d:/test_videos/1.flv !decodebin2 !autovideosink       同上,只是decodebin用較新的decodebin2代替了

gst-launch uridecodebin uri=file:///d:/test_videos/1.flv !autovideosink        用uridecodebin 和autovideosink 2個element, 其中uridecodebin的屬性uri設置了

gst-launch playbin uri=file:///d:test_video/1.flv               利用playbin一個element,設置了其屬性uri 為file:///加文件路徑
gst-launch playbin2 uri=file:///d:test_video/1.flv             同上,只是用較新的playbin2代替了playbin

如果想要自己用基本element而不用上層bin element 進行鏈路構建,那需要以下步驟。

比如, 你想播放一個flv文件,位於d:/test_videos/0.flv

首先你需要確定需要什么樣的解碼element來構建,所以,你首先需要確定該文件編碼格式是什么,假如為h264

然后,在命令行下鍵入:

gst-launch filesrc location=d:/test_videos/0.flv !flvdemux !ffdec_h264 !autovideosink

其中,flvdemux用來分離多路數據的, ffdec-h264用來解碼,最后由autovideosink播放

如果你想播放其他文件,只需要根據相應文件容器格式指定特定的demux,再根據編碼格式指定特定的解碼器便可以了,如果不清楚改用哪個element,最好的方法當然用是gst-inspect去查找和驗證了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM