Last active
July 19, 2022 01:51
-
-
Save sahara-ooga/6e63423e02d38a309f256bef0329656e to your computer and use it in GitHub Desktop.
Convert movies via ffmpeg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i foo.mkv -vcodec copy -acodec copy foo.mp4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
<< DESCRIPTION | |
動画ファイルをgif画像に変換します | |
# 対応しているファイル形式 | |
.mov | |
# 使い方 | |
1. パスを通してあるディレクトリにこのファイルを設置 | |
2. convgif.sh file.mov | |
でfile.gifが同じディレクトリに生成されます | |
DESCRIPTION | |
inputfile=$1 | |
# 出力したいファイルの拡張子 | |
ext=".gif" | |
# "ファイル名.拡張子" | |
filename_ext=${inputfile##*/} | |
#ファイル名から拡張子を取り除く | |
filename=${filename_ext%.*} | |
## 出力先ファイルパスを作成 | |
output=${opt_out:-$filename$ext} | |
ffmpeg -i $inputfile -filter_complex "[0:v] fps=10,scale=640:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" $output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ディレクトリ内の.movファイルからgifファイルを生成する | |
for movie in *.mov | |
do | |
ffmpeg -i ${movie} -filter_complex "[0:v] fps=10,scale=640:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" ${movie}.gif | |
done | |
#mac用のrenameコマンド。一般的なものとは異なる | |
#brew install rename | |
rename -s .mov.gif .gif *.mov.gif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i input.mov -filter_complex "[0:v] fps=10,scale=640:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" output.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment