Skip to content

Instantly share code, notes, and snippets.

@nngogol
Last active June 1, 2019 09:40
Show Gist options
  • Save nngogol/09f02b374e9f213d44454b615279d4fa to your computer and use it in GitHub Desktop.
Save nngogol/09f02b374e9f213d44454b615279d4fa to your computer and use it in GitHub Desktop.
for FAST media conveting

ffmpeg

reduce filesize

ffmpeg -i input.avi -vcodec libx264 -crf 24 output.avi

trim

trim start :

ffmpeg
-i 1.mp4
-ss start_time
-c copy
retult.mp4

trim end :

ffmpeg
-i 1.mp4
-to end_time
-c copy
retult.mp4

audio or video only

-vn -acodec copy -> only audio
-an -vcodec copy -> only video

joinfiles

Ehhh...
ls * | perl -ne 'print "file $_"' | ffmpeg -f concat -i - -c copy merged.mp4

video <--> images

to images : ffmpeg -i video.flv image%d.jpg
from images : ffmpeg -f image2 -i image%d.jpg imagestovideo.mpg

video -> gif

set palt=palette.png
set filters=scale=800:-1:flags=lanczos
rem set filters=fps=10,scale=500:-1:flags=lanczos

rem make palette.png
set a=ffmpeg -y -i %1 -filter_complex "%filters%,palettegen" %1-%palt%
rem set a=ffmpeg -y -i %1 -filter_complex "%filters%,palettegen" %1-%palt%

rem make gif: palette.png + video.mp4
set b=ffmpeg -y -i %1 -i %1-%palt% -filter_complex "%filters%[x];[x][1:v]paletteuse" %2
rem set b=ffmpeg -y -i %1 -i %1-%palt% -filter_complex "%filters%[x];[x][1:v]paletteuse" %2

%a%
%b%
@nngogol
Copy link
Author

nngogol commented Oct 10, 2018

ffmpeg -list_devices true -f dshow -i dummy

@nngogol
Copy link
Author

nngogol commented Jun 1, 2019

PROPER trim
ffmpeg -y -i 12-29-44-452952816.mkv -ss 00:00:02 -to 00:00:10.01 -async 1 out.mkv

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