1

I'm trying to use a jpg-File as a virtual webcam for Skype (or similar). The image file is reloading every few seconds and the Pipeline should also transmit always the newest image. I started creating a Pipeline like this

gst-launch filesrc location=~/image.jpg ! jpegdec ! ffmpegcolorspace ! freeze ! v4l2sink device=/dev/video2

but it only streams the first image and ignores the newer versions of the image file. I read something about concat and dynamically changing the Pipeline but I couldn't get this working for me.

Could you give me any hints on how to get this working?

Paul
  • 13
  • 1
  • 3

2 Answers2

0

Dynamic refresh the input file is NOT possible (at least with filesrc).
Besides, your sample use freeze, which will prevent the image change.

One possible method is using multifilesrc and videorate instead. multifilesrc can read many files (with a provided pattern similar to scanf/printf), and videorate can control the speed.

For example, you create 100 images with format image0000.jpg, image0001.jpg, ..., image0100.jpg. Then play them continuously, with each image in 1 second:

gst-launch multifilesrc location=~/image%04d.jpg start-index=0 stop-index=100 loop=true caps="image/jpeg,framerate=\(fraction\)1/1" ! jpegdec ! ffmpegcolorspace ! videorate ! v4l2sink device=/dev/video2

Changing the number of image at stop-index=100, and change speed at caps="image/jpeg,framerate=\(fraction\)1/1"
For more information about these elements, refer to their documents at gstreamer.freedesktop.org/documentation/plugins.html

EDIT: Look like you use GStreamer 0.10, not 1.x
In this case, please refer to old documents multifilesrc and videorate

matilda gl
  • 319
  • 1
  • 6
0

You can use a general file name with multifilesrc if you add some parameter adjustments and pair it with an identity on a delay. It's a bit fragile but it'll do fine for a temporary one-off program as long as you keep your input images the same dimensions and format.

gst-launch-1.0 multifilesrc loop=true start-index=0 stop-index=0 location=/tmp/whatever ! decodebin ! identity sleep-time=1000000 ! videoconvert ! v4l2sink

mpr
  • 3,250
  • 26
  • 44
  • Can you provide any examples of the general file name working @mpr? Were you providing a list, or directory? Can you please paste more or elaborate on this answer? I would get `gstmultifilesrc.c(474): gst_multi_file_src_create (): /GstPipeline:pipeline0/GstMultiFileSrc:multifilesrc0: Error reading file '/home/pi/Data/Videos/TimeLapse/12_10_18': Is a directory ERROR: pipeline doesn't want to preroll.` If I tried *.jpeg added to the directory, that would also break. Just looking for a pipeline recipe! – Kelton Temby Dec 11 '18 at 01:57
  • For the sake of completeness per comment above, I found that Gstreamer does accept symlinks. So getting a variation this working to pre-process will work great: `mkdir tmp curIdx=0; for curFile in *.JPG; do outFile=$(printf "./tmp/img_%04d.jpg" "$curIdx"); echo 'File: '$curFile '->' $outFile; ln -s $curFile $outFile; curIdx=$(expr $curIdx + 1); done` Reference: https://devtalk.nvidia.com/default/topic/1038158/jetson-tx2/gstreamer-h265-compression-jetson-tx2/ – Kelton Temby Dec 11 '18 at 02:49