Skip to content

Instantly share code, notes, and snippets.

@acceptableEngineering
Last active July 13, 2024 17:44
Show Gist options
  • Select an option

  • Save acceptableEngineering/ba6062358e081196360b941ac93da7fc to your computer and use it in GitHub Desktop.

Select an option

Save acceptableEngineering/ba6062358e081196360b941ac93da7fc to your computer and use it in GitHub Desktop.
Video Engineering (Command Line) Tricks

Description

These are FFmpeg commands I use on a regular basis and rather than keeping them to myself I figured it'd be good to share!

For the sake of simplicity, the filenames I use in the examples below are in.mp4 and out.mp4, though you can use your imagination to picture blah.mov or audio.wav on a case-by-case basis:


Media Conversion

High-Quality, Infinitely Looping GIF from MP4

ffmpeg -i input.mp4 -vf "fps=12,scale=720:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif

Convert FLV to MP4 without full re-encode

ffmpeg -i in.flv -vcodec copy out.mp4

Adjustments / Processing

Boost audio level (volume) without re-encoding

ffmpeg -i in.mp4 -vcodec copy -af "volume=10dB" out.mp4

Delay audio

ffmpeg -i "in.mp4" -itsoffset 0.3 -i "in.mp4" -map 0:v -map 1:a -vcodec copy -acodec copy "out.mp4"

Ripping

Rip and audio stream (I use this to rip SHOUTcast streams, specifically ours)

ffmpeg -y -i http://geostream.cdn.shoutdrive.com:80/sd-mp3 out.mp3

Rip an M3U8 (video HLS)

ffmpeg -i "http://on-demand.cdn.shoutdrive.com/mixes/service/2018-April-22_Thee-O/play.m3u8" -c copy -bsf:a aac_adtstoasc out.mp4

Output / Encoding / Streaming

Stream a local file to an RTMP server (Periscope specification)

ffmpeg -i FILE.mp4 -crf 30 -preset ultrafast -acodec aac -strict experimental -ar 44100 -ac 2 -b:a 92k -vcodec libx264 -x264-params keyint=60:no-scenecut=1 -r 30 -b:v 3250k -s 1280x720 -f flv rtmp://ca.pscp.tv:80/x/STREAM_KEY_HERE;

Translating / Muxing

Mount RTSP as virtual video device

$ ffmpeg -f mjpeg -i rtsp://192.168.1.16/play2.sdp -pix_fmt yuv420p -f v4l2 /dev/video0

Source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment