ajhsu / blog

The external storage of my brain.
3 stars 0 forks source link

實驗性 FFmpeg 指令集 #34

Open ajhsu opened 7 years ago

ajhsu commented 7 years ago

Install FFmpeg on Ubuntu 14.04

sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ffmpeg

Combine image and audio file into video file

原版指令(來源

ffmpeg -loop 1 -i image.jpg -i audio.wav -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest out.mp4

原版精簡

ffmpeg -loop 1 -i image.jpg -i audio.wav -c:v libx264 -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest out.mp4

最精簡的版本,但會有一定機率失敗的問題

ffmpeg -loop 1 -i 3.jpg -i 3.mp3 -c:v libx264 -c:a aac -b:a 192k -shortest 3.mp4
ajhsu commented 7 years ago

Conver MP3 to M4A with FFMPEG on-fly

Using AAC

ffmpeg -i input.mp3 -c:a aac -b:a 128k output.m4a

Source

Using libfaac

ffmpeg  -i Kalimba.mp3 -c:a libfaac -vn Kalimba.m4a

Source

Upload M4A file using uguu API

curl -i -F name=m.m4a -F file=@m.m4a "https://uguu.se/api.php?d=upload-tool"

Convert mp3 to m4a with NodeJS + FluentFFmpeg

var ffmpeg = require('fluent-ffmpeg');
var command = ffmpeg()
  .input('https://fs-preview.kfs.io/201307/0dguZusnnTg00mpLw_FUBtFAQnzkfdWeKlkkrtwLN8CDky3dVmI=?__gda__=1490690799_f6cb8f4624b3225becd4e948b32c036c')
  .output('test.m4a')
  .audioCodec('aac')
  .audioBitrate('128k')
  .on('start', cmd => console.log('Start with ' + cmd))
  .on('progress', progress => console.log('Processing - ' + JSON.stringify(progress)))
  .on('error', err => console.error(err))
  .on('end', stdout => console.log('FFmpeg finished - ' + stdout));

command.run();
ajhsu commented 7 years ago

聲音相關

音檔轉換

wav to mp3

ffmpeg -i inputfile.wav -ab 320k outputfile.mp3 ffmpeg -i audio.wav -acodec libmp3lame audio.mp3

ogg to mp3

ffmpeg -i audio.ogg -acodec libmp3lame audio.mp3

ac3 to mp3

ffmpeg -i audio.ac3 -acodec libmp3lame audio.mp3

aac to mp3

ffmpeg -i audio.aac -acodec libmp3lame audio.mp3

音檔裁切

Take a look at the -t and -ss arguments. They should do what you want.

-t duration
Restrict the transcoded/captured video sequence to the duration specified in seconds. hh:mm:ss[.xxx] syntax is also supported.
-ss position'
Seek to given time position in seconds. hh:mm:ss[.xxx] syntax is also supported.

ffmpeg -ss 30 -t 70 -i inputfile.mp3 -acodec copy outputfile.mp3

Here's a command line that will slice to 30 seconds without transcoding:

ffmpeg -t 30 -i inputfile.mp3 -acodec copy outputfile.mp3

https://stackoverflow.com/questions/1390731/how-to-crop-a-mp3-from-x-to-xn-using-ffmpeg https://stackoverflow.com/questions/43890/crop-mp3-to-first-30-seconds

ajhsu commented 7 years ago

// Install FFMPEG + MP4 Codec in OSX

brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265

// List all of codec

ffmpeg -codecs

// List all of format supported

ffmpeg -formats

// Save stream into h264

ffmpeg -i "http://219.70.20.195:81/videostream.cgi?user=admin&pwd=" -vcodec h264 -q 1 -framerate 12 output.mp4

// Save stream into flv

ffmpeg -i "http://219.70.20.195:81/videostream.cgi?user=admin&pwd=" -vcodec flv -q 1 -framerate 12 output.flv
ajhsu commented 7 years ago

Mute right audio channel

ffmpeg -i source.mov -map_channel -1 -map_channel 0.0.0 -c:v copy dest.mov

Mute left audio channel

ffmpeg -i source.mov -map_channel -1 -map_channel 0.0.1 -c:v copy dest.mov