meta

what's the meta about say it ditto dot net?

User Tools

Site Tools


cheatsheet:ffmpeg

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
cheatsheet:ffmpeg [2025/08/16 02:09] melocheatsheet:ffmpeg [2026/07/16 00:33] (current) melo
Line 4: Line 4:
  
 [[https://cheat-sheets.org/project/tldr/command/ffmpeg/|ffmpeg TLDR]], [[http://cheat.sh/ffmpeg|ffmpeg cheat.sh]] [[https://cheat-sheets.org/project/tldr/command/ffmpeg/|ffmpeg TLDR]], [[http://cheat.sh/ffmpeg|ffmpeg cheat.sh]]
 +
 +==== audio conversion ====
 +
 +=== FLAC to MP3 ===
 +
 +<code bash>
 +ffmpeg -i "$FILE.flac" -ab 320k -map_metadata 0 -id3v2_version 3 "$FILE.mp3"
 +</code>
  
 ==== video to frames ==== ==== video to frames ====
  
-see ''~/.local/bin/vidtools'' ([[https://bytes.4-walls.net/kat/dotfiles/src/commit/73e1380fd1dd186ce5925ab20b4529b4928e91cf/config/.local/bin/vidtools#L11|dotfiles]]) for the default/most used option (every frame including duplicates).+see ''~/.local/bin/vidtools'' ([[https://bytes.4-walls.net/kat/dotfiles/src/commit/main/config/.local/bin/vidtools|dotfiles]]) for the default/most used option (every frame including duplicates).
  
 === 1/1 frames === === 1/1 frames ===
Line 19: Line 27:
 <code bash> <code bash>
 ffmpeg -i "$FILE" -filter:v fps=fps=1/2 %04d.jpg ffmpeg -i "$FILE" -filter:v fps=fps=1/2 %04d.jpg
 +</code>
 +
 +=== avoid dupe frames ===
 +
 +<code bash>
 +ffmpeg -i "$f" -vf mpdecimate,setpts=N/FRAME_RATE/TB "%04d.png"
 +</code>
 +
 +==== cut based on timestamps ====
 +
 +<code bash>
 +# cut from the first minute to the second minute
 +ffmpeg -i "$FILE" -ss 00:01:00 -to 00:02:00 "$NEWFILE"
 +</code>
 +
 +==== scale/resize ====
 +
 +<code bash>
 +# replace 540 with 480, 720, 1080, etc
 +ffmpeg -i "$FILE" -vf scale=-1:540 "$NEWFILE"
 </code> </code>
  
 ==== re-encode ==== ==== re-encode ====
  
 +now mostly consolidated in ''vidtools'' (linked above), but copied here just in case.
  
 +=== x264 (AVC), no GPU ===
 +
 +<code bash>
 +ffmpeg -i "$FILE.mp4" -c:v libx264 -crf 18 -c:a copy -c:s copy "$FILE.mkv"
 +</code>
 +
 +=== x265 (HEVC), no GPU ===
 +
 +<code bash>
 +ffmpeg -i "$FILE.mp4" -c:v libx265 -vtag hvc1 -crf 18 -c:a copy -c:s copy "$FILE.mkv"
 +</code>
 +
 +=== x265 (HEVC), GPU, bash loop ===
 +
 +<code bash>
 +for f in *.mkv; do ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i "$f" -c:v hevc_nvenc -qmin 24 -qmax 24 -vtag hvc1 -profile main -preset slow -rc vbr_hq -c:a copy -c:s copy -map 0 "${f%.*} HEVC.mkv"; done
 +</code>
 +
 +=== AVI/DivX/XviD to MKV, bash loop ===
 +
 +<code bash>
 +for f in *.avi; do ffmpeg -fflags +genpts -i "$f" -c:v copy -c:a copy -c:s copy "${f%.*} AVI2MKV.mkv"; done
 +</code>
 +
 +=== copy video, remove audio, bash loop ===
 +
 +<code bash>
 +for f in *.mp4; do ffmpeg -i "$f" -vcodec copy -an "${f%.mp4}_noaudio.mp4"; done
 +</code>
 +
 +=== camcorder sources ===
 +
 +GPU accelerated camcorder source MPEG+AC3+VOBSUB to x264+AC3+VOBSUB (little to no file size reduction, for web uploads)
 +
 +<code bash>
 +ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -extra_hw_frames 10 -i "input.mkv" -c:a copy -c:v h264_nvenc -c:s copy -b:v 5M "output.mkv"
 +</code>
cheatsheet/ffmpeg.1755310158.txt.gz · Last modified: by melo

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki