FFmpeg Commands

Make FastStart MP4 for internet video

ffmpeg -i in.mp4 -vcodec copy -movflags faststart out.mp4

RTSP to RTMP

ffmpeg -rtsp_transport tcp -i rtsp://user:password@localhost:554/rtsp -vcodec copy -f flv -r 25 -s 1920x1080 -an "rtmp://localhost/rtmp"

-an: Disable audio

-f: Force format

-r: Frame rate

-s: Video resolution

-vcodec: Set the video codec. "copy" means no decoding/encoding.

RTSP to HLS

ffmpeg -rtsp_transport tcp -i rtsp://user:password@localhost:554/rtsp -c:a libmp3lame -b:a 64k -c:v copy -f hls -hls_flags delete_segments -hls_time 1 -hls_list_size 5 -hls_segment_filename live%05d.ts live.m3u8

-hls_time: duration of each segment

-hls_list_size: number of segments to keep

-hls_flags delete_segments: delete outdated segments

Note: for Windows you need to escape % by putting ^ in front of it, as in live^%05d.ts.

Capture RTSP video stream

ffmpeg -rtsp_transport tcp -i rtsp://user:password@localhost:554/rtsp -vcodec copy -an cap.mp4

-rtsp_transport: Specify RTSP transport protocol, TCP is more reliable and supports large frames

-vcodec: copy the original video codec