Reputation: 55
I am working on a project where I need to display a video with "alpha keying" a region of interest based on color and run it over an image so the image under the region of interest is visible over the video.
$ 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.
Searching for it I found something like this which allows me to display the test video (videotestsrc
) over the image but when I give an alternate video source it wont do that .
The code I used to give my own source and the errors followed by it.
$ 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 ...
I am not able find what's right I am not doing to make it work.
So to summarize
I want a video sourced by me with an transparent alpha region, which when run on a image will display the image over the alpha region of interest in video.
Any help would be appreciated.
Thanks in advance.
Upvotes: 1
Views: 2915
Reputation: 55
I found out a way to do what I have asked in the question .I am posting it here for those whom it will help .
This will run video on top of an image. Note: If the video has any "orange" colored region , it will apply alpha keying transparency and the image will below will be displayed on 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
Upvotes: 2
Reputation: 31374
you need to demultiplex and decode your video-file in order to be able to use it. just using filesrc ! video/x-raw-yuv
will not magically extract the video data from an mp4. try something like h264parse ! ffdec_h264
(in case your mp4 holds h.264
encoded data)
Upvotes: 0