maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Multimedia (https://talk.maemo.org/forumdisplay.php?f=32)
-   -   [Solved] [Maemo 5] Keeping record of last two minute Audio/video recording? (https://talk.maemo.org/showthread.php?t=82561)

int_ua 2012-02-24 16:25

Re: [Maemo 5] Keeping record of last two minute video recording?
 
let's start garage project for this, I can't wait to post commits :)
Or some git*

int_ua 2012-02-24 16:33

Re: [Maemo 5] Keeping record of last two minute video recording?
 
But 3 seconds are lost on each video.

int_ua 2012-02-24 16:38

Re: [Maemo 5] Keeping record of last two minute video recording?
 
Maybe let's talk on #maemo@freenode?

skykooler 2012-02-24 16:53

Re: [Maemo 5] Keeping record of last two minute video recording?
 
Quote:

Originally Posted by int_ua (Post 1169257)
Great start :)
Just move STATE_PLAYING into while loop and fix prints, please :)

I fixed that.

nicholes 2012-02-24 17:34

Re: [Maemo 5] Keeping record of last two minute video recording?
 
Quote:

Originally Posted by skykooler (Post 1169248)
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")


is there anything which a noob can understand? i dont know what to do i just start xterminal and type

python

(after pressing enter)

should i paste your code (whole code) at once

or i should paste this only.....

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)

and then this.........

Code:


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

and what do you mean by saying this...


Code:

chmod 755 record.py; ./record.py
it says no such file or directory

skykooler 2012-02-24 17:48

Re: [Maemo 5] Keeping record of last two minute video recording?
 
Quote:

Originally Posted by nicholes (Post 1169305)
is there anything which a noob can understand? i dont know what to do i just start xterminal and type

python

(after pressing enter)

should i paste your code (whole code) at once

or i should paste this only.....

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)

and then this.........

Code:


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

and what do you mean by saying this...


Code:

chmod 755 record.py; ./record.py
it says no such file or directory

Copy the code I posted into a file called record.py. Then run:
Code:

chmod 755 record.py; ./record.py

nicholes 2012-02-24 18:07

Re: [Maemo 5] Keeping record of last two minute video recording?
 
2 Attachment(s)
Quote:

Originally Posted by skykooler (Post 1169312)
Copy the code I posted into a file called record.py. Then run:
Code:

chmod 755 record.py; ./record.py

i opened leafpad and paste your code and save it as record.py(in /home/user)

than i try to run it but first permission denied and import not found

so i sudo gainroot and than run it but still import not found

there are screen shot for you thanks in advance!

skykooler 2012-02-24 18:17

Re: [Maemo 5] Keeping record of last two minute video recording?
 
Oops, add
Code:

#!/usr/bin/env python
to the beginning of that file.

nicholes 2012-02-24 18:29

Re: [Maemo 5] Keeping record of last two minute video recording?
 
Quote:

Originally Posted by skykooler (Post 1169327)
Oops, add
Code:

#!/usr/bin/env python
to the beginning of that file.

Finally it works!

Thanks to all of you guys and devlopers.

speacial Thanks to skykooler and int_ua

int_ua 2012-02-24 20:13

Re: [Solved] [Maemo 5] Keeping record of last two minute video recording?
 
I just finished first attempt to get gst-launch working and queue works as expected with this code:
Code:

gst-launch v4l2src device=/dev/video0 ! queue leaky=upstream min-threshold-time=10000000000 ! autovideosink
(time in nanoseconds)
Now it would be great to try to use queue sink in the above python code instead of moving files :) That's all for today, I hope we will finish it tomorrow :)


All times are GMT. The time now is 15:33.

vBulletin® Version 3.8.8