@@ -158,11 +158,20 @@ fn create_input_bin(
158
158
pipeless_bus_sender : & tokio:: sync:: mpsc:: UnboundedSender < pipeless:: events:: Event > ,
159
159
) -> Result < gst:: Bin , InputPipelineError > {
160
160
let bin = gst:: Bin :: new ( ) ;
161
- if uri == "v4l2" { // Device webcam
161
+ if uri. starts_with ( "v4l2" ) { // Device webcam
162
162
let v4l2src = pipeless:: gst:: utils:: create_generic_component ( "v4l2src" , "v4l2src" ) ?;
163
163
let videoconvert = pipeless:: gst:: utils:: create_generic_component ( "videoconvert" , "videoconvert" ) ?;
164
164
let videoscale = pipeless:: gst:: utils:: create_generic_component ( "videoscale" , "videoscale" ) ?;
165
165
166
+ // The input uri for v4l2 can contain the device to use. Example: "v4l2:/dev/video0"
167
+ let uri_parts: Vec < & str > = uri. split ( ':' ) . collect ( ) ;
168
+ if uri_parts. len ( ) == 2 {
169
+ v4l2src. set_property ( "device" , uri_parts[ 1 ] ) ;
170
+ } else if uri_parts. len ( ) > 2 {
171
+ error ! ( "The provided input URI using v4l2 contains more than one video source. URI: {}" , uri) ;
172
+ return Err ( InputPipelineError :: new ( "Wrong input URI provided" ) ) ;
173
+ }
174
+
166
175
// Webcam resolutions are not standard and we can't read the webcam caps,
167
176
// force a hardcoded resolution so that we annouce a correct resolution to the output.
168
177
let forced_size_str = "video/x-raw,width=1280,height=720" ;
0 commit comments