How to access compressed stream from webcam using ffmpeg

I want to broadcast a live webcam using ffmpeg. My Logitech c920 webcam has a raw and compressed output stream. The command ffmpeg -f v4l2 -list_formats all -i /dev/video1

prints the following console output:

[video4linux2,v4l2 @ 0x26709e0] Raw       :   yuyv422 :     YUV 4:2:2 (YUYV) : 640x480 160x90 160x120 176x144 320x180 320x240 352x288 432x240 640x360 800x448 800x600 864x480 960x720 1024x576 1280x720 1600x896 1920x1080 2304x1296 2304x1536
[video4linux2,v4l2 @ 0x26709e0] Compressed:      h264 :                H.264 : 640x480 160x90 160x120 176x144 320x180 320x240 352x288 432x240 640x360 800x448 800x600 864x480 960x720 1024x576 1280x720 1600x896 1920x1080
[video4linux2,v4l2 @ 0x26709e0] Compressed:     mjpeg :                MJPEG : 640x480 160x90 160x120 176x144 320x180 320x240 352x288 432x240 640x360 800x448 800x600 864x480 960x720 1024x576 1280x720 1600x896 1920x1080

      

I would like to copy a compressed h264 image and send it to ffserver.

When I use this command ffmpeg -r 25 -f v4l2 -i /dev/video0 -c:v libx264 -b:v 2500k http://localhost:8090/feed1.ffm

, the program gets raw data and re-encodes it with h264 codec.

When I change -c:v libx264

to -c:v copy

I get an error because ffmpeg is trying to copy the original camera image.

How can I access the h264 compressed image and send it to the server?

+3


source to share


1 answer


FFmpeg has an input_format

option to specify the format of the input device. Try adding -input_format h264

as an input parameter for your command.



+2


source







All Articles