Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to record audio and video from a Kinect using avconv but I seem to have trouble specifying the right options.

avconv -f video4linux2 -video_size 640x480 -c:v h264 -c:a ac3 -i /dev/video1 test.mp4

results in:

avconv: /build/buildd/libav-extra-0.8.3ubuntu0.12.04.1/libav/libavutil/mathematics.c:79: av_rescale_rnd: Assertion `c > 0' failed.
Aborted (core dumped)

Cheese is perfectly happy recording the audio and video from the Kinect, so it's not a setup issue. For added fun, I also need to display the video at the same time.

share|improve this question

2 Answers 2

Correct avconv usage is:

avconv [global options] [input options] -i input [output options] output

You're putting all your options before your input, and so avconv is treating them all as input options. This would be better:

avconv -f video4linux2 -i /dev/video1 -s 640x480 -c:v libx264 -c:a ac3 test.mp4

The default settings may not be ideal for you; for libx264 you might want to set a -crf value (between 0 and 51, 23 is default, 18-28 is a sane range to use, lower=better quality, but bigger file) and a -preset (I normally use veryfast). For more information look here. Normally I'd recommend using VBR encoding for audio, but I don't really know about encoding AC3, so you may need to use a fixed bitrate (-b:a 192k will probably be OK for stereo sound).

Also, resizing the video may not be necessary, only use -s 640x480 if you need to shrink a larger input to that size.

As for viewing it as you're recording it, I can think of two solutions. The first is to simply open the file you are creating with your preferred video player software. This will mean a slight delay in viewing.

The second solution is to send a second output from avconv to stdout, and then use I/O redirection to input the information to a video player. This will be faster, but it will take about twice the processing power, since as it stands avconv can only do this by encoding a second time (this may change in the future).

avconv -f video4linux2 -i /dev/video1 -s 640x480 -c:v libx264 -c:a ac3 test.mp4 \
-s 640x480 -c:v libx264 -c:a ac3 -f mp4 - | vlc -

I'm using VLC as an example, but all the linux video players I know can do this. Since avconv normally determines what container format to use from the file extension, but - (stdout) doesn't have one, so you have to declare the container format with -f mp4.

share|improve this answer

I couldn't get the above method working, but I was able to get streamer working.

streamer -q -c /dev/video0 -f rgb24 -r 3 -t 00:30:00 -o ~/outfile.avi

I am also playing around with the Kinect. I haven't got audio working yet.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.