Hacker News new | ask | show | jobs
by eXpl0it3r 1892 days ago
Video to GIF

  SET filters="fps=%4,scale=%3:-1:flags=lanczos"
  ffmpeg -v warning -i %1 -vf "%filters%,palettegen" -y palette.png
  ffmpeg -v warning -i %1 -i palette.png -lavfi "%filters% \[x\]; \[x\]\[1:v\] paletteuse" -y %2
  DEL palette.png

  togif.bat <input.mp4> <output.gif> <width> <fps>
Extract audio from a video

  ffmpeg -i "path\to\my_input_video_file.mp4" "path\to\my_output_audio_only.wav"
Extract specific video and audio stream

  ffmpeg -i "path\to\my_input_video_file.mp4" -map 0:0 -c copy video.mp4 -map 0:1 -c copy audio0.m4a -map 0:2 -c copy audio1.m4a
Concatenate two or more video clips

  (echo file 'first file.mp4' & echo file 'second file.mp4' )>list.txt
  ffmpeg -safe 0 -f concat -i list.txt -c copy output.mp4
Convert 10-bit H.265 to 10-bit H.264

  ffmpeg -i input -c:v libx264 -crf 18 -c:a copy output.mkv
Convert 10-bit H.265 to 8-bit H.265

  ffmpeg -i input -c:v libx265 -vf format=yuv420p -c:a copy output.mkv
Convert 10-bit H.265 to 8-bit H.264

  ffmpeg -i input -c:v libx264 -crf 18 -vf format=yuv420p -c:a copy output.mkv
2 comments

> Extract audio from a video

If you use `-vn` and `-acodec copy` (I use both although not sure `-vn` is strictly necessary), you can demux the audio from the video in the same format it is already in. Of course, you're extracting to wav so not transcoding, but copying may be faster/use less space.

> Extract audio from a video

In my opinion, `ffmpeg -i filename.mp4 filename.wav` is one of the greatest known examples of powerful functionality with a simple interface.