Skip to content

Instantly share code, notes, and snippets.

@poqudrof
Created July 28, 2016 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poqudrof/c81ed038f50150108680c1896b389c53 to your computer and use it in GitHub Desktop.
Save poqudrof/c81ed038f50150108680c1896b389c53 to your computer and use it in GitHub Desktop.
Stream Gstreamer launch
#!/bin/ruby
## You can take pictures via Entangle, or in command line.
require 'fileutils'
# First argument is starting number
name = "capture"
output_name = "playing/capture000000.jpg"
# start with zero, to take from input arguments
id = ARGV[0].to_i
## Start Gstreamer
pid = Process.fork do
`gst-launch-0.10 multifilesrc location=playing/capture%06d.jpg start-index=0 stop-index=0 loop=true caps="image/jpeg,framerate=\(fraction\)1/1" ! jpegdec ! ffmpegcolorspace ! videorate ! v4l2sink device=/dev/video0`
end
file_name = name + id.to_s.rjust(6, "0") + ".jpg"
p file_name
p FileTest.exists? file_name
## update with the latest picture
while true do
if FileTest.exists? file_name
p "Putting image: " + id.to_s
FileUtils.cp file_name, output_name
id = id +1
file_name = name + id.to_s.rjust(6, "0") + ".jpg"
end
sleep 1
end
## Stream the video to V4L2:
# gphoto2 --stdout --capture-movie | gst-launch-0.10 fdsrc ! decodebin2 name=dec ! queue ! ffmpegcolorspace ! v4l2sink device=/dev/video0
## Stream x photos to V4L2
# gst-launch-0.10 multifilesrc location=capture%06d.jpg start-index=5 stop-index=18 loop=true caps=image/jpeg,framerate=\(fraction\)1/1 ! jpegdec ! ffmpegcolorspace ! videorate ! v4l2sink device=/dev/video0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment