class MultimediaParadise::GUI::Gtk::WebcamWidget
Constants
- ARRAY_DEFAULT_RESOLUTIONS
#¶ ↑
ARRAY_DEFAULT_RESOLUTIONS
¶ ↑#¶ ↑
- HEIGHT
#¶ ↑
HEIGHT
¶ ↑#¶ ↑
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- TITLE
#¶ ↑
TITLE
¶ ↑#¶ ↑
- USE_THIS_FONT
#¶ ↑
USE_THIS_FONT
¶ ↑#¶ ↑
- WIDTH
#¶ ↑
WIDTH
¶ ↑#¶ ↑
Public Class Methods
new( commandline_arguments = ARGV, run_already = true )
click to toggle source
run( i = ARGV )
click to toggle source
#¶ ↑
MultimediaParadise::GUI::Gtk::WebcamWidget.run
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 319 def self.run( i = ARGV ) require 'gtk_paradise/app/app.rb' _ = ::MultimediaParadise::GUI::Gtk::WebcamWidget.new(i) r = ::Gtk.run r << _ r.automatic_size_then_automatic_title r.enable_quick_exit r.top_left_then_run end
Public Instance Methods
add_the_camera_web_icon()
click to toggle source
border_size?()
click to toggle source
connect_skeleton()
click to toggle source
#¶ ↑
connect_skeleton
(connect tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 242 def connect_skeleton abort_on_exception add_the_camera_web_icon populate_the_grid minimal(@grid, 10) minimal(horizontal_line, 2) result = `#{return_the_ffmpeg_list_all_supported_formats_command}` splitted = result.split("\n") selection = splitted.select {|entry| entry.include? 'video4linux2' } selection.each {|this_text| truncated_text = this_text.sub(/\[.+\]/,'') minimal( left_aligned_text(truncated_text) ) } minimal(horizontal_line, 2) # ======================================================================= # # Add the button that captures the video stream next # ======================================================================= # hbox5 = gtk_hbox mini_hbox = gtk_hbox mini_hbox.minimal(@button_capture_the_video_stream, 5) hbox5.center_this_widget hbox5.minimal(mini_hbox, 12) minimal(hbox5, 2) end
create_skeleton()
click to toggle source
#¶ ↑
create_skeleton
(create tag, skeleton tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 142 def create_skeleton create_the_checkboxes create_the_grid create_the_entries create_the_comboboxes # ======================================================================= # # === @button_capture_the_video_stream # ======================================================================= # @button_capture_the_video_stream = button('_Capture video stream') @button_capture_the_video_stream.clear_background @button_capture_the_video_stream.background_color(:oldlace) @button_capture_the_video_stream.on_hover(:lightblue) @button_capture_the_video_stream.bblack2 @button_capture_the_video_stream.pad8px @button_capture_the_video_stream.on_clicked { do_run_the_capture_command } end
create_the_checkboxes()
click to toggle source
#¶ ↑
create_the_checkboxes
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 126 def create_the_checkboxes # ======================================================================= # # === @checkbox_shall_we_store_into_a_file # ======================================================================= # @checkbox_shall_we_store_into_a_file = gtk_checkbox @checkbox_shall_we_store_into_a_file.is_active @checkbox_shall_we_store_into_a_file.hint = 'Store into a file '\ 'as well. De-select this to not store into a local file.' @checkbox_shall_we_store_into_a_file.on_changed { toggle_the_main_command_shown } end
create_the_comboboxes()
click to toggle source
#¶ ↑
create_the_comboboxes
(comboboxes tag, combobox tag, combo tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 200 def create_the_comboboxes # ======================================================================= # # === @combobox_resolution # ======================================================================= # sorted_array = ARRAY_DEFAULT_RESOLUTIONS.sort {|entry| entry.split('x').first.to_i }.reverse @combobox_resolution = gtk_combo_box_text( sorted_array ) @combobox_resolution.first_one_is_active @combobox_resolution.pad5px @combobox_resolution.on_changed { update_the_entry_command_to_run } # ======================================================================= # # === @combobox_allowed_input_formats # ======================================================================= # @combobox_allowed_input_formats = gtk_combobox_text(%w( mjpeg yuyv422 h264 )) @combobox_allowed_input_formats.pad5px @combobox_allowed_input_formats.first_one_is_active @combobox_allowed_input_formats.on_changed { update_the_entry_command_to_run } end
create_the_entries()
click to toggle source
#¶ ↑
create_the_entries
(entries tag, entry tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 164 def create_the_entries # ======================================================================= # # === @entry_device_to_use # ======================================================================= # @entry_device_to_use = gtk_entry('/dev/video1') @entry_device_to_use.pad5px @entry_device_to_use.bblack1 @entry_device_to_use.yello @entry_device_to_use.width_height(280, 42) @entry_device_to_use.hint = "This can be something like "\ "<b>/dev/video0</b> or <b>/dev/video2</b> and so forth.\n\n"\ "A hint will show up if there is no value assigned in "\ "this entry." @entry_device_to_use.ghost_text = '/dev/video0' # ======================================================================= # # === @entry_store_into_this_file # ======================================================================= # @entry_store_into_this_file = gtk_entry(return_a_plausible_location_for_the_generated_video_file) @entry_store_into_this_file.pad5px @entry_store_into_this_file.bblack1 @entry_store_into_this_file.yello @entry_store_into_this_file.width_height(280, 42) # ======================================================================= # # === @entry_command_to_run # ======================================================================= # @entry_command_to_run = gtk_entry @entry_command_to_run.pad5px @entry_command_to_run.bblack1 @entry_command_to_run.yello @entry_command_to_run.width_height(880, 42) @entry_command_to_run.can_not_be_modified end
create_the_grid()
click to toggle source
#¶ ↑
create_the_grid
(grid tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 114 def create_the_grid # ======================================================================= # # === @grid # ======================================================================= # @grid = default_grid @grid.set_column_spacing(4) @grid.set_row_spacing(4) end
current_input_format?()
click to toggle source
current_resolution?()
click to toggle source
do_run_the_capture_command()
click to toggle source
#¶ ↑
do_run_the_capture_command
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 404 def do_run_the_capture_command if File.directory? the_base_directory_is_at? cd(the_base_directory_is_at?) end Thread.new { esystem(return_the_capture_command) } end
Also aliased as: do_capture
padding?()
click to toggle source
populate_the_grid()
click to toggle source
#¶ ↑
populate_the_grid
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 334 def populate_the_grid @grid.left(left_aligned_text('Resolution to use:')) @grid.right(@combobox_resolution) @grid.new_line @grid.left(left_aligned_text('Device to use:')) @grid.right(@entry_device_to_use) @grid.new_line @grid.left(left_aligned_text('Store into this file:')) hbox1 = gtk_hbox hbox1.maximal(@entry_store_into_this_file) hbox1.minimal(@checkbox_shall_we_store_into_a_file) @grid.right(hbox1) @grid.new_line @grid.left(left_aligned_text('Allowed input formats:')) @grid.right(@combobox_allowed_input_formats) @grid.new_line @grid.left(left_aligned_text('Command to run:')) @grid.right(@entry_command_to_run) @grid.new_line end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 83 def reset reset_the_internal_variables # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] # ======================================================================= # # === Set the title, width, height and the font in use. # ======================================================================= # title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT) use_gtk_paradise_project_css_file infer_the_size_automatically end
return_a_plausible_location_for_the_generated_video_file()
click to toggle source
#¶ ↑
return_a_plausible_location_for_the_generated_video_file
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 358 def return_a_plausible_location_for_the_generated_video_file _ = '/tmp/video1.mp4' # mkv' if File.directory?('/Depot/j/') _ = '/Depot/j/video1.mp4' end return _ end
return_the_capture_command()
click to toggle source
#¶ ↑
return_the_capture_command
¶ ↑
Note
that some camers offer a lot of fps, such as by using the MJPEG encoder, but less fps when using “raw video”.
We could also use ffmpeg for the capture command.
Example for this:
ffmpeg -framerate 30 -input_format mjpeg -f video4linux2 -video_size 1920x1080 -i /dev/video1 /Depot/jjjj/foobar.mp4 ffmpeg -input_format mjpeg -framerate 30 -f v4l2 -video_size 1920x1080 -i /dev/video1 -c copy /Depot/jjjj/foobar.mp4
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 387 def return_the_capture_command cmd = 'mpv '.dup cmd << '--profile=low-latency ' if @checkbox_shall_we_store_into_a_file.active? cmd << '--stream-record='+store_into_which_file? end cmd << ' '\ '--demuxer-lavf-format=video4linux2 '\ '--demuxer-lavf-o-set=input_format='+current_input_format?+' '\ '--demuxer-lavf-o=video_size='+current_resolution?+' '\ 'av://v4l2:'+which_device_to_use? return cmd.squeeze(' ') end
return_the_ffmpeg_list_all_supported_formats_command()
click to toggle source
run()
click to toggle source
store_into_which_file?()
click to toggle source
the_base_directory_is_at?()
click to toggle source
update_the_entry_command_to_run()
click to toggle source
#¶ ↑
update_the_entry_command_to_run
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/gui/gtk3/webcam_widget/webcam_widget.rb, line 369 def update_the_entry_command_to_run @entry_command_to_run.set_text(return_the_capture_command) end
Also aliased as: toggle_the_main_command_shown