Support #361

Simultanoues capture of mpg4, extended mpg4 and mjpeg

Added by Johannes Gajdosik 2 months ago. Updated 2 months ago.

Status:Closed Start:07/06/2010
Priority:Normal Due date:
Assigned to:Ben Collins % Done:

0%

Category:- Spent time: -
Target version:-

Description

According to the datasheet, the solo6010 chip should be capable of simultanous capture of
4*mpg4(D1) and 4*extendedmpg4 and 4*mjpeg
in full framerate.

I have used and studied the newest git sources of the driver, but I cannot figure out, how the simultaneous capturing is intended. To me it looks like that for one channel I can capture
eigther mpg4(D1) or extendedmpg4 or mjpeg.

I tried to simultanousely capture mjpeg and mpg4(D1) from the same channel. For mjpeg I call
mplayer -tv device=/dev/video1:outfmt=mjpeg tv://
and for mpg4(D1) I call my own testing application. When I start mplayer first, my application fails:
'VIDIOC_S_FMT error 16, Device or resource busy'.
When I start my application first, mplayer says
'v4l2: ioctl set format failed: Device or resource busy'.

Could you please be so kind and tell me what I am doing wrong.
Thanks, Johannes

History

Updated by Ben Collins 2 months ago

  • Status changed from New to Closed

Based on the card capabilities, and v4l2's own API, you can open a device more than once, but you cannot change the video format while a capture is already taking place.

Unfortunately, vlc, mplayer and most other v4l2 client apps will try to set the format before recording, and then fail if it cannot be set. This is wrong. If setting the format does not succeed (because of EBUSY in this case), it doesn't mean that the record will not work, it just means it will only record at whatever the device is already set at.

Using a basic v4l2 capture without calling set_format will work, and you can capture mp4, emp4 and mjpeg simultaneously. We are making use of this very feature internally in our own software.

Updated by Johannes Gajdosik 2 months ago

Thanks for the reply. Maybe some other users do not know the details of how to get simultanous mp4, emp4 and mjpeg on one channel, lets say /dev/video1. Therefore I give a short explanation.

The Solo6010 spec says, that mp4, emp4 and mjpeg on one channel must have the same width, height and fps.
Quality and GOP size may be different for mp4, emp4. VIDIOC_S_FMT is required for choosing whether to capture mp4, emp4 or mjpeg.

So you start the first app, open /dev/video1 and call VIDIOC_S_FMT with fmt.fmt.pix.pixelformat=V4L2_PIX_FMT_MJPEG; fmt.fmt.pix.width=352; fmt.fmt.pix.height=288(PAL).

Then you start the second app, also on /dev/video1, and call VIDIOC_S_FMT with fmt.fmt.pix.pixelformat=V4L2_PIX_FMT_MPEG; fmt.fmt.pix.width=352; fmt.fmt.pix.height=288(PAL); fmt.fmt.pix.priv = 0 for mpeg4 recording.

Then you start the third app on /dev/video1 (while the first and second apps are still running), and call VIDIOC_S_FMT with fmt.fmt.pix.pixelformat=V4L2_PIX_FMT_MPEG; fmt.fmt.pix.width=352; fmt.fmt.pix.height=288(PAL); fmt.fmt.pix.priv = 1 for mpeg4 extended recording.

Note that the VIDIOC_S_FMT do not fail, when you do not change width and height. This was the problem I had initially: mplayer(for mjpeg) and my app(for mpg4) used different picture sizes.

On my computer the extended mpg4 has a higher bitrate than the std mpg4, and weird green or magenta color artefacts in regions with changing image contents, but this is another story.

Updated by Ben Collins 2 months ago

I can confirm the artifacts on extended mpeg4 capture, which is why we haven't hyped it too much. I'm not sure of what the problem is. I also haven't checked into if the original solo driver had this same problem.

If you would like, you can open another issue on the Empg4 artifacting problem.

Thanks!

Also available in: Atom PDF