Notifications
Clear all

MP4 video camera?  

Page 3 / 5

Spyder
(@spyder)
Prominent Member
Joined: 2 years ago
Posts: 876
 

@robo-pi

That is an awesome project dude !

Posted by: @robo-pi

I managed to satisfy all four of these.  So I'd say that's a WIN for me. 😎

Yup, I'd call it a win !

Might not fit what somebody else wants, but it does exactly what YOU NEED from it, which is what I'd call a win

What about a case ?

What are you using to hold it all together ?

You don't have a 3D printer, so you must be using some other way to sorta box it all up


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 2 years ago
Posts: 1855
Topic starter  
Posted by: @spyder

What about a case ?

The 3.5" displays I bought came with clear plastic cases.  However, these cases are designed to fit RPi 4.  So I am modifying them for use with the Pi Zeros.

Posted by: @spyder

What are you using to hold it all together ?

The case snaps together and can also be taken back apart just as easily.  I've screwed the Pi Zero down to the floor of the case.  The case came with hardware to mount the Pi on standoffs.

Posted by: @spyder

You don't have a 3D printer, so you must be using some other way to sorta box it all up

There are quite a few things to taken into consideration to be sure.  In fact, since I'm building two of these I might make a video of the second build using the first build to actually shoot the video. 😎 

 

There are also several different ways to go with this.  My first thought was to have it all self-contained as a single package (i.e. the Camera, Pi Zero and touchscreen all combined together).   However, that actually turns out being fairly awkward for several reasons.

  1. I'm using an AC adapter for power rather than batteries. (so I'll have the power cord to deal with)
  2. I'm also using an external USB hub.  (So that's even more junk hanging off the pi)
  3. So in the end having the camera attached to the Pi case can become quite cumbersome.

So instead of going for a totally portable camera I've decided to use a long cable between the Pi and the camera and let the camera be more flexible on its own.

I've decided to use these camera to HDMI converters, so I can use a nice HDMI cable between the camera and the Pi.  This adds some more cost to the project, but it will be so much easier to deal with the camera alone when positioning it for a shot.

 

 

Because the Pi Zero only takes up half the space within the case there's enough room to mount this camera-to-HDMI connector inside the case with the Pi.   This way I can just plug the HDMI cable right into the Pi Case.

I'll have a 6' HDMI cable going to the camera.  The camera came with a nice mounting case too.  So all I need to do at that end is attach a mount that I can affix to a tripod.

It certainly won't be as portable as it could be.  But I'm not worried about that kind of portability.  It's still portable in the sense that I can set this up anywhere I need to shoot videos.  The current plan is to film machining projects on the lathe and milling machine.  So these cameras will basically just be set up by those machines with the camera on a tripod or some other mount.

After I have the first one finished, I might use it to film a video constructing the second one.

Posted by: @spyder

Might not fit what somebody else wants, but it does exactly what YOU NEED from it, which is what I'd call a win

Exactly.  Plus there are certainly options available to make it into a portable single unit that's battery operated. I'm not going to bother going that route because I don't mind plugging it in.  And I kind of like having the camera at the end of an HDMI cable.  That will make the actual camera quite a bit smaller and perhaps a bit easier to position in tight spots.

So yeah, not a design for everyone.    But the tkinter software I wrote should work no matter how it is physically constructed.  So that much of the project is more versatile.

DroneBot Workshop Robotics Engineer
James


Spyder liked
ReplyQuote
Spyder
(@spyder)
Prominent Member
Joined: 2 years ago
Posts: 876
 

@robo-pi

That CSI-USB looks pretty cool. I'm going to have a need for one shortly (I think. Look for new post on it) Different model I think. The one suggested in the article is obviously out of stock (of course)

What is that black thingy on the back ? Is that a jack ? What's it for ?

And the big question...

What size are the mp4 files you're creating ?

On avg, mb per minute


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 2 years ago
Posts: 1855
Topic starter  
Posted by: @spyder

That CSI-USB looks pretty cool

It's actually CSI to full-size HDMI connector.   It allows you to use a standard HDMI cable to connect the camera to the Pi so you don't need to use a long delicate flat ribbon cable.  I like it because it's pretty durable.  You can mount the camera on a tripod away from the Pi and not have to worry so much about the cable being accidentally damage.

In fact, I actually use this same set up with my Jetson Nanos and their cameras.  It's just a nifty way to be able to move the camera around without worrying about keeping it close to the SBC.  In fact, I'm using 15 foot cables on my Jetson Nanos.  That's a bit of overkill but it allows me to place the camera just about anywhere without having to worry about dragging the Jetson Nano along with it.

I'll only be using 6' cables for these cameras.  In fact, I could probably get by with 3' cables, but they are pretty close to the same price so why not get the longer ones?   Better to have too much cable than not enough.

Posted by: @spyder

What is that black thingy on the back ? Is that a jack ? What's it for ?

It's a standard 3 connection audio/aux jack.    There is nothing connected to it other than the HDMI part of the connector.  They say that you can use this to pass any 3 signals you like, audio, data, GPIO pins, etc.

Of course if you want to use it for audio you'll need to supply the actual audio signal.   I don't currently have a use for the these jacks.   I won't be recording audio on these videos.  I'll dub in a voice-over later.   There's too much noise when the lathe or mill are running anyway.   So I'll just grab the video I need and then talk over it when I do the video editing.  

I'm not sure how you would sync audio with the video anyway?  I didn't really pay attention to see whether raspivid has any audio options.   I didn't even bother to look since I wasn't worried about recording audio from the beginning.  As I say, too noisy in the shop anyway.

But yeah, apparently there are three conductors on the HDMI cable that the camera doesn't use, so they included this audio style jack for the maker to come up with a brilliant use for those extra three signals. 👍 

DroneBot Workshop Robotics Engineer
James


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 2 years ago
Posts: 1855
Topic starter  

~~~

Satisfaction with a Raspberry Pi
it may seem simple by my oh my!
when it comes together it's oh so sweet
goose pimples flow o're this Dronebot geek

~~~

I'm currently waiting for some parts to arrive before I can finish the first camera build.   So in the meantime I cloned the SD card and stuck it in another Pi Zero along with plugging in another touchscreen display.   I fired it up and it's works exactly like the first one. 😎 

Yes, I know.  What else should I expect?  That's what it's supposed to do. 🤣 

None the less it feels really good to see the second unit working without any hassle.  I have so much on here. My remote desktop and WiFi credentials, the enabled camera, the touchscreen software, my Python TK camera GUI program.  Along with various other installed software like Pillow, MP4Box, etc.

It took a lot to get this up to where it is.  It's really nice to be able to just clone an SD card and have a second Pi Zero fire up and see everything working without a hitch.   So the second camera only needs to be physically built in terms of the case and connectors, etc.  The software is finished.

The project is coming along. 🥂 

 

DroneBot Workshop Robotics Engineer
James


Spyder liked
ReplyQuote
Spyder
(@spyder)
Prominent Member
Joined: 2 years ago
Posts: 876
 

@robo-pi

Now yer that much closer to mass-production, eh ?

Do you think this method might be helpful in ripping my VHS tapes ?

I'm currently using a combination of RCA-HDMI connected to an HDMI-USB, and piping it into a program called Bandicam, which... works, but I have to draw a bounding box around the picture, and then capture that picture

I've tried other software, but, I want the output to be mp4, which, for some reason, isn't easy to find, or work with if you CAN find it


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 2 years ago
Posts: 815
 

@robo-pi

I have a 3.5 inch touch screen already that is connected to a RasPi 3 that I haven't used in ages, guess all I need now is the Arducam (even have a set of the csi-to-hdmi adapters).

There was an adapter that connected the HDMI port of the PI to the touchscreen that came with my screen, but I'm guessing to use the Pi Zero, you had to use a short HDMI cable.  Is that correct?

And if the Arducam is connected to the Pi Zero, there will be a need for a CSI cable for the Zero.

SteveG


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 2 years ago
Posts: 1855
Topic starter  
Posted by: @codecage

There was an adapter that connected the HDMI port of the PI to the touchscreen that came with my screen, but I'm guessing to use the Pi Zero, you had to use a short HDMI cable.  Is that correct?

That's my understanding as well.  Touchscreens that have HDMI connectors usually come with either standard size HDMI connector for RP1 3, or a micro HDMI connector for the RPI 4.   Oddly the Pi Zero uses a Mini HDMI connector.  So yes, you will most likely need a cable to make that adaptation from mini to full-size.

This was one reason I got the GPIO type display.  I didn't want to have to deal with trying to adapt a Mini HDMI connector to the display.

 

