Problems with recording video

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with recording video

Ian Davidson
I am trying to record video.  The recording time can be over an hour and if I try to record to a single file, the file can get too large.

I wrote a script to attempt to record a series of shorter videos - and then use Ctrl-C to stop recording when I wanted to finish.  Below is a simplified version of the script.
#!/bin/bash
fileNamePart="${HOME}/video"
v4l2-ctl -i 1
counter=0
while [ $counter -lt 100 ]; do
    let counter=counter+1
    fullFileName="${fileNamePart}-${counter}.avi"
    `gst-launch-1.0 v4l2src norm=PAL num-buffers=100 ! 'video/x-raw,format=(string)I420,width=352,height=288,framerate=(fraction)25/1' ! queue ! mux. alsasrc num-buffers=440 ! audioconvert ! 'audio/x-raw,rate=44100,channels=2' ! queue ! mux. avimux name=mux ! filesink location="$fullFileName"`

Note that this test version has the num-buffers set to 100 for the video source.  When I run this script for a short while, I get the following on the console
[ian@localhost ~]$ ./testScript
Video input set to 1 (Composite1: ok)
./testScript: line 8: Setting: command not found
./testScript: line 8: Setting: command not found
^C
[ian@localhost ~]$

The first video records without any comment, the second and subsequent attempts get that 'Setting: command not found' message.

The final video - the one that is terminated by the Ctrl-C - does not seem to have recorded the video properly.  When I try to view the videos, that final video does not display the actual material, just a 'filmstrip'.  If I carry the videos from my Linux box to a Windows machine, editors fail to open the final AVI file.

Thus far, two questions.
1) What is the meaning of that 'command not found'?
2) Why does the final video, terminated by Ctrl-C not work?

I then noticed that I have num-buffers on both the video and audio sources - so I removed the 'num-buffers=440' - but now the first video did not come to a natural end but waited until the Ctrl-C.

Third question. Do I need to have num-buffers on both sources?

Your help is appreciated.

Ian
--
--
Ian Davidson
239 Streetsbrook Road, Solihull, West Midlands, B91 1HE
--
Facts used in this message may or may not reflect an underlying objective reality. Facts are supplied for personal use only.
Recipients quoting supplied information do so at their own risk. Facts supplied may vary in whole or part from widely accepted standards.
While painstakingly researched, facts may or may not be indicative of actually occurring events or natural phenomena.
The author accepts no responsibility for personal loss or injury resulting from memorisation and subsequent use.

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problems with recording video

Ian Davidson
I missed a 'done' in my transcription of the script.  I have corrected the script below.

On 12/12/2012 16:13, Ian Davidson wrote:
I am trying to record video.  The recording time can be over an hour and if I try to record to a single file, the file can get too large.

I wrote a script to attempt to record a series of shorter videos - and then use Ctrl-C to stop recording when I wanted to finish.  Below is a simplified version of the script.
#!/bin/bash
fileNamePart="${HOME}/video"
v4l2-ctl -i 1
counter=0
while [ $counter -lt 100 ]; do
    let counter=counter+1
    fullFileName="${fileNamePart}-${counter}.avi"
    `gst-launch-1.0 v4l2src norm=PAL num-buffers=100 ! 'video/x-raw,format=(string)I420,width=352,height=288,framerate=(fraction)25/1' ! queue ! mux. alsasrc num-buffers=440 ! audioconvert ! 'audio/x-raw,rate=44100,channels=2' ! queue ! mux. avimux name=mux ! filesink location="$fullFileName"`
done

Note that this test version has the num-buffers set to 100 for the video source.  When I run this script for a short while, I get the following on the console
[ian@localhost ~]$ ./testScript
Video input set to 1 (Composite1: ok)
./testScript: line 8: Setting: command not found
./testScript: line 8: Setting: command not found
^C
[ian@localhost ~]$

The first video records without any comment, the second and subsequent attempts get that 'Setting: command not found' message.

The final video - the one that is terminated by the Ctrl-C - does not seem to have recorded the video properly.  When I try to view the videos, that final video does not display the actual material, just a 'filmstrip'.  If I carry the videos from my Linux box to a Windows machine, editors fail to open the final AVI file.

Thus far, two questions.
1) What is the meaning of that 'command not found'?
2) Why does the final video, terminated by Ctrl-C not work?

I then noticed that I have num-buffers on both the video and audio sources - so I removed the 'num-buffers=440' - but now the first video did not come to a natural end but waited until the Ctrl-C.

Third question. Do I need to have num-buffers on both sources?

Your help is appreciated.

Ian
--
--
Ian Davidson
239 Streetsbrook Road, Solihull, West Midlands, B91 1HE
--
Facts used in this message may or may not reflect an underlying objective reality. Facts are supplied for personal use only.
Recipients quoting supplied information do so at their own risk. Facts supplied may vary in whole or part from widely accepted standards.
While painstakingly researched, facts may or may not be indicative of actually occurring events or natural phenomena.
The author accepts no responsibility for personal loss or injury resulting from memorisation and subsequent use.


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

--
--
Ian Davidson
239 Streetsbrook Road, Solihull, West Midlands, B91 1HE
--
Facts used in this message may or may not reflect an underlying objective reality. Facts are supplied for personal use only.
Recipients quoting supplied information do so at their own risk. Facts supplied may vary in whole or part from widely accepted standards.
While painstakingly researched, facts may or may not be indicative of actually occurring events or natural phenomena.
The author accepts no responsibility for personal loss or injury resulting from memorisation and subsequent use.

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problems with recording video

Krzysztof Konopko
In reply to this post by Ian Davidson
Firstly, you have a Bash problem here. The back-ticks syntax will
execute whatever is between the back-ticks, take the result printed by
executing the content in the sub-process and interpret it as a command
in the top-level script (process) as it appears first on the line.

Example:
`echo ls`

will execute ls in the top-level script as echo prints "ls".

So whatever your gst-launch-1.0 prints out in the first loop will be
interpreted as a command to execute. That's probably not what you want.
Why do use use back-ticks at all?

Secondly, if you remove num-buffers from alsasrc it will keep generating
buffers so your first execution of gst-launch-1.0 will run until you
stop it.

Kris

On 12/12/12 16:13, Ian Davidson wrote:

> I am trying to record video.  The recording time can be over an hour and
> if I try to record to a single file, the file can get too large.
>
> I wrote a script to attempt to record a series of shorter videos - and
> then use Ctrl-C to stop recording when I wanted to finish.  Below is a
> simplified version of the script.
> #!/bin/bash
> fileNamePart="${HOME}/video"
> v4l2-ctl -i 1
> counter=0
> while [ $counter -lt 100 ]; do
>     let counter=counter+1
>     fullFileName="${fileNamePart}-${counter}.avi"
>     `gst-launch-1.0 v4l2src norm=PAL num-buffers=100 !
> 'video/x-raw,format=(string)I420,width=352,height=288,framerate=(fraction)25/1'
> ! queue ! mux. alsasrc num-buffers=440 ! audioconvert !
> 'audio/x-raw,rate=44100,channels=2' ! queue ! mux. avimux name=mux !
> filesink location="$fullFileName"`
>
> Note that this test version has the num-buffers set to 100 for the video
> source.  When I run this script for a short while, I get the following
> on the console
> [ian@localhost ~]$ ./testScript
> Video input set to 1 (Composite1: ok)
> ./testScript: line 8: Setting: command not found
> ./testScript: line 8: Setting: command not found
> ^C
> [ian@localhost ~]$
>
> The first video records without any comment, the second and subsequent
> attempts get that 'Setting: command not found' message.
>
> The final video - the one that is terminated by the Ctrl-C - does not
> seem to have recorded the video properly.  When I try to view the
> videos, that final video does not display the actual material, just a
> 'filmstrip'.  If I carry the videos from my Linux box to a Windows
> machine, editors fail to open the final AVI file.
>
> Thus far, two questions.
> 1) What is the meaning of that 'command not found'?
> 2) Why does the final video, terminated by Ctrl-C not work?
>
> I then noticed that I have num-buffers on both the video and audio
> sources - so I removed the 'num-buffers=440' - but now the first video
> did not come to a natural end but waited until the Ctrl-C.
>
> Third question. Do I need to have num-buffers on both sources?
>
> Your help is appreciated.
>
> Ian
> --
> --
> Ian Davidson
> /239 Streetsbrook Road, Solihull, West Midlands, B91 1HE/
> --
> Facts used in this message may or may not reflect an underlying
> objective reality. Facts are supplied for personal use only.
> Recipients quoting supplied information do so at their own risk. Facts
> supplied may vary in whole or part from widely accepted standards.
> While painstakingly researched, facts may or may not be indicative of
> actually occurring events or natural phenomena.
> The author accepts no responsibility for personal loss or injury
> resulting from memorisation and subsequent use.
>
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problems with recording video

