Skip to contentSkip to conversation

Capturing raw JPEG stream from webcam

DISCUSSION Basil Mohamed Gohar 3 participants 8 messages Mar 13, 2010 – Mar 17, 2010 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

I originally posted this to the video4linux mailing list, but I've since discovered that this is the appropriate place (or so I understand) for video4linux questions. My question is how can I capture the raw JPEG image stream (e.g., MJPEG) from my webcam, which reports through v4l2 that it is capable of. I am using the gst-launch cli to gstreamer, which confirms that my webcam has this capability:

Quoted 2 lines

image/jpeg, width=(int)640, height=(int)480, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }

And, indeed, I can capture using this capability, but the framerate is not at the specified rate, but at a much lower value (half or less). So, even if I specify 30fps, I get something less. I can capture the full 30fps when I use one of the yuv modes, though, so it's clearly capable of delivering that framerate.

My webcam is a Logitech QuickCam Pro 5000. The lsusb output is:

Quoted 1 line

046d:08ce Logitech, Inc. QuickCam Pro 5000

An example command line I try is as follows:

Quoted 2 lines

gst-launch-0.10 v4l2src device=/dev/video0 ! 'image/jpeg, width=640, height=480, framerate=30/1' ! jpegdec ! xvimagesink

Thank you in advance for any help!

Signature · 5 lines
      Basil Mohamed Gohar
[email protected]
http://www.basilgohar.com/blog
basilgohar on irc.freenode.net
GPG Key Fingerprint:  5AF4B362
#1 lore raw

Hi Basil,

Quoted 16 lines · On Saturday 13 March 2010 02:55:47 Basil Mohamed Gohar wrote:

I originally posted this to the video4linux mailing list, but I've since discovered that this is the appropriate place (or so I understand) for video4linux questions. My question is how can I capture the raw JPEG image stream (e.g., MJPEG) from my webcam, which reports through v4l2 that it is capable of. I am using the gst-launch cli to gstreamer,

which confirms that my webcam has this capability:

Quoted 2 lines

image/jpeg, width=(int)640, height=(int)480, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }

And, indeed, I can capture using this capability, but the framerate is not at the specified rate, but at a much lower value (half or less). So, even if I specify 30fps, I get something less. I can capture the full 30fps when I use one of the yuv modes, though, so it's clearly capable of delivering that framerate.

Quoted 6 lines

My webcam is a Logitech QuickCam Pro 5000. The lsusb output is:

Quoted 1 line

046d:08ce Logitech, Inc. QuickCam Pro 5000

An example command line I try is as follows:

Quoted 2 lines

gst-launch-0.10 v4l2src device=/dev/video0 ! 'image/jpeg, width=640, height=480, framerate=30/1' ! jpegdec ! xvimagesink

Have you tried disabling auto-exposure ? The camera is allowed to reduce the frame rate in low-light conditions if auto-exposure is turned on.

Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw
Quoted 2 lines · Laurent Pinchart

Hi Basil,

Hi Laurent!

Quoted 23 lines · On Saturday 13 March 2010 02:55:47 Basil Mohamed Gohar wrote:
Quoted 22 lines

I originally posted this to the video4linux mailing list, but I've since discovered that this is the appropriate place (or so I understand) for video4linux questions. My question is how can I capture the raw JPEG image stream (e.g., MJPEG) from my webcam, which reports through v4l2 that it is capable of. I am using the gst-launch cli to gstreamer,

which confirms that my webcam has this capability:

Quoted 3 lines

image/jpeg, width=(int)640, height=(int)480, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }

And, indeed, I can capture using this capability, but the framerate is not at the specified rate, but at a much lower value (half or less). So, even if I specify 30fps, I get something less. I can capture the full 30fps when I use one of the yuv modes, though, so it's clearly capable of delivering that framerate.

My webcam is a Logitech QuickCam Pro 5000. The lsusb output is:

Quoted 2 lines

046d:08ce Logitech, Inc. QuickCam Pro 5000

Quoted 9 lines
Quoted 5 lines

An example command line I try is as follows:

Quoted 3 lines

gst-launch-0.10 v4l2src device=/dev/video0 ! 'image/jpeg, width=640, height=480, framerate=30/1' ! jpegdec ! xvimagesink

Have you tried disabling auto-exposure ? The camera is allowed to reduce the frame rate in low-light conditions if auto-exposure is turned on.

Thanks for replying. I haven't actually tried this yet (I am currently at work), but I do not think this is the issue, because when I choose the YUV-style modes, I can capture at the full framerates. It's only when I select the image/jpeg mode that I get the lower framerates, despite explicitly requesting the higher ones.

I suppose it's not impossible that the camera is opting for different behavior depending on the mode of the request, but I think that is not likely the case. I do appreciate the suggestion, though, and I'll try it when I get home.

Meanwhile, does anyone else have any other ideas?

#3 lore raw

Hi Basil,

Quoted 34 lines · On Monday 15 March 2010 16:09:49 Basil Mohamed Gohar wrote:
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · On Saturday 13 March 2010 02:55:47 Basil Mohamed Gohar wrote:

I originally posted this to the video4linux mailing list, but I've since discovered that this is the appropriate place (or so I understand) for video4linux questions. My question is how can I capture the raw JPEG image stream (e.g., MJPEG) from my webcam, which reports through v4l2 that it is capable of. I am using the gst-launch cli to gstreamer,

which confirms that my webcam has this capability:

Quoted 2 lines

image/jpeg, width=(int)640, height=(int)480, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }

And, indeed, I can capture using this capability, but the framerate is not at the specified rate, but at a much lower value (half or less). So, even if I specify 30fps, I get something less. I can capture the full 30fps when I use one of the yuv modes, though, so it's clearly capable of delivering that framerate.

My webcam is a Logitech QuickCam Pro 5000. The lsusb output is:

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

046d:08ce Logitech, Inc. QuickCam Pro 5000

An example command line I try is as follows:

Quoted 2 lines

gst-launch-0.10 v4l2src device=/dev/video0 ! 'image/jpeg, width=640, height=480, framerate=30/1' ! jpegdec ! xvimagesink

Have you tried disabling auto-exposure ? The camera is allowed to reduce the frame rate in low-light conditions if auto-exposure is turned on.

Thanks for replying. I haven't actually tried this yet (I am currently at work), but I do not think this is the issue, because when I choose the YUV-style modes, I can capture at the full framerates. It's only when I select the image/jpeg mode that I get the lower framerates, despite explicitly requesting the higher ones.

Quoted 4 lines

I suppose it's not impossible that the camera is opting for different behavior depending on the mode of the request, but I think that is not likely the case. I do appreciate the suggestion, though, and I'll try it when I get home.

It could, but that indeed seems unlikely. The USB descriptors advertise 30fps in MJPEG mode. Unless the information is wrong (in which case this would be a firmware bug), 30fps should be achievable.

Quoted 1 line

Meanwhile, does anyone else have any other ideas?

Signature · 3 lines
Regards,

Laurent Pinchart
#4 lore raw

Message bounced the first time because I had HTML on. Here it is again.

I have the same camera (Logi 5000). There's an ordering issue of ioctl calls that you have to make to get the frame rate set properly. But I'm away from my home computer and code, so I can't quote the solution to you yet. I can't speak about gst-launch, but I do I recall fixing this exact bug in my own code.

I figured out the frame rate issue by examing the code to luvcview. That sample app can capture jpegs at 640x480x30fps no problem.

I'll post sample code to you later tonight.

----------------------------------------

Quoted 54 lines

From: [email protected]
To: [email protected]
Subject: Re: Capturing raw JPEG stream from webcam
Date: Mon, 15 Mar 2010 21:00:05 +0100
CC: [email protected]

Hi Basil,

Quoted 34 lines · On Monday 15 March 2010 16:09:49 Basil Mohamed Gohar wrote:
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · On Saturday 13 March 2010 02:55:47 Basil Mohamed Gohar wrote:

I originally posted this to the video4linux mailing list, but I've since discovered that this is the appropriate place (or so I understand) for video4linux questions. My question is how can I capture the raw JPEG image stream (e.g., MJPEG) from my webcam, which reports through v4l2 that it is capable of. I am using the gst-launch cli to gstreamer,

which confirms that my webcam has this capability:

Quoted 2 lines

image/jpeg, width=(int)640, height=(int)480, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }

And, indeed, I can capture using this capability, but the framerate is not at the specified rate, but at a much lower value (half or less). So, even if I specify 30fps, I get something less. I can capture the full 30fps when I use one of the yuv modes, though, so it's clearly capable of delivering that framerate.

My webcam is a Logitech QuickCam Pro 5000. The lsusb output is:

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

046d:08ce Logitech, Inc. QuickCam Pro 5000

An example command line I try is as follows:

Quoted 2 lines

