ajayramesh
ajayramesh

Reputation: 3774

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 ________________________________|
(consumer)
// reads only Non-decoded h264 format from a file. 

Upvotes: 0

Views: 2159

Answers (2)

ajayramesh
ajayramesh

Reputation: 3774

I found this as solution

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

Upvotes: 0

Gyan
Gyan

Reputation: 92928

Use

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.

Upvotes: 1

Related Questions