2015-02-23 110 views
1

我正在開發一個項目,我需要根據顏色顯示一個基於顏色的感興趣區域的「alpha keying」視頻,然後在圖像上運行它通過視頻可以看到感興趣區域下的圖像。通過圖像覆蓋(或播放)視頻作爲背景 - 使用gstreamer

$ gst-launch-0.10 -e \ 
    videomixer name=mix\ 
    ! ffmpegcolorspace \ 
    ! xvimagesink \ 
    videotestsrc pattern=0 \ 
    ! video/x-raw-yuv, framerate=1/1, width=350, height=250 \ 
    ! textoverlay font-desc="Sans 24" text="CAM1" valign=top halign=left shaded-background=true \ 
    ! videobox border-alpha=0 top=-200 left=-50 \ 
    ! mix. 
    multifilesrc location="drawing_total_mask_1.jpg" caps="image/jpeg,framerate=1/1" 
    ! jpegdec \ 
    ! textoverlay font-desc="Sans 26" text="Live from Pl" halign=left shaded-background=true auto-resize=false \ 
    ! ffmpegcolorspace \ 
    ! video/x-raw-yuv,format=\(fourcc\)AYUV \ 
    ! mix. 

搜索它,我發現這樣的事情,讓我顯示在圖像上測試視頻(videotestsrc),但是當我給一個備用視頻源,它不會做。

我用來給我自己的源代碼和錯誤所遵循的代碼。

$ gst-launch-0.10 -e videomixer name=mix ! ffmpegcolorspace ! xvimagesink filesrc location = "asd.mp4" ! video/x-raw-yuv, framerate=1/1, width=350, height=250 !  textoverlay font-desc="Sans 24" text="CAM1" valign=top halign=left shaded-background=true !  videobox border-alpha=0 top=-200 left=-50 ! mix. multifilesrc location=drawing_total_mask_1.jpg" caps="image/jpeg,framerate=1/1" ! jpegdec !  textoverlay font-desc="Sans 26" text="Live from Pl" halign=left shaded-background=true auto-resize=false !  ffmpegcolorspace ! video/x-raw-yuv,format=\(fourcc\)AYUV ! mix. 
Setting pipeline to PAUSED ... 
Pipeline is PREROLLING ... 
WARNING: from element /GstPipeline:pipeline0/GstTextOverlay:textoverlay0: Could not multiplex stream. 
Additional debug info: 
gsttextoverlay.c(1848): gst_text_overlay_video_event(): /GstPipeline:pipeline0/GstTextOverlay:textoverlay0: 
received non-TIME newsegment event on video input 
WARNING: from element /GstPipeline:pipeline0/GstTextOverlay:textoverlay1: Could not multiplex stream. 
Additional debug info: 
gsttextoverlay.c(1848): gst_text_overlay_video_event(): /GstPipeline:pipeline0/GstTextOverlay:textoverlay1: 
received non-TIME newsegment event on video input 
ERROR: from element /GstPipeline:pipeline0/GstCapsFilter:capsfilter1: Filter caps do not completely specify the output format 
Additional debug info: 
gstcapsfilter.c(393): gst_capsfilter_prepare_buf(): /GstPipeline:pipeline0/GstCapsFilter:capsfilter1: 
Output caps are unfixed: video/x-raw-yuv, framerate=(fraction)1/1, width=(int)350, height=(int)250, format=(fourcc){ AYUV, YUY2, Y444, UYVY, Y42B, YV12, I420, Y41B } 
ERROR: pipeline doesn't want to preroll. 
Setting pipeline to NULL ... 

我無法找到正確的東西我沒有做到這一點。

所以總結
我想要一個由我製作的視頻,帶有一個透明的alpha區域,當它在圖像上運行時,會在視頻中的alpha區域顯示圖像。 任何幫助,將不勝感激。

在此先感謝。

回答

1

我發現了一種方法來做我在問題中提出的問題。我在這裏發佈它以幫助它們。

這將在圖像上運行視頻。 注:如果視頻有任何「橙」色區域,它將應用阿爾法鍵控透明度和圖像下面會顯示在tranparent region.cheers

gst-launch videomixer name=mix sink_0::alpha=1.0 sink_0::zorder=1 sink_1::zorder=2 
! ffmpegcolorspace ! xvimagesink filesrc location =vidoe.avi ! decodebin 
! alpha method=custom target-r=245 target-g=161 target-b=11 angle=10 
! ffmpegcolorspace ! mix.sink_1 multifilesrc location="image.jpg" 
    caps="image/jpeg,framerate=1/1" 
! jpegdec 
! textoverlay font-desc="Sans 26" text="Live from Pl" halign=left 
    shaded-background=true auto-resize=false 
! ffmpegcolorspace ! video/x-raw-yuv,format=\(fourcc\)AYUV ! mix.sink_0 
0

您需要解碼和解碼您的視頻文件才能使用它。只需使用filesrc ! video/x-raw-yuv就不會奇蹟般地從mp4中提取視頻數據。嘗試類似h264parse ! ffdec_h264(如果你的mp4擁有h.264編碼數據)

+0

能否請你通過把你說的幫我,在任何管道中作爲例子或使用上面的一個。謝謝 – 2015-02-23 12:15:58