Reply
Thread Tools
nicholes's Avatar
Posts: 1,086 | Thanked: 354 times | Joined on Oct 2010 @ india, indore
#1
Hi,
I want to use N900 as a third empire video rec. of a cricket match. to do this somehow N900 should keep video record of last two or three minute only .rest should be delete so thus whatever happens in the match recently (just two minute before) i can see reply of it. i hope i have present what i want in good words.(actually my English is not good)

video rec. SOLVED:- here is how to do this

you need rootsh and leafpad installed

open leafpad and paste the code

Thanks to skykooler and int_ua for their hard work

Code:
#!/usr/bin/env python
import gst
import time
import os

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"))

while True:
    bin.set_state(gst.STATE_PLAYING)
    bin.set_property("filename", "current.mp4")
    bin.set_property("mode",1)
    #starts recording
    bin.emit("user-start")

    time.sleep(60)

    # stops recording
    bin.emit("user-stop")
    bin.set_state(gst.STATE_PAUSED)
    bin.set_state(gst.STATE_NULL)
    try:
        os.remove("twominutesold.mp4")
    except OSError:
        print "No two-minutes-old file exists yet."
    try:
        os.rename("oneminuteold.mp4", "twominutesold.mp4")
    except OSError:
        print "No one-minute-old file exists yet."
    os.rename("current.mp4", "oneminuteold.mp4")
Now save it as record.py

now open your camera shutter and close camera app.

go to xterminal and type sudo gainroot and go to directory where you saved record.py and type

Code:
chmod 755 record.py; ./record.py
the video is saved in home/user
__________________
N900 gave me a reason to live in this cruel world

get your smooth live wallpaper today
My YouTube videos

Last edited by nicholes; 02-28-2012 at 12:54 AM.
 

The Following 2 Users Say Thank You to nicholes For This Useful Post:
int_ua's Avatar
Posts: 653 | Thanked: 1,004 times | Joined on Jul 2010 @ Kyiv, Ukraine
#2
That's an interesting question. As a workaround (but not solution) I can propose to record 1 minute intervals with sh script and drop all except last N of them. But, again, it's just the first thing that comes to my mind. Will look through gst sinks.
__________________
I reckon current Russian government as fascist threat and everyone who supports it as my personal enemies. If you are one of those, prepend the info to anything else.
 

The Following User Says Thank You to int_ua For This Useful Post:
int_ua's Avatar
Posts: 653 | Thanked: 1,004 times | Joined on Jul 2010 @ Kyiv, Ukraine
#3
Maybe leaky queue?..
__________________
I reckon current Russian government as fascist threat and everyone who supports it as my personal enemies. If you are one of those, prepend the info to anything else.
 

The Following User Says Thank You to int_ua For This Useful Post:
nicholes's Avatar
Posts: 1,086 | Thanked: 354 times | Joined on Oct 2010 @ india, indore
#4
Originally Posted by int_ua View Post
Maybe leaky queue?..
is there anything which a noob can understand?
__________________
N900 gave me a reason to live in this cruel world

get your smooth live wallpaper today
My YouTube videos
 
Posts: 468 | Thanked: 520 times | Joined on Oct 2010
#5
Originally Posted by nicholes View Post
is there anything which a noob can understand?
The shell script idea seems pretty simple. Unfortunately I don't know enough of gstreamer to completely work it out. Here's my take (two scripts):

update.sh:
Code:
#!/bin/bash
rm twominutesold.avi
mv oneminuteold.avi twominutesold.avi
mv current.avi oneminuteold.avi
(crazy gstreamer stuff to record a minute of video to current.avi)
record.sh:
Code:
#!/bin/bash
watch -n 60 ./update.sh
Record.sh is what you run; every minute it runs update.sh, which deletes the oldest recording and starts a new one. Control-c stops and leaves you with between 2 and 3 minutes of the most recent video.

Anyone want to figure out the gstreamer command?
 

The Following 2 Users Say Thank You to skykooler For This Useful Post:
Posts: 478 | Thanked: 100 times | Joined on Feb 2010
#6
Would be a good idea for an app, could be used in cars too! keep recordings of any potential accident you may have...
 

The Following 3 Users Say Thank You to Spotfist For This Useful Post:
int_ua's Avatar
Posts: 653 | Thanked: 1,004 times | Joined on Jul 2010 @ Kyiv, Ukraine
#7
The gstreamer command was somewhere on the forums. nicholes, what about pycam that I've seen in your earlier thread? Can it be limited to 1 minute? However, there was pure sh code which is much much simpler.
__________________
I reckon current Russian government as fascist threat and everyone who supports it as my personal enemies. If you are one of those, prepend the info to anything else.
 
nicholes's Avatar
Posts: 1,086 | Thanked: 354 times | Joined on Oct 2010 @ india, indore
#8
Originally Posted by skykooler View Post
The shell script idea seems pretty simple. Unfortunately I don't know enough of gstreamer to completely work it out. Here's my take (two scripts):

update.sh:
Code:
#!/bin/bash
rm twominutesold.avi
mv oneminuteold.avi twominutesold.avi
mv current.avi oneminuteold.avi
(crazy gstreamer stuff to record a minute of video to current.avi)
record.sh:
Code:
#!/bin/bash
watch -n 60 ./update.sh
Record.sh is what you run; every minute it runs update.sh, which deletes the oldest recording and starts a new one. Control-c stops and leaves you with between 2 and 3 minutes of the most recent video.

Anyone want to figure out the gstreamer command?

can this help somehow?
__________________
N900 gave me a reason to live in this cruel world

get your smooth live wallpaper today
My YouTube videos
 

The Following User Says Thank You to nicholes For This Useful Post:
Posts: 468 | Thanked: 520 times | Joined on Oct 2010
#9
Originally Posted by nicholes View Post
can this help somehow?
Thanks! Here's a python script which should handle it by itself. To run:
Code:
chmod 755 record.py; ./record.py
record.py:
Code:
import gst
import time
import os

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"))

while True:
    bin.set_state(gst.STATE_PLAYING)
    bin.set_property("filename", "current.mp4")
    bin.set_property("mode",1)
    #starts recording
    bin.emit("user-start")

    time.sleep(60)

    # stops recording
    bin.emit("user-stop")
    bin.set_state(gst.STATE_PAUSED)
    bin.set_state(gst.STATE_NULL)
    try:
        os.remove("twominutesold.mp4")
    except OSError:
        print "No two-minutes-old file exists yet."
    try:
        os.rename("oneminuteold.mp4", "twominutesold.mp4")
    except OSError:
        print "No one-minute-old file exists yet."
    os.rename("current.mp4", "oneminuteold.mp4")

Last edited by skykooler; 02-24-2012 at 12:52 PM.
 

The Following 3 Users Say Thank You to skykooler For This Useful Post:
int_ua's Avatar
Posts: 653 | Thanked: 1,004 times | Joined on Jul 2010 @ Kyiv, Ukraine
#10
Great start
Just move STATE_PLAYING into while loop and fix prints, please
__________________
I reckon current Russian government as fascist threat and everyone who supports it as my personal enemies. If you are one of those, prepend the info to anything else.
 

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

Thread Tools

 
Forum Jump


All times are GMT -4. The time now is 06:11 AM.