bbb
Posts: 55
Joined: Sat Jun 02, 2012 9:52 am

Re: Hardware H.264 Encode of Webcam

Sun Jun 30, 2013 4:57 pm

Hi All,

I have been working on using the Raspberry PI + USB device as an IP Web CAM - actual aim is stream over LAN to something like wirecast - however is a lot more examples of streaming to ustream around .. so going with this for know till I get the audio and video encoding side of things working first...

I was getting some crashes with the C code in the first example, so I started fresh with the example v4l_capture.c in the V4L2 sources + some of the OpenMAX examples that come with raspberry PI.

I've put together a 'raspiv4l.bin' - advantages are it detects the video resolution and frame rate from V4L interface and sets up the SW scaler and HW h264 encoder accordingly in code. So you can adjust the USB V4L parameters using v4l2-ctrl without having to constantly change hard coded values and recompile the C code :)

Please see attached code including example script 'stream.sh' for streaming to ustream - note you will need an ffmpeg compiled from recent GIT or snapshot source .. - see threads on using the raspberry pi and streaming for more info on this.
raspiv4l.tar.gz
Example code + stream.sh script
(6.36 KiB) Downloaded 648 times
Next thing I am working is getting h264 video + mp3 audio streaming working - very close just not reading audio quick enough and getting crackling due to audio breakup. - I have included my attempts so far in 'stream.sh'.

joantune
Posts: 7
Joined: Fri Aug 16, 2013 9:38 pm

Re: Hardware H.264 Encode of Webcam

Sat Aug 17, 2013 1:11 am

looeyc wrote: Hi Jamesh,
Thanks for your help! I am encoding H.264 with openmax at 25fps now! :lol:
I am so susuprised to be capable of reaching such a high performance! :o
Before your advice, I a lot of introductions about the RPi, and there is only the H.264 decoder mentioned, so I doubted there would be no encoder. Your reply save me a lot of time and energy, thank you again! :D
Best regards!
How? can you post your sample code?

25fps for which resolution?

Thanks!

crom
Posts: 1
Joined: Tue Oct 29, 2013 4:36 pm

Re: Hardware H.264 Encode of Webcam

Tue Oct 29, 2013 4:39 pm

Hi, thanks a lot for the code. :) I'm wondering if there is a way to control the maximum data rate of the encoded video for slow uploads?

tmlk
Posts: 2
Joined: Wed Jan 08, 2014 6:49 pm

Re: Hardware H.264 Encode of Webcam

Wed Jan 08, 2014 6:52 pm

@looeyc

According to your post, mind sharing some info on how to encode to h264 video from usb webcam?

Thanks in advance for your help.

Regards.

Eekay
Posts: 1
Joined: Fri Dec 05, 2014 9:54 am

Re: Hardware H.264 Encode of Webcam

Fri Dec 05, 2014 10:00 am

Does anyone still have the code fbutler posted last year? v4l2capturetoH264.c? Seems the link is down now :(

I'm looking into streaming video from a web cam to disk, I got some code working, but right now I'm just dumping each frame to file without compression. I have tried compressing and playing with ffmpeg but results are not good.

Return to “Graphics, sound and multimedia”