"Cannot allocate memory" in v4l2_ingest

376 views
Skip to first unread message

Christopher Peters

unread,
Jan 5, 2012, 12:07:49 PM1/5/12
to openreplay
So I've recently picked up one of the SAA7134-based capture cards
Andrew recommended: http://tinyurl.com/7kupvw7

And when I start up v4l2_ingest, I get:

"queue v4l2 buffer: Cannot allocate memory".

I poked around at it a bit with gdb, but nothing obvious popped out at
me. Command line:

"v4l2_ingest /dev/video1 /root/openreplay.buffer"

/root/openreplay.buffer is a 1G file created as specified in the
README. I also tried this on a 512M buffer with similar results.

Any ideas what might be causing this?

Hardware:

Dell Optiplex GX620
Pentium 4 HT 3.2 GHz processor
2 GB RAM
1 TB HDD

--
Kit Peters (W0KEH), Engineer II
KMOS TV Channel 6 / KTBG 90.9 FM
University of Central Missouri
http://kmos.org/ | http://ktbg.fm/

Andrew Armenia

unread,
Jan 6, 2012, 11:00:34 AM1/6/12
to openr...@googlegroups.com
You could try changing "n_buffers" from 32 to something smaller... it sounds like maybe you're running out of DMA-accessible address space. Maybe add a fprintf(stderr, "buffer %d\n", i) call around line 214 so you can get an idea of how many buffers (if any) it manages to allocate before failure?

-Andrew

Christopher Peters

unread,
Jan 6, 2012, 12:31:16 PM1/6/12
to openr...@googlegroups.com
I thought of that, and tried setting n_buffers to 1 in v4l2_ingest.cpp.  No luck.

It might be relevant to note that v4l2 detects the card I'm using as a generic saa7134-based card, and I can't get any video out of it using xawtv, vlc, or mythtv.

Kit

Andrew Armenia

unread,
Jan 9, 2012, 8:22:53 PM1/9/12
to openr...@googlegroups.com
My card didn't have an EEPROM and I had to edit the configuration. Check your 'dmesg' output for whining from the driver. I think I put something like 'options saa7134 card=33,33,33,33' in /etc/modprobe.d/saa7134_card (a new file I created) and that got it working.

For quickly testing whether or not the card is working, you can probably use mplayer: mplayer -tv device=/dev/videoX:norm=ntsc tv://
If you're interested, see man mplayer for more of the options (width, height, fps...) you can pass to -tv, and of course substitute 0, 1, etc. for the 'X'.

-Andrew

Christopher Peters

unread,
Jan 11, 2012, 9:45:27 AM1/11/12
to openr...@googlegroups.com
card=33,33,33,33 worked for me - I have video via XawTV. However,
v4l2_ingest still gives me:

queue v4l2 buffer: Cannot allocate memory

Thoughts?

On Mon, Jan 9, 2012 at 7:22 PM, Andrew Armenia <and...@asquaredlabs.com> wrote:
> My card didn't have an EEPROM and I had to edit the configuration. Check
> your 'dmesg' output for whining from the driver. I think I put something
> like 'options saa7134 card=33,33,33,33' in /etc/modprobe.d/saa7134_card (a
> new file I created) and that got it working.

Andrew Armenia

unread,
Jan 11, 2012, 10:47:21 AM1/11/12
to openr...@googlegroups.com
If you haven't already, check the tail end of 'dmesg' output for clues after it fails... if it's something going wrong in the driver, it'll show up there.

-Andrew

Christopher Peters

unread,
Jan 11, 2012, 10:50:57 AM1/11/12
to openr...@googlegroups.com
Nothing relevant in dmesg.

Note also that when I added code to tell me how many buffers
v4l2_ingest tried to allocate before it failed, it failed on buffer 0.

KP

On Wed, Jan 11, 2012 at 9:47 AM, Andrew Armenia <and...@asquaredlabs.com> wrote:
> If you haven't already, check the tail end of 'dmesg' output for clues after
> it fails... if it's something going wrong in the driver, it'll show up
> there.

--

Christopher Peters

unread,
Jan 11, 2012, 11:20:45 AM1/11/12
to openr...@googlegroups.com
I also compiled the capture example from
http://v4l2spec.bytesex.org/spec/capture-example.html. When I ran it
using IO_METHOD_USERPTR, I got the same error.

So why is IO_METHOD_USERPTR failing? I'll post a question to
linux-media as well.

KP

Christopher Peters

unread,
Jan 11, 2012, 11:40:32 AM1/11/12
to openr...@googlegroups.com
Response from one poster on linux-media:

[quote]
On Wed, Jan 11, 2012 at 11:28 AM, Christopher Peters <cpe...@ucmo.edu> wrote:
> So as I said in my previous email, I got video out of my card. Now
> I'm trying to capture video using a piece of software called
> "openreplay". Its v4l2 capture code is based heavily on the capture
> example at http://v4l2spec.bytesex.org/spec/capture-example.html, so I
> thought I'd try compiling the example code to see what I got.
>
> When I ran the capture example with this command-line: "
> ./capture_example -u" (to use application allocated buffers) I got:
>
> "VIDIOC_QBUF error 12, Cannot allocate memory"
>
> I'm running Mythbuntu 11.10, Ubuntu kernel 3.0.0-14-generic. All
> CONFIG_*V4L* options are set to 'y' or 'm', and all modules matching
> "v4l2-*" are loaded.
>
> What do I need to do to make application allocated buffers work?

USERPTR buffers don't work with many drivers (for example, those that
use videobuf-vmalloc). You should use the mmap method, which is
supported by every card I can think of.
[/quote]

KP

Christopher Peters

unread,
Jan 11, 2012, 11:42:30 AM1/11/12
to openr...@googlegroups.com
One more thing: I compiled the userptr test example from
http://linuxtv.org/downloads/v4l-dvb-apis/userp.html and it told me
that user pointer streaming was not supported by the driver.

Andrew Armenia

unread,
Jan 11, 2012, 1:31:34 PM1/11/12
to openr...@googlegroups.com
The version of v4l2_ingest in the "untested" branch uses mmap IO, and is not as untested as the branch name would imply. In fact, there's quite a bit in there that probably should have been merged into master, so you may want to just switch to that branch. Sorry about the confusion...

-Andrew

Christopher Peters

unread,
Jan 11, 2012, 2:41:20 PM1/11/12
to openr...@googlegroups.com
After compiling v4l2_ingest from the "untested" branch, I got past the
"couldn't allocate memory" error. Now it dies with the error:

terminate called after throwing an instance of 'std::runtime_error'
what(): Failed to open data file

I tracked that down to line 261 of v4l2_ingest.cpp ("untested"
branch): "MmapState clock_ipc("clock_ipc");". Should I be
initializing MmapState with the data file, or do I need to create a
"clock_ipc" file? If the latter, what does that file need to look
like?

Andrew Armenia

unread,
Jan 11, 2012, 2:48:26 PM1/11/12
to openr...@googlegroups.com
Just make a blank 1M file with 'dd if=/dev/zero of=clock_ipc bs=1M count=1'. That file can be used to pull a scoreboard clock into the replay system, but that feature is kind of unfinished.

-Andrew
Reply all
Reply to author
Forward
0 new messages