Last active
December 23, 2021 10:02
-
-
Save ecoopnet/6b79cefb74548c15d01c7c5119720a35 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Convert mp4 video to animation GIF. | |
# Requirement: ffmpeg | |
if [ -z "$1" ]; then | |
( | |
echo "Usage: $(basename $0) video-file.mp4 [extra-options] | |
Convert mp4 video to animation GIF. | |
i.e: if ~/Downloads/video-file.mp4 was passed, ~/Downloads/video-file.gif was generated. | |
To change/add ffmpeg options, just append any options you want after the video filename. | |
" | |
) >&2 | |
exit | |
fi | |
input="$1" | |
shift | |
opts="$@" | |
if [ -z "$( echo "$opts" | grep -- '-r ')" ];then | |
opts="$opts -r 10" | |
fi | |
if [ -z "$( echo "$opts" | grep -- 'scale= ')" ];then | |
opts="$opts -vf scale=320:-1" | |
fi | |
output=$(echo "$input" | sed 's/\.[^\.]*$//').gif | |
#echo ffmpeg -i "$input" $opts "$output" | |
ffmpeg -i "$input" $opts "$output" | |
参考…スマートフォンアプリ開発時の動画撮影方法
iOS
- iPhoneをMacに繋ぐ
- Mac で QuickTime Player アプリを開く
- 新規ムービー収録 -> 中央下部 ● ボタン横から、iPhoneを選択
- iPhoneで録画準備(対象のアプリを起動するなど)
- Macで●ボタンを押して録画開始〜終わったら停止する
- Macでファイル→保存で任意のファイル名(hoge.mov)で保存する。
Android (ADBコマンドを使う例)
- Android 端末をPCに繋ぐ
- Androidで録画準備(対象のアプリを起動するなど)
- PCのコマンドラインから
adb shell screenrecord /sdcard/hoge.mp4
などとして録画開始(ファイル名は任意) - PCのコマンドラインでCtrl+Cで録画終了
adb pull /sdcard/hoge.mp4
としてAndroidからPCに転送adb shell rm /sdcard/hoge.mp4
としてAndroidから録画ファイル削除
ソースコードを https://github.com/ecoopnet/smartphone-development-tools に移植しました。
今後の更新は上記リポジトリを参照してください。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ビデオファイル(mp4, movなど)から、アニメーションGIFを生成します。
出力は入力と同一フォルダに展開されます。
例: mpeg2gif ~/Downloads/hoge.mp4
→hoge.gif が生成される。
実行にはffmpegが必要です。
ffmpegに追加オプションを渡したい場合、
などのように、ファイル名指定のあとにオプションを足すと、そのままffmpegに渡します。