USB Streaming with ffmpeg


Streaming with the pi camera seemed fairly easy. I will also be adding this to motion to test if it works from there, but for now a straight command line seems to work streaming directly to youtube using the usb webcam and the usb camera microphone.

ffmpeg -f alsa -ac 2 -i hw:1 -f v4l2 -s 1920x1080 -r 30 -input_format h264 -i /dev/video0 -vcodec copy -r 15 -g 30 -b:v 3000k -ar 44100 -threads 6 -b:a 96k -bufsize 3000k -f flv rtmp://

The problem I had was the audio. On the first -f I added alsa and then the first -i I put hw,1.

I found the audio recording device of my usb camera by typing:
arecord -l
This gave me the audio device of the camera. You may have more than one, but my pi only has the usb camera mic.
**** List of CAPTURE Hardware Devices ****
card 1: C920 [HD Pro Webcam C920], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

Once I had this I was fairly sure that the hw device would be 1.

You can find your usb devices by typing
Bus 001 Device 006: ID 046d:082d Logitech, Inc. HD Pro Webcam C920
Bus 001 Device 005: ID 046d:c408 Logitech, Inc. Marble Mouse (4-button)
Bus 001 Device 004: ID 04f3:0103 Elan Microelectronics Corp. ActiveJet K-2024 Multimedia Keyboard
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

-6.1193329,39.1580149,05-20-2019 01:21:46 AM,!On a treasure hunt