How to get non-decoded h264 stream from the webcam using ffmpeg?

I want to get the file which is non-decoded h264 format to use in another client application. I know how to stream to disk using below command from the docs.

Example to encode video from /dev/video0:

ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mp4

High level Diagram

This is typical producer and consumer problem -

Webcam  =============> ffmpeg to  video stream into file. (producer)                                    
Client ________________________________|
// reads only Non-decoded h264 format from a file. 

2 answers

  • answered 2018-03-14 06:16 Mulvya


    ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mp4 -c copy out.h264

    out.h264 is the received H264 bitstream, saved as a file.

  • answered 2018-03-14 18:30 air

    I found this as solution

    ffmpeg  -pix_fmt yuv420p -y -f v4l2 -vcodec h264  -i /dev/video0 out.h264