Tim-Philipp Müller-2
In reply to this post by Ian Davidson
On Wed, 2012-12-12 at 16:13 +0000, Ian Davidson wrote:

Hi Ian,

> I wrote a script to attempt to record a series of shorter videos - and
> then use Ctrl-C to stop recording when I wanted to finish.  Below is a
> simplified version of the script.
> #!/bin/bash
> fileNamePart="${HOME}/video"
> v4l2-ctl -i 1
> counter=0
> while [ $counter -lt 100 ]; do
>     let counter=counter+1
>     fullFileName="${fileNamePart}-${counter}.avi"
>     `gst-launch-1.0 v4l2src norm=PAL num-buffers=100 !
> 'video/x-raw,format=(string)I420,width=352,height=288,framerate=(fraction)25/1' ! queue ! mux. alsasrc num-buffers=440 ! audioconvert ! 'audio/x-raw,rate=44100,channels=2' ! queue ! mux. avimux name=mux ! filesink location="$fullFileName"`
>
> Note that this test version has the num-buffers set to 100 for the
> video source.  When I run this script for a short while, I get the
> following on the console
> [ian@localhost ~]$ ./testScript
> Video input set to 1 (Composite1: ok)
> ./testScript: line 8: Setting: command not found
> ./testScript: line 8: Setting: command not found

This is probably because of the `gst-launch-1.0 ...` backticks. I don't
see why you use them here. What happens is probably that gst-launch-1.0
prints 'Setting pipeline to PAUSED state' or so, and that output is
passed to the shell which tries to interpret it as a command.


> The first video records without any comment, the second and subsequent
> attempts get that 'Setting: command not found' message.
>
> The final video - the one that is terminated by the Ctrl-C - does not
> seem to have recorded the video properly.  When I try to view the
> videos, that final video does not display the actual material, just a
> 'filmstrip'.  If I carry the videos from my Linux box to a Windows
> machine, editors fail to open the final AVI file.
>
> Thus far, two questions.
> 1) What is the meaning of that 'command not found'?
> 2) Why does the final video, terminated by Ctrl-C not work?

Pass -e to gst-launch-1.0 to make sure muxers can finalize file headers
properly when you press control-C.

Cheers
 -Tim

> I then noticed that I have num-buffers on both the video and audio
> sources - so I removed the 'num-buffers=440' - but now the first video
> did not come to a natural end but waited until the Ctrl-C.
>
> Third question. Do I need to have num-buffers on both sources?
>
> Your help is appreciated.
>
> Ian
> --
> --
> Ian Davidson
> 239 Streetsbrook Road, Solihull, West Midlands, B91 1HE
> --
> Facts used in this message may or may not reflect an underlying
> objective reality. Facts are supplied for personal use only.
> Recipients quoting supplied information do so at their own risk. Facts
> supplied may vary in whole or part from widely accepted standards.
> While painstakingly researched, facts may or may not be indicative of
> actually occurring events or natural phenomena.
> The author accepts no responsibility for personal loss or injury
> resulting from memorisation and subsequent use.
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problems with recording video

mattes
In reply to this post by Ian Davidson
> 2) Why does the final video, terminated by Ctrl-C not work?

use gst-launch -e

Uhis will send and EOS down the pipeline, notfiying all
elements and allowing to properly close


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel