2015-02-23 106 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