Posted by: @codecage

And if the Arducam is connected to the Pi Zero, there will be a need for a CSI cable for the Zero.

Yes, that's another little quirk.  The Pi Zero uses a smaller CSI cable connector.  So you'll need to remove the ribbon cable from one of your CSI-to-HDMI connectors and replace it with one that is necked down for the Pi Zero.   Lots of little annoying details. 🤣 

DroneBot Workshop Robotics Engineer
James


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 2 years ago
Posts: 1855
Topic starter  

SOFTWARE UPDATE:  

I made some changes to the TK camera program.    I finally figured out how to retain control of Python while the video is recording.  So I no longer need to use the desktop ICON to execute the "pkill raspivid" command.  The program still uses pkill but it's now being done via a button in the TK window

  1. Imported "multiprocessing" module to free Python from raspivid.
  2. Added a STOP VIDEO button to the TK window.
  3. Resized the TK window to 480 x 320 since I no longer need to see the desktop icon to use pkill
  4. Added a SAVE JPG button to the TK window.  (allows the choice to save a preview as a named jpg)
  5. Added a Label below the save button to show the name the jpg will be saved as.

 Sorry I don't have time to give a full explanation.   I tried to include comments where possible.

You might need to modify the path I'm using path = "/media/pi/MP4/" because I'm using a USB stick that I had named MP4

If you are saving your files somewhere else, you'll need to change the path accordingly.  I think this path is defined two places in the code.  It should probably be made global so it only needs to be defined once.  I'm sure this code could be cleaned up quite a bit.  I'm happy to have found a way to stop the video from within Python.   Using multiprocessing appears to work. 

 

I still have more cosmetic work to do on this program.  But I thought I'd post this update in the meantime for whatever it might be worth. 

 

# Subprocess is used to excute raspivid commands
import subprocess as CMDLine
# clear the terminal screen (for programming use only)
CMDLine.call(("clear"), shell=True)
# The following is used to allow raspivi to run as a seperate process
# This allows the python TK window to retain control and stop the video recording
from multiprocessing import Process

# TK imports used NOTE: You could use "from tkinter import *"
# I prefer to just import what I actually use
from tkinter import Tk
from tkinter import Frame
from tkinter import Label
from tkinter import Button
from tkinter import OptionMenu
from tkinter import StringVar
# Pillow imports (used for the preview image)
from PIL import ImageTk
from PIL import Image

# Create a TK Window name win_Main
win_Main = Tk()
win_coords = "480x320+0+0"
win_Main.title("Camera Settings")
win_Main.geometry(win_coords)
win_Main.resizable(False, False)

# Create frame_1 (I like to use Frames)
# But you could just do this all in win_Main
frame_1 = Frame(win_Main)
frame_1.grid(row = 0, column = 0)

# ---------  Widget methods follow -------

# This routine is called by the OptionMenu when a new option is selected.
def SetLabel(self):
	# Get the selected name from the OptionMenu using video_name_tk get()
	# Construct the new video filename including the video_number
	lbl_VidName.config(text=video_name_tk.get() + "_" + str(video_number))

# This routine increments or decrements the video file number
# Used by the Up, Dn buttons.
def File_Number(num):
	global video_number
	video_number = video_number + num
	# Construct the full video filename in the widget lbl_VidName
	lbl_VidName.config(text=video_name_tk.get() + "_" + str(video_number))
	lbl_VidName2.config(text=video_name_tk.get() + "_" + str(video_number))

# This method is called by the multiprocess command in def Record(): See method below
def Start_recording(command):
	CMDLine.call((command), shell=True)


# This is the record method that actually takes the video
# This routine also converts the video from h264 to mp4
def Record():
	# Record button aesthetics
	btn_Record.config(text = "Recording")
	btn_Record.config(activebackground="red")
	win_Main.update_idletasks()
	# END Record button aesthetics
	# 	# define the command as a string
	# NOTE: use -t 0 to record forever, or until Pkill is used
	# -t 10000 is 10000 millisecond or 10 seconds
	path = "/media/pi/MP4/"
	# Set up the video name and path
	vid_name = path + lbl_VidName.cget("text")
	# set up the raspivid command
	command = "raspivid -o " + vid_name + ".h264 -t 10000 -w 1280 -h 720 -p '480,0,480,320'"
	# The following is the new multiprocessing feature:
	# Send the command to the terminal as a new process
	p = Process(target=Start_recording, args=(command,))
	p.start()

	btn_Record.config(text = "Record Video")
	# recording is finished and converted to mp4
	# Record button aesthetics
	btn_Record.config(text = "Record")
	btn_Record.config(activebackground=btn_Record.cget('bg'))
	win_Main.update_idletasks()
	# END Record button aesthetics

