LoginSignup
28
16

More than 1 year has passed since last update.

ffmpegによるmp4→mp3変換めも

Last updated at Posted at 2019-08-15

webp -> jpg 一括変換

find . -type f -name '*.webp' | xargs -P 5 -I{} bash -c 'ffmpeg -i $0 ${0%.*}.jpg' {}

mp3ファイルにカバーアート付ける

ffmpeg -i audio.mp3 -i thumb.jpg -map 0:a -map 1:v -c copy -disposition:1 attached_pic -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" audio-with-cover.mp3

動画ファイル(MP4)と字幕ファイル(SRT)の結合

ffmpeg -i 動画ファイル名.mp4 -vf subtitles=字幕ファイル名.srt 出力ファイル名.mp4

再生速度変更

0.5倍速
ffmpeg -i input.mp4 -vf setpts=PTS/0.5 -af atempo=0.5 output.mp4

mp4 -> gifへ変換

mp4->gif
# カラーパレット使用,10fps,再生速度:0.5倍,無限ループ,切り出し:5秒目から3秒間
ffmpeg -i input.mp4 -vf "fps=10, scale=640:-1, setpts=PTS/0.5, split[a][b]; [a]palettegen[c]; [b][c]paletteuse" -loop 0 -t 3 -ss 5 output.gif

ts -> mp4へ変換

ts->mp4
ffmpeg -i "concat:index0.ts|index1.ts|index2.ts|index3.ts|index4.ts|index5.ts|index6.ts" -c copy hoge.mp4

# 連番結合 1〜30 ゼロサプレス
ffmpeg -i "concat:`seq -f index-%g.ts -s \| 30`" -c copy hoge.mp4

Webmでopusが読めないって言われた人が読むめも

よくわかってないです。めも
・webmがYoutubeなどで流行っている?
・VLCは、opusを標準非対応?vorbisは対応
・opusが音声圧縮界隈で流行っている?
・webm vl8/9は、opus/vorbisである必要がある。

# opus抜く
ffmpeg -i "test.webm" -vn -acodec copy "test.opus"

# opus -> vorbis 変換
ffmpeg -i "test.opus" -vn -ac 2 -ar 44100 -ab 256k -acodec libvorbis -f ogg "test.ogg"

# 音声消す
ffmpeg -i test.webm -vcodec copy -an test2.webm

# 映像/音声の結合
ffmpeg -i test2.webm -i test.ogg -map 0:0 -map 1:0 -vcodec copy -acodec copy result.webm

# しょっぱいワンライナー (いい感じにできる人教えてくだせい)
ffmpeg -i "test.webm" -vn -acodec copy "test.opus" && ffmpeg -i "test.opus" -vn -ac 2 -ar 44100 -ab 256k -acodec libvorbis -f ogg "test.ogg" && ffmpeg -i test.webm -vcodec copy -an test2.webm && ffmpeg -i test2.webm -i test.ogg -map 0:0 -map 1:0 -vcodec copy -acodec copy result.webm && rm test.opus test.ogg test2.webm

インストール

yum -y install ffmpeg ffmpeg-devel

mp3化

ディレクトリ内一括
find . -type f -name "*.mp4" -print0 | perl -pe 's/\.mp4\0/\0/g' | xargs -0 -I% ffmpeg -i %.mp4 -acodec libmp3lame -ab 256k %.mp3
個別変換
ffmpeg -i hoge.mp4 -acodec libmp3lame -ab 256k foo.mp3

音量上げる

ffmpeg -i hoge.mp4 -af "volume=20dB" foo.mp4

動画切り出し

ffmpeg -ss [開始地点()] -i [入力する動画パス] -t [切り出す秒数] [出力する動画パス]
28
16
2

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
28
16