- Linux Version :
- # lsb_release -da
- Distributor ID: Ubuntu
- Description: Ubuntu 14.04.4 LTS
- Release: 14.04
- Codename: trusty
You will need to install :
ffmpeg used for adding and scaling film, for another information you can google it.
- root@kecap:/tmp# apt-get install ffmpeg
because i want use another font for my subtitle, in this case it's Arial
- root@kecap:/tmp# apt-get install fontconfig
you need to install this package to get microsoft fonts, but if after installing this package and you got empty directory (like what happen to me), simple...just copy arial font from windows to /usr/share/fonts/truetype/msttcorefonts/ and run fs-cache.
- root@kecap:/tmp# apt-get install ttf-mscorefonts-installer
Now, we go to main topic.
Adding subtitle using ffmpeg
Basic :
Advanced :
- ffmpeg -i input.mp4 -vf subtitles=mysub.srt output.mp4
for .ASS tag description please read this
- ffmpeg -i input.mp4 -vf subtitles="f=mysub.srt:force_style='FontName=Arial Bold,FontSize=22,PrimaryColour=&H0009FAFD,OutlineColour=&H00000000,WrapStyle=2,Borderstyle=1,Outline=1,Shadow=1'" -y output.mp4
Scaling film using ffmpeg
Basic :
Advanced :
- ffmpeg -i input.mp4 -vf scale=1028:720 output.mp4
- ffmpeg -i input.mp4 -vf scale=-1:720 -c:v libx264 -profile:v high -level:v 3.1 -c:a copy output.mp4
Combining two ffmpeg command
- ffmpeg -i input.mp4 -vf "scale=-1:720,subtitles="f=mysub.srt:force_style='FontName=Arial Bold,FontSize=22,PrimaryColour=&H0009FAFD,OutlineColour=&H00000000,WrapStyle=2,Borderstyle=1,Outline=1,Shadow=1'"" -c:v libx264 -profile:v high -level:v 3.1 -y output.mp4
ffmpeg & bash
If you writing ffmpeg script inside bash, you will get "funny error"
the point is the bash script seems to produce input (Namely the 'c' key) which interferes with the ffmpeg process. just add >/dev/null at the end of the ffmpeg command to prevent ffmpeg from reading its standard input, see example below:
- Parse error, at least 3 arguments were expected, only 1 given in string....
for more information you can read it here
- ffmpeg -i input.mp4 -vf scale=1028:720 output.mp4 >/dev/null