def Stop_Record():
	# It's still necessary to stop rapivid using "pkill raspivid"
	# But now it can be done using a python button instead of a desktop icon
	command = "pkill raspivid"
	CMDLine.call((command), shell=True)
	path = "/media/pi/MP4/"
	# Set up the video name and path
	vid_name = path + lbl_VidName.cget("text")
	# --- MOVED convert to MP4 here to this Stop_Record() button method
	# define another command to convert video formats
	command_mp4 = "MP4Box -add " + vid_name + ".h264 " + vid_name + ".mp4"
	# Send the command to the terminal
	CMDLine.call(command_mp4, shell=True)



# This method Previews the jpeg and displays the Preview
def Preview():
	# Preview button aesthetics 
	btn_preview.config(text="Please Wait")
	btn_preview.config(activebackground="red")
	win_Main.update_idletasks()
	# END preview button aesthetics
	# Using raspistill to take the jpeg
	CMDLine.call(("raspistill -o preview.jpg -w 360 -h 240"), shell=True)
	# pix_preview must be global
	global pix_preview
	pix_preview = ImageTk.PhotoImage(Image.open("preview.jpg"))
	# pic_1 is a TK Label widget to display the jpeg
	pic_1 = Label(frame_1)
	pic_1.config(image = pix_preview)
	pic_1.grid(row=0, column=2, rowspan=12)
	# Preview button aesthetics
	btn_preview.config(text="Snap Preview")
	btn_preview.config(activebackground=btn_preview.cget('bg'))
	win_Main.update_idletasks()
	# END preview button aesthetics

# Added the following method to offer an option to save the preview to a file.
def Save_Preview():
	path = "/media/pi/MP4/"
	command = "cp preview.jpg " + path + lbl_VidName.cget("text") + "jpg"
	CMDLine.call((command), shell=True)

# The Exit Button routine
def Exit():
	win_Main.destroy()

# ---- Below are all the widgets used on the TK frame_1

# This is a list of video names for the OptionMenu
# Note: you can add or delete names on this list as desired
options = [
	"Steam",
	"Shop",
	"Robot",
	"Tools"]

# This is a TK string variable used by the OptionMenu box
video_name_tk = StringVar()
video_name_tk.set(options[0])
# Used to hold the number part of the video name
video_number = 0

# The Options menu widget
OpMenu = OptionMenu(frame_1, video_name_tk, *options, command=SetLabel)
OpMenu.config(width=8)
OpMenu.grid(row=0, column=0, columnspan=2)	

# Static Lable to always display "Video Name"
lbl_VidName0 = Label(frame_1, text="Video Name", width=10)
lbl_VidName0.grid(row=2, column = 0, columnspan=2)

# Dynamic Label to display the current chosen video filename and number
# This label is dynamically updated when the name or number is chosen
# See methods: SetLabel, Up, and Dn.
lbl_VidName = Label(frame_1, width=12, bg='white')
# Construct the initial filename using video_name_tk and video_number
# and place it on the VidName TK label
lbl_VidName.config(text=video_name_tk.get() + "_" + str(video_number))
lbl_VidName.grid(row=3, column = 0, columnspan=2)

# Button Up -- increment video number
btn_Up = Button(frame_1, text = "Up", width=3, command=lambda: File_Number(1))
btn_Up.grid(row=4, column=0)

# Button Dn -- decrement video number
btn_Dn = Button(frame_1, text = "Dn", width=3,  command=lambda: File_Number(-1))
btn_Dn.grid(row=4, column=1)

# Button to record and also convert videos from h264 to mp4
# Currently set to 10 second videos, use raspivid -t 0 for unlimited video 
# NOTE: must use the desktop Pkill icon to stop recording when using -t 0
btn_Record = Button(frame_1, text = "Record Video", width=10, command=Record)
btn_Record.grid(row=6, column=0, columnspan=2)

btn_Stop_Record = Button(frame_1, text = "Stop Video", width=10, command=Stop_Record)
btn_Stop_Record.grid(row=7, column=0, columnspan=2)


# Button to Preview a preview for focusing 
btn_preview = Button(frame_1, text = "Snap Preview", width=10,  command=Preview)
btn_preview.grid(row=8, column=0, columnspan=2)

# Save the preview as a jpg 
btn_save_preview = Button(frame_1, text = "Save as jpg", width=10,  command=Save_Preview)
btn_save_preview.grid(row=9, column=0, columnspan=2)

# This is just a copy of lbl_VidName and placed after the "Save as jpg" Button
lbl_VidName2 = Label(frame_1, width=12, bg='white')
# Construct the initial filename using video_name_tk and video_number
# and place it on the VidName TK label
lbl_VidName2.config(text=video_name_tk.get() + "_" + str(video_number))
lbl_VidName2.grid(row=10, column = 0, columnspan=2)

# Button to Exit the TK program
btn_exit = Button(frame_1, text = "Exit", width=10, command=Exit)
btn_exit.grid(row=11, column=0, columnspan=2)

# The following keeps the TK window looping.
win_Main.mainloop()


# --- If you are modifying previous code, don't forget to edit all grid coordinate ---
# --- Buttons need to be in consecutive rows or they will be displayed overtop each other
# --- Also on line 115 in the Preview() method columnspan,....
# ,... needs to equal the total number of buttons and labels you have.
# ,... this could have been done better using a second frame for the preview picture.
# ,... this is still a work in progress. 

DroneBot Workshop Robotics Engineer
James


ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 2 years ago
Posts: 815
 

Great work @robo-pi!  I'm using your code on my Raspberry Pi Video Camera and it works great.  The "Kill" button will be a wonderful addition.  I'll give it a shot.  Might make a great Christmas Day project to improve one of my toys then use it to record some of the "playing" with the other new toys that Santa brings!

SteveG


ReplyQuote
frogandtoad
(@frogandtoad)
Honorable Member
Joined: 2 years ago
Posts: 671
 

@robo-pi

Are you creating a separate GUI over the top of the original?

You might want to avoid multiprocessing, and use threading (recommended) instead for GUI work.


ReplyQuote
byron
(@byron)
Reputable Member
Joined: 2 years ago
Posts: 389
 

@robo-pi

Thanks for your nice example code,  its a most satisfying project example.   A short while back I did get tkinter buttons working with my rpi camera using the import picamera module as opposed to using a sub process command line, but I'm not sure if this is applicable for your camera and certainly not worth changing your code for.

It is not often clear as to whether multi-processing or multi-threading will give the best results though the rule of thumb of course is for i/o bound use threading and for cpu bound use multi processing.   A tip may be that you can easily switch between the two with by just changing one line of code if you use the concurrent.futures module where one would just change the following -

with concurrent.futures.ProcessingPoolExector as executor

- to

with concurrent.futures.ThreadingPoolExecutor as executor

and all the rest of ones code can remain the same making a comparison benchmark easy to do.   But thats just some thoughts for some future projects and I not saying it's of much relevance to the code you show.  

If only I could be as diligent as you with all those excellent comments.  It all make for a very good example of just how readable and understandable a nice bit of python code can be.  And finally I see a good use of a lambda that actually adds to the readability, short and sweet and they are a treat. 😎 👍 


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 2 years ago
Posts: 1855
Topic starter  

@frogandtoad, @byron

Hi guys, thanks for the comments.   I'm no expert on Python, Tkinter, threading, or multiprocessing.   I just hack my way though this stuff and I'm using a ton of web resources when I don't know how to do something, which is pretty much with every line of code I write.  🤣 

When I get something hacked together that actually works, I run with it.  Knowing full-well it's most likely not the best way to do things.

So I've offered this code up as "food for thought".  Just something that someone might use to get their feet wet.  Especially if they know even less than me about Python, Tkinter, raspivid, etc.

There are also always many different ways to write programs.  If you have any code examples that you would like to share, please feel free to post your code for others to see.   I might switch over to using your code myself. 😊 

My code could be cleaned up quite a bit, just by going over it with the intent of cleaning it up, even if I continue to use the same basic modules and methods.   So I make no claim that my code is efficient, or even professional.  All I can lay claim to is that it appears to do what it's supposed to do.

I am trying to learn more, but my mind doesn't retain information very well anymore.  So I tend to learn general ideas and principles, but then when it comes time to actually use them I'll no-doubt need to go back to the web resources to learn the precise implementation anyway.

Posted by: @frogandtoad

Are you creating a separate GUI over the top of the original?

You might want to avoid multiprocessing, and use threading (recommended) instead for GUI work.

No, I'm not creating a separate GUI over top the original.   I'm just running raspivid as a separate process.  Raspivid has no GUI.

I do believe I have some understanding of when to best use threading versus multiprocessing.

It's my understanding that threading is best used within a program where you want to have various parts of the same program running in parallel. 

Multiprocessing, on the other hand, is best used when you want to launch a totally separate process from within your program.  That's what I'm doing.  I'm launching raspivid from within the Tkinter GUI loop.   This way raspivid can do its thing while the Tkinter GUI loop continues to run, thus allowing me to use a Tkinter Button to then stop the raspivid process.

So I think I'm using the correct tool.  Just not sure if I'm using it in the most efficient way possible.  My purpose here is not to speed anything up, but rather just to allow the Tkinter window to remain active after having launched raspivid.

My original Tkinter window would freeze up and become unresponsive the moment I launched raspivid.  And it wouldn't regain control until I used the desktop "pkill" icon to kill raspivid.   But now, by using multiprocessing, the Tkinter window remains active and so I can use a Tkinter Button to kill raspivid.

All I know is that it works. 😎  Whether it's the proper way to do things I have clue. 😮 🥂 

I'm no expert.  I'm just a hack.

DroneBot Workshop Robotics Engineer
James


ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer Moderator
Joined: 2 years ago
Posts: 1855
Topic starter  
Posted by: @byron

If only I could be as diligent as you with all those excellent comments.  It all make for a very good example of just how readable and understandable a nice bit of python code can be.

I've started commenting my code profusely, because I got tired of going back to my old code and having to try to figure out what the heck I was doing back then.  🤣 

Also, in the case of this particular code, I wrote in comments with the intention of making the code into a post.   So I tended to write the comments as if I was trying to explain the code to someone else. 

Actually, that's probably the best way to always write comments.  You should always try to write comments as if you are explaining what you are doing to someone else who might not know.  Think of how easy that's going to be for you to read when you come back to your own code much later. 👍 

DroneBot Workshop Robotics Engineer
James


ReplyQuote
frogandtoad
(@frogandtoad)
Honorable Member
Joined: 2 years ago
Posts: 671
 

@robo-pi

Posted by: @frogandtoad
Posted by: @frogandtoad

Are you creating a separate GUI over the top of the original?

You might want to avoid multiprocessing, and use threading (recommended) instead for GUI work.

No, I'm not creating a separate GUI over top the original.   I'm just running raspivid as a separate process.  Raspivid has no GUI.

No, I'm talking about your tkinter GUI program... isn't this about your tkinter GUI?  For example, when you run your code, and click the "Record Video" button, it creates another GUI (program instance) directly on top of the original one, that you can drag out of the way with your mouse.  Click the button again will create a third GUI, and so on - Each of these GUI instances reside in their own memory space.

Maybe you and @codecage can try it out as described and let us know your findings?, because that's exactly what your code does when I run it.

Anyway, what you want instead is:

    import threading

[snip]

    # Then replace your line with the following
    p = threading.Thread(target=Start_recording, args=(command,))

You should also think about disabling the button after clicking it too:

    btn_Record.config(state = DISABLED)

Posted by: @robo-pi

I do believe I have some understanding of when to best use threading versus multiprocessing.

It's my understanding that threading is best used within a program where you want to have various parts of the same program running in parallel. 

Multiprocessing, on the other hand, is best used when you want to launch a totally separate process from within your program. 

Threading = Concurrent threads within the same process (memory space)
Process = Parallel processes (independent instances of memory space)

Multithreading is recommended for GUI work.
Multiprocessing is recommended for I/O CPU bound work.

Posted by: @robo-pi

I'm launching raspivid from within the Tkinter GUI loop

Which appears to be spawning a new GUI each time the button is pressed, at least that's my experience when I run your code.

Posted by: @robo-pi

All I know is that it works.

The button works for me too, in every instance of the GUI...


ReplyQuote
Page 3 / 5