尝试在Gstreamer中同时播放多个视频文件

时间:2011-09-15 06:01:38

标签: video gstreamer

我正在尝试为gstreamer发出命令,以便它可以同时播放多个视频文件。所以我做了一些研究,发现了这个

gst-launch -e videomixer name=mix ! ffmpegcolorspace ! xvimagesink \
    videotestsrc pattern=1 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! \
    videobox border-alpha=0 top=0 left=0 ! mix. \
    videotestsrc pattern=15 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! \
    videobox border-alpha=0 top=0 left=-320 ! mix. \
    videotestsrc pattern=13 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! \
    videobox border-alpha=0 top=-180 left=0 ! mix. \
    videotestsrc pattern=0 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! \
    videobox border-alpha=0 top=-180 left=-320 ! mix. \
    videotestsrc pattern=3 ! video/x-raw-yuv, framerate=5/1, width=640, height=360 ! mix.

这是输出图像= http://i.stack.imgur.com/4lZWL.png

这是我修改过的代码,假设是这样的

http://i.stack.imgur.com/Mdsc0.png

time gst-launch -e videomixer name=mix ! ffmpegcolorspace ! xvimagesink \
    filesrc location=./Cityscape1Min_720p_mp4.mp4 ! video/x-raw-yuv, framerate=5/1, \
        width=320, height=180 ! videobox border-alpha=0 top=0 left=0 ! mix. \
    filesrc location=./Cityscape1Min_720p_mp4.mp4 ! video/x-raw-yuv, framerate=5/1, \
        width=320, height=180 ! videobox border-alpha=0 top=0 left=-320 ! mix. \
    filesrc location=./Cityscape1Min_720p_mp4.mp4 ! video/x-raw-yuv, framerate=5/1, \
        width=320, height=180 ! videobox border-alpha=0 top=-180 left=0 ! mix. \
    filesrc location=./Cityscape1Min_720p_mp4.mp4 ! video/x-raw-yuv, framerate=5/1, \
        width=320, height=180 ! videobox border-alpha=0 top=-180 left=-320 ! mix. 

但它不起作用。有没有其他解决方案?

2 个答案:

答案 0 :(得分:4)

我喜欢这种方法,它会创建一个2x2的矩阵。 sink_0是你的背景,你也可以将它设置为图像。有关picture in picture的更多信息。

gst-launch -e \
videomixer name=mix \
        sink_0::xpos=0   sink_0::ypos=0  sink_0::alpha=0\
        sink_1::xpos=0   sink_1::ypos=0 \
        sink_2::xpos=200 sink_2::ypos=0 \
        sink_3::xpos=0   sink_3::ypos=100 \
        sink_4::xpos=200 sink_4::ypos=100 \
    ! xvimagesink \
videotestsrc pattern="black" \
    ! video/x-raw-yuv,width=400,height=200 \
    ! mix.sink_0 \
uridecodebin uri='file:///home/user/video/test1.mp4' \
    ! ffmpegcolorspace ! videoscale \
    ! video/x-raw-yuv,width=200,height=100 \
    ! mix.sink_1 \
uridecodebin uri='file:///home/user/video/test2.mp4' \
    ! ffmpegcolorspace ! videoscale \
    ! video/x-raw-yuv,width=200,height=100 \
    ! mix.sink_2 \
uridecodebin uri='file:///home/user/video/test.avi' \
    ! ffmpegcolorspace ! videoscale \
    ! video/x-raw-yuv,width=200,height=100 \
    ! mix.sink_3 \
uridecodebin uri='mms://server/video/test.wmv' \
    ! ffmpegcolorspace ! videoscale \
    ! video/x-raw-yuv,width=200,height=100 \
    ! mix.sink_4 \

答案 1 :(得分:0)

从您的所有实际视频中移除framerate=5/1。对我来说,只有videotestsrc可以使用framerate封面过滤器进行修改。

gst-launch-0.10 -e videomixer name=mix ! ffmpegcolorspace ! xvimagesink \
    uridecodebin uri=file:///home/user/Desktop/sintel_trailer-480p.webm ! \
            ffmpegcolorspace ! videoscale ! \
            video/x-raw-yuv, width=320, height=180 ! \
            videobox border-alpha=0 top=0 left=0 ! mix. \
    videotestsrc pattern=15 ! \
            video/x-raw-yuv, width=320, height=180 ! \
            videobox border-alpha=0 top=0 left=-320 ! mix. \
    videotestsrc pattern=13 ! \
            video/x-raw-yuv, width=320, height=180 ! \
            videobox border-alpha=0 top=-180 left=0 ! mix. \
    videotestsrc pattern=0 ! \
            video/x-raw-yuv, width=320, height=180 ! \
            videobox border-alpha=0 top=-180 left=-320 ! mix. \
    videotestsrc pattern=3 ! \
            video/x-raw-yuv, framerate=5/1, width=640, height=360 ! mix.