5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ffmpegでフォルダの中を一気に処理する

Posted at

aviフォルダの中の動画ファイル(aviなど)を全部mp4に変換する

avi2mp4.sh
# ffmpeg -i avi/MOVI0192.avi mp4/MOVI0192.avi.mp4
 ls avi/ | xargs -i ffmpeg -i avi/{} mp4/{}.mp4

フォルダの中のmp4を一個のmp4に連結する

concat.sh
echo -n > list.txt
ls mp4/ | xargs -i echo file mp4/{} >> list.txt
ffmpeg -f concat -i list.txt -c copy concatmp4/$(date "+%Y%m%d").mp4

list.txtというファイルに連結すべきファイルを書いて、それをffmpegに引数としてわたしています。

xargsでリダイレクトされた各行を、次のコマンドの{}に渡しています。上記の例では、lsで出力されたファイルを名が{}に変換されて、繰り返しコマンドが実行されます。

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?