gst-launch-0.10 v4l2src device=/dev/video0 ! 'image/jpeg, width=640, height=480, framerate=30/1' ! jpegdec ! xvimagesink

Have you tried disabling auto-exposure ? The camera is allowed to reduce the frame rate in low-light conditions if auto-exposure is turned on.

Thanks for replying. I haven't actually tried this yet (I am currently at work), but I do not think this is the issue, because when I choose the YUV-style modes, I can capture at the full framerates. It's only when I select the image/jpeg mode that I get the lower framerates, despite explicitly requesting the higher ones.

Quoted 4 lines

I suppose it's not impossible that the camera is opting for different behavior depending on the mode of the request, but I think that is not likely the case. I do appreciate the suggestion, though, and I'll try it when I get home.

It could, but that indeed seems unlikely. The USB descriptors advertise 30fps in MJPEG mode. Unless the information is wrong (in which case this would be a firmware bug), 30fps should be achievable.

Quoted 1 line

Meanwhile, does anyone else have any other ideas?

Quoted 8 lines

--
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

_________________________________________________________________
Lauren found her dream laptop. Find the PC that’s right for you.
http://www.microsoft.com/windows/choosepc/?ocid=ftp_val_wl_290

#5 lore raw
In reply to Laurent Pinchart

Hi Basil:

I ran the following command line with my Logitech 5000:

gst-launch-0.10 v4l2src device=/dev/video0 ! 'image/jpeg, width=640, height=480, framerate=30/1' ! multifilesink location=frame%.4d.jpg

I let it run for 5 seconds or so and then cancel it.  When done I had a bit more than 150+ frames on disk.  Clearly, I'm getting 30 frames per second.

I ran your command line below and compared with the equivalent command line of luvcview.  The weird thing is that luvcview shows nice smooth video with no blur (jpg was the format).  gst-launch at the same configuration just "seems" like a slower frame rate.  Then I dropped down the frame rate of both gst-launch and luvcview to 15fps.  gst-launch looked more like 7-8 fps.  luvcview looked fine.  Switching gst-launch to YUV was a noticeable improvement.

My guess is jpeg decoding mixed with xvimagesink is the issue.  More debuging.  Switching to YUV or the file renderer produces better results.  More debugging is needed.

Might be better to move this thread of discussion over to the GStreamer list.

Quoted 48 lines

From: [email protected]
To: [email protected]
Subject: Re: Capturing raw JPEG stream from webcam
Date: Mon, 15 Mar 2010 21:00:05 +0100
CC: [email protected]

Hi Basil,

Quoted 34 lines · On Monday 15 March 2010 16:09:49 Basil Mohamed Gohar wrote:
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · On Saturday 13 March 2010 02:55:47 Basil Mohamed Gohar wrote:

I originally posted this to the video4linux mailing list, but I've since discovered that this is the appropriate place (or so I understand) for video4linux questions. My question is how can I capture the raw JPEG image stream (e.g., MJPEG) from my webcam, which reports through v4l2 that it is capable of. I am using the gst-launch cli to gstreamer,

which confirms that my webcam has this capability:

Quoted 2 lines

image/jpeg, width=(int)640, height=(int)480, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }

And, indeed, I can capture using this capability, but the framerate is not at the specified rate, but at a much lower value (half or less). So, even if I specify 30fps, I get something less. I can capture the full 30fps when I use one of the yuv modes, though, so it's clearly capable of delivering that framerate.

My webcam is a Logitech QuickCam Pro 5000. The lsusb output is:

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

046d:08ce Logitech, Inc. QuickCam Pro 5000

An example command line I try is as follows:

Quoted 2 lines

gst-launch-0.10 v4l2src device=/dev/video0 ! 'image/jpeg, width=640, height=480, framerate=30/1' ! jpegdec ! xvimagesink

Have you tried disabling auto-exposure ? The camera is allowed to reduce the frame rate in low-light conditions if auto-exposure is turned on.

Thanks for replying. I haven't actually tried this yet (I am currently at work), but I do not think this is the issue, because when I choose the YUV-style modes, I can capture at the full framerates. It's only when I select the image/jpeg mode that I get the lower framerates, despite explicitly requesting the higher ones.

Quoted 4 lines

I suppose it's not impossible that the camera is opting for different behavior depending on the mode of the request, but I think that is not likely the case. I do appreciate the suggestion, though, and I'll try it when I get home.

Quoted 14 lines

It could, but that indeed seems unlikely. The USB descriptors advertise 30fps in MJPEG mode. Unless the information is wrong (in which case this would be a firmware bug), 30fps should be achievable.

