How to get non-decoded h264 stream from the webcam using ffmpeg? - 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.

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.

I found this as solution
ffmpeg -pix_fmt yuv420p -y -f v4l2 -vcodec h264 -i /dev/video0 out.h264

Related

Extracting frames from video while recording using ffmpeg

I am using ffmpeg to record a video using a Raspberry Pi with its camera module.
I would like to run a image classifier on a regular interval for which I need to extract a frame from the stream.
This is the command I currently use for recording:
$ ffmpeg -f video4linux2 -input_format h264 -video_size 1280x720 -framerate 30 -i /dev/video0 -vcodec copy -an test.h264
In other threads this command is recommended:
ffmpeg -i file.mpg -r 1/1 $filename%03d.bmp
I don't think this is intended to be used with files that are still appended to and I get the error "Cannot use -sseof, duration of test.h264 not known".
Is there any way that ffmpeg allows this?
I don't have a Raspberry Pi set up with a camera at the moment to test with, but you should be able to simply append a second output stream to your original command, as follows to get, say, 1 frame/second of BMP images:
ffmpeg -f video4linux2 -input_format h264 -video_size 1280x720 -framerate 30 -i /dev/video0 -vcodec copy -an test.h264 -r 1 frame-%03d.bmp

Command to stream MPEG-1 video

I'm trying to stream MPEG-1 video over FFMPEG with
ffmpeg -i "out.ts" -f flv -listen 1 -i rtmp://localhost:8889/live/app -c copy -f flv -listen 1 rtmp://localhost:1935/live/app
The out.ts file is a MPEG-1 video encoded with
ffmpeg -i out.avi -f mpegts -codec:v mpeg1video -b:v 1500k -r 30 -bf 0 -codec:a mp2 -b 0 -q 5 -t 1 out.ts
When I try to open the stream with VLC: rtmp://localhost:1935/live/app media is not playing. What's the command to stream MPEG-1 video over FFMPEG?
RTMP does not have support for mpeg1 video or mpeg2 audio. You can see the complete list if supported code in the fly specification under the VIDEODATA header.
https://www.adobe.com/content/dam/acom/en/devnet/flv/video_file_format_spec_v10.pdf
To stream MPEG-1 video using ffmpeg:
ffmpeg -re -y -i out.ts -an -f rtp_mpegts rtp://127.0.0.1:1234
Credit to: https://ffmpeg.org/pipermail/ffmpeg-user/2015-October/028879.html
(Although the source video is 720p, the stream in VLC looks like 360p and no audio is streamed, any idea would be appreciated)

ffmpeg raw video over udp

I am trying to stream desktop with as little latency as possible I am using this command to stream
ffmpeg -sn -f avfoundation -i '1' -r 10 -vf scale=1920x1080 -tune zerolatency -f rawvideo udp://224.3.0.11:5000
and for client side this command
ffplay -f rawvideo -pixel_format uyvy422 -framerate 10 -video_size 1920x1080 -fs -i udp://224.3.0.11:5000
The issue I am having is shown in this screenshoot here from the client side does anyone know what I can do to stop this issue?
Because of UDP.
UDP is an unordered protocol. Hence the video decoder did not receive the video packets in the correct order - causing the glitch in your video stream.

Seek issue of HEVC streams with ffplay

I'm attempting to perform a seek operation in an MPEG-TS stream that contains a HEVC encoded bit stream. The HEVC stream is encoded using the following command;
ffmpeg -s:v 1920x1080 -i kimono.yuv -c:v libx265 -x265-params crf=23:fps=30:keyint=10:min-keyint=10 -c:a copy -f mpegts testhevc.ts
The seek operation is attempted with ffplay as;
ffplay testhevc.ts -ss 5 -vf showinfo
The information shown gives multiple initial errors with missing POCs, such as;
Could not find ref with POC 126
However, everything works fine when the same operation is performed with H.264. The encoding with H.264/AVC is performed as;
ffmpeg -s:v 1920x1080 -i kimono.yuv -c:v libx265 -c:v libx264 -crf 23 -r 30 -keyint_min 10 -g 10 -c:a copy -f mpegts testh264.ts
Is this an issue with the ffmpeg tools for HEVC or am I missing something in these commands?.
Thanks.

Stream with FFMpeg with a Decklink card on Windows

I am trying to capture with ffmpeg the output from a Decklink Studio card on Windows, how would this be done? Is this even possible?
ffmpeg -video_size 720x576 -rtbufsize 702000k -framerate 60 -pixel_format uyvy422 -framerate 25 -f dshow -i video="Decklink Video Capture":audio="Decklink Audio Capture" -format x264 -an -b:v 1200k -s 1280x720 -f flv "rtmp://yourURL/Key"
of course it depends on the streaming protocol.
Sure. You just need to use the DeckLink SDK.

Resources