Hi,
I'm trying to do the player for my plugin to play video from v4l2src
and i'm getting this error from gstreamer "Check your filtered caps,
if any".
I will put, what i think is the relevant code here, in the hopes that
someone may have an ideia about what i'm doing wrong.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
class V4l2Player(Player):
def __init__(self, config):
super(V4l2Player, self).__init__(config)
# GStreamer pipeline setup
self.debug("__init__(%s)" % str(config))
# Undo parent pipeline
pbus = self.pipeline.get_bus()
pbus.remove_signal_watch()
self.debug("Setting pipeline to NULL")
self.pipeline.set_state(gst.STATE_NULL)
self.pipeline = None
self.pgm_sink = None
# Recreate the pipeline
self._pipeline_v4l2src = None
self.pgm_sink = gst.element_factory_make('pgmimagesink')
self.pipeline = self._create_video_and_audio_pipeline(self.pgm_sink);
self.debug("pipeline is %s" % str(self.pipeline))
self.playlist = V4l2PlaylistModel()
# FIXME: disconnect from there
self.pipeline.connect('notify::stream-info',
self._on_stream_infos_notify)
pbus = self.pipeline.get_bus()
pbus.connect('message::eos', self._message_eos_cb)
pbus.connect('message::error', self._message_error_cb)
pbus.connect('message::state-changed', self._message_state_changed_cb)
pbus.connect('message::buffering', self._message_buffering_cb)
pbus.connect('message::element', self._message_element_cb)
pbus.connect('message::tag', self._message_tag_cb)
pbus.add_signal_watch()
def play_model(self, media_model):
self.playlist = V4l2PlaylistModel()
self.playlist.append(media_model)
self.play_at_index(0)
def _load_playable_model(self, model):
"""
@param model: a
L{elisa.plugins.v4l2.models.PlayableV4l2InputSourceModel}
@type param: C{elisa.plugins.v4l2.models.PlayableV4l2InputSourceModel}
"""
self._pipeline_v4l2src.set_property('device', model.device_model.device)
def _create_video_and_audio_pipeline(self, video_sink):
"""
Constructs the pipeline
"""
pipeline = gst.Pipeline('pipeline0')
# Video elements
if not self._pipeline_v4l2src:
self._pipeline_v4l2src =
gst.element_factory_make('v4l2src', 'v4l2src0')
pipeline.add(self._pipeline_v4l2src)
image_caps = gst.element_factory_make('capsfilter', 'image_capsfilter')
caps_string = 'video/x-raw-yuv,width=640,height=480,framerate=30/1'
image_caps.set_property('caps', gst.caps_from_string( caps_string ))
pipeline.add( image_caps )
video_queue = gst.element_factory_make('queue2', 'queue0')
pipeline.add( video_queue )
if video_sink:
self.debug("Adding videosink to pipeline - %s" % str(video_sink))
pipeline.add( video_sink )
self.debug("Connecting pipeline")
# video segment with caps, queue and video_sink
gst.element_link_many(self._pipeline_v4l2src, image_caps,
video_queue, video_sink)
self.debug("videosink parent is %s" % \
str(video_sink.get_parent()))
else:
self.warning("pipeline doesn't have an video sink")
return pipeline
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
The rest of the code is already in launchpad
(https://code.launchpad.net/elisa-plugin-v4l2)
My class V4l2Player extends elisa.plugins.poblesec.player_video.Player.
The constructor, after calling parent's constructor, destroy the
parent's pipeline, based in playbin and constructs a new one that is
basically this
v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=30/1 ! queue2
! pgmimagesink
The result is an message on screen saying
----------------
Unable To Play Selected File
Unfortunately Elisa cannot play the selected file. Gstreamer
error: The stream is in the wrong format
----------------
The log says
----------------
WARN MainThread default Mar 19 01:32:18
Gstreamer The stream is in the wrong format.:gstbasesrc.c(2426):
gst_base_src_start (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
Check your filtered caps, if any (elisa/plugins/poblesec/player_video.py:535)
----------------
I already tried all these pipelines
v4l2src ! pgmimagesink
v4l2src ! queue2 ! pgmimagesink
v4l2src ! queue2 ! ffmpegcolorspace ! pgmimagesink
v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=30/1 ! queue2
! ffmpegcolorspace ! pgmimagesink
All produce the same error.
I've also tried all these pipelines with gst-launch (replacing
pgmimagesink with xvimagesink) and they all work fine.
The pgmimagesink caps are compatible with video/x-raw-yuv and
video/x-raw-rgb with any width, height and framerate.
I've made a simple program to print the pgmimagesink caps and the result is this
----------------
video/x-raw-rgb, framerate=(fraction)[ 0/1, 2147483647/1 ],
width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ];
video/x-raw-yuv, framerate=(fraction)[ 0/1, 2147483647/1 ],
width=(int)[ 1, 2147483647 ], height=(int)[ 1, 2147483647 ]
----------------
So... I have no ideia about what i'm going wrong. I don't understand
what is the problem with the caps.
Can anyone help me with this?
Rui