Quoted 1 line

Meanwhile, does anyone else have any other ideas?

Signature · 7 lines
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits.
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009

#6 lore raw
Quoted 8 lines · John Selbie

Hi Basil:

I ran the following command line with my Logitech 5000:

gst-launch-0.10 v4l2src device=/dev/video0 ! 'image/jpeg, width=640, height=480, framerate=30/1' ! multifilesink location=frame%.4d.jpg

I let it run for 5 seconds or so and then cancel it. When done I had a bit more than 150+ frames on disk. Clearly, I'm getting 30 frames per second.

Thanks for helping me test this. Just out of curiosity, did you actually look at the individual files and see if they changed each frame? It's possible that it's writing 30 fps, but the video it is grabbing may not be 30 distinct frames per second. Testing this case might help us pin down the problem. I am, once again, at work, so I cannot test this until after I get home once again (about 8 hours from now!).

Quoted 2 lines

I ran your command line below and compared with the equivalent command line of luvcview. The weird thing is that luvcview shows nice smooth video with no blur (jpg was the format). gst-launch at the same configuration just "seems" like a slower frame rate. Then I dropped down the frame rate of both gst-launch and luvcview to 15fps. gst-launch looked more like 7-8 fps. luvcview looked fine. Switching gst-launch to YUV was a noticeable improvement.

I'd never heard of luvcview until you just mentioned it now! Here's the link for anyone else that might find this utility useful, as I'm sure I will:

http://www.quickcamteam.net/software/linux/v4l2-software/luvcview/

Quoted 4 lines

My guess is jpeg decoding mixed with xvimagesink is the issue. More debuging. Switching to YUV or the file renderer produces better results. More debugging is needed.

Might be better to move this thread of discussion over to the GStreamer list.

If luvcview did indeed operate at a higher/the expected fps, then that makes the most sense. I will wait until I have confirmed for myself, though, before I move on. But thank you, John, for taking the time out to help me figure out this problem! I'll post back here once I've done some testing myself.

Quoted 76 lines
Quoted 56 lines

From: [email protected]
To: [email protected]
Subject: Re: Capturing raw JPEG stream from webcam
Date: Mon, 15 Mar 2010 21:00:05 +0100
CC: [email protected]

Hi Basil,

Quoted 39 lines · On Monday 15 March 2010 16:09:49 Basil Mohamed Gohar wrote:
Quoted 23 lines · Laurent Pinchart
Quoted 21 lines · On Saturday 13 March 2010 02:55:47 Basil Mohamed Gohar wrote:

I originally posted this to the video4linux mailing list, but I've since discovered that this is the appropriate place (or so I understand) for video4linux questions. My question is how can I capture the raw JPEG image stream (e.g., MJPEG) from my webcam, which reports through v4l2 that it is capable of. I am using the gst-launch cli to gstreamer,

which confirms that my webcam has this capability:

Quoted 3 lines

image/jpeg, width=(int)640, height=(int)480, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }

And, indeed, I can capture using this capability, but the framerate is not at the specified rate, but at a much lower value (half or less). So, even if I specify 30fps, I get something less. I can capture the full 30fps when I use one of the yuv modes, though, so it's clearly capable of delivering that framerate.

My webcam is a Logitech QuickCam Pro 5000. The lsusb output is:

Quoted 2 lines

046d:08ce Logitech, Inc. QuickCam Pro 5000

Quoted 8 lines
Quoted 5 lines

An example command line I try is as follows:

Quoted 3 lines

gst-launch-0.10 v4l2src device=/dev/video0 ! 'image/jpeg, width=640, height=480, framerate=30/1' ! jpegdec ! xvimagesink

Have you tried disabling auto-exposure ? The camera is allowed to reduce the frame rate in low-light conditions if auto-exposure is turned on.

Thanks for replying. I haven't actually tried this yet (I am currently at work), but I do not think this is the issue, because when I choose the YUV-style modes, I can capture at the full framerates. It's only when I select the image/jpeg mode that I get the lower framerates, despite explicitly requesting the higher ones.

Quoted 5 lines

I suppose it's not impossible that the camera is opting for different behavior depending on the mode of the request, but I think that is not likely the case. I do appreciate the suggestion, though, and I'll try it when I get home.

Quoted 16 lines

It could, but that indeed seems unlikely. The USB descriptors advertise 30fps in MJPEG mode. Unless the information is wrong (in which case this would be a firmware bug), 30fps should be achievable.

Quoted 2 lines

Meanwhile, does anyone else have any other ideas?

Signature · 7 lines
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits.
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009

#7 lore raw
In reply to John Selbie
Quoted 6 lines · John Selbie

Hi Basil:

I ran the following command line with my Logitech 5000:

gst-launch-0.10 v4l2src device=/dev/video0 ! 'image/jpeg, width=640, height=480, framerate=30/1' ! multifilesink location=frame%.4d.jpg

Quoted 8 lines

I let it run for 5 seconds or so and then cancel it. When done I had a bit more than 150+ frames on disk. Clearly, I'm getting 30 frames per second.

I ran your command line below and compared with the equivalent command line of luvcview. The weird thing is that luvcview shows nice smooth video with no blur (jpg was the format). gst-launch at the same configuration just "seems" like a slower frame rate. Then I dropped down the frame rate of both gst-launch and luvcview to 15fps. gst-launch looked more like 7-8 fps. luvcview looked fine. Switching gst-launch to YUV was a noticeable improvement.

My guess is jpeg decoding mixed with xvimagesink is the issue. More debuging. Switching to YUV or the file renderer produces better results. More debugging is needed.

Might be better to move this thread of discussion over to the GStreamer list.

John,

Thanks for all your help and giving me some leads. I've come to basically the same conclusion as you. ds over in #gstreamer advised me to use sync=false on the xvimagesink element, which allowed it to play the live, JPEG-encoded video at the full framerate. Also, capturing to files was not affected at all - can capture to the full 30fps to individual files or into one file (e.g., an MJPEG AVI file). So, the problem is pretty-much resolved as far as I'm concerned.

Quoted 76 lines
Quoted 56 lines

From: [email protected]
To: [email protected]
Subject: Re: Capturing raw JPEG stream from webcam
Date: Mon, 15 Mar 2010 21:00:05 +0100
CC: [email protected]

Hi Basil,

Quoted 39 lines · On Monday 15 March 2010 16:09:49 Basil Mohamed Gohar wrote:
Quoted 23 lines · Laurent Pinchart
Quoted 21 lines · On Saturday 13 March 2010 02:55:47 Basil Mohamed Gohar wrote:

I originally posted this to the video4linux mailing list, but I've since discovered that this is the appropriate place (or so I understand) for video4linux questions. My question is how can I capture the raw JPEG image stream (e.g., MJPEG) from my webcam, which reports through v4l2 that it is capable of. I am using the gst-launch cli to gstreamer,

which confirms that my webcam has this capability:

Quoted 3 lines

image/jpeg, width=(int)640, height=(int)480, framerate=(fraction){ 30/1, 25/1, 20/1, 15/1, 10/1, 5/1 }

And, indeed, I can capture using this capability, but the framerate is not at the specified rate, but at a much lower value (half or less). So, even if I specify 30fps, I get something less. I can capture the full 30fps when I use one of the yuv modes, though, so it's clearly capable of delivering that framerate.

My webcam is a Logitech QuickCam Pro 5000. The lsusb output is:

Quoted 2 lines

046d:08ce Logitech, Inc. QuickCam Pro 5000

Quoted 8 lines
Quoted 5 lines

An example command line I try is as follows:

Quoted 3 lines

gst-launch-0.10 v4l2src device=/dev/video0 ! 'image/jpeg, width=640, height=480, framerate=30/1' ! jpegdec ! xvimagesink

Have you tried disabling auto-exposure ? The camera is allowed to reduce the frame rate in low-light conditions if auto-exposure is turned on.

Thanks for replying. I haven't actually tried this yet (I am currently at work), but I do not think this is the issue, because when I choose the YUV-style modes, I can capture at the full framerates. It's only when I select the image/jpeg mode that I get the lower framerates, despite explicitly requesting the higher ones.

Quoted 5 lines

I suppose it's not impossible that the camera is opting for different behavior depending on the mode of the request, but I think that is not likely the case. I do appreciate the suggestion, though, and I'll try it when I get home.

Quoted 16 lines

It could, but that indeed seems unlikely. The USB descriptors advertise 30fps in MJPEG mode. Unless the information is wrong (in which case this would be a firmware bug), 30fps should be achievable.

Quoted 2 lines

Meanwhile, does anyone else have any other ideas?

Signature · 7 lines
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits.
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009

Signature · 5 lines
      Basil Mohamed Gohar
[email protected]
http://www.basilgohar.com/blog
basilgohar on irc.freenode.net
GPG Key Fingerprint:  5AF4B362