Active Topics

 


Reply
Thread Tools
Posts: 84 | Thanked: 76 times | Joined on Aug 2011
#1
So I saw this thread: http://talk.maemo.org/showpost.php?p...7&postcount=12
I want to make a shortcut of it so I tried to put it in a python script like this (and later create a .desktop file):

Code:
#!/usr/bin/python
import gst
bin = gst.element_factory_make("camerabin")
bin.set_property("videoenc", gst.element_factory_make("dspmp4venc"))
bin.set_property("videomux", gst.element_factory_make("hantromp4mux"))
bin.set_property("audioenc", gst.element_factory_make("nokiaaacenc"))
bin.set_state(gst.STATE_PLAYING)
bin.set_property("filename", "test.mp4")
bin.set_property("mode",1)
#starts recording
bin.emit("user-start")
And then chmod 755. But it doesn't work when I tried "python /path/to/script.py" in the terminal. The window did open but closed immediately. I know nothing about coding, just did it with some google searching. Can anyone help?

Last edited by LightRain; 2011-10-15 at 20:49.
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#2
This script wont work.
You have to remove this line
#start
And you need a way to stop the recording and change
the pipeline state to STATE_PAUSED

nicolai
 
Posts: 84 | Thanked: 76 times | Joined on Aug 2011
#3
Thanks for the reply. So I removed the line "#starts recording" but still it doesn't work. And with the same behaviour: the recording window show up and close immediately (I'm running the default kernel config)
If I can get this to work then I can make another shortcut to stop the recording later.

Edit: When I run the script as root it says "Home directory /home/user not ours" (not displayed when run as user). Does it have anything to do with anything?

Last edited by LightRain; 2011-10-16 at 04:46.
 
Posts: 84 | Thanked: 76 times | Joined on Aug 2011
#4
After a lot of struggles and searches I managed to get it to work. It's because the window is closed automatically after executing the command. I did some search and found the way to keep it open. So here it is for anyone need it.

#!/usr/bin/python
import gst
bin = gst.element_factory_make("camerabin")
bin.set_property("videoenc", gst.element_factory_make("dspmp4venc"))
bin.set_property("videomux", gst.element_factory_make("hantromp4mux"))
bin.set_property("audioenc", gst.element_factory_make("nokiaaacenc"))
bin.set_state(gst.STATE_PLAYING)
bin.set_property("filename", "test.mp4")
bin.set_property("mode",1)
bin.emit("user-start")
raw_input("Press enter to stop")
bin.emit("user-stop")
bin.set_state(gst.STATE_PAUSED)
bin.set_state(gst.STATE_NULL)

My next question is: Can we somehow hide the recording window, so it'll be more like a spycam?

Last edited by LightRain; 2011-10-16 at 12:50.
 
Posts: 87 | Thanked: 46 times | Joined on Nov 2010 @ lisbon, portugal
#5
This is part of a plugin in python I've made.

#START RECORDING

dtoday = datetime.date.today()
dnow = datetime.datetime.now()
if (dtoday.month<10):
mes="0" + str(dtoday.month)
else:
mes=str(dtoday.month)
if (dtoday.day<10):
dia="0" + str(dtoday.day)
else:
dia=str(dtoday.day)
if (dnow.hour<10):
hora="0" + str(dnow.hour)
else:
hora=str(dnow.hour)
if (dnow.minute<10):
minuto="0" + str(dnow.minute)
else:
minuto=str(dnow.minute)
if (dnow.second<10):
segundo="0" + str(dnow.second)
else:
segundo=str(dnow.second)


fname = 'VID_' +str(dtoday.year) + mes + dia +'_'+ hora + minuto + segundo +'.mp4'
cambin.set_property("videoenc", gst.element_factory_make("dspmp4venc"))
cambin.set_property("videomux", gst.element_factory_make("hantromp4mux"))
cambin.set_property("audioenc", gst.element_factory_make("nokiaaacenc"))
#cambin.set_property("video-capture-framerate", 0.20)
#cambin.set_property("video-capture-height", 480))
#cambin.set_property("video-capture-width", 427)
cambin.set_state(gst.STATE_PLAYING)
cambin.set_property("filename", videopath + fname)
cambin.set_property("mode",1)
cambin.emit("user-start")
self.isrecording=True
self.LASPOS=2
self.draw(self.e_vidstart,"2")
#using lfocus to prevent red led
#os.popen("/opt/lfocus/v4l2-ctl -c indicator_intensity=0")

#STOP RECORDING
cambin.emit("user-stop")
cambin.set_state(gst.STATE_PAUSED)
cambin.set_state(gst.STATE_NULL)
self.draw(self.e_vidstart,0)
self.LASPOS=0
self.isrecording=False



hope it helps
 

The Following User Says Thank You to trlopes1974 For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 09:48.