some useful ffmpeg commands

http://www.upubuntu.com/2012/10/some-useful-ffmpeg-commands.html


Some Useful FFMPEG Commands (Screencasting, Rotate Video, Add Logo, etc.) - Ubuntu/Linux Mint

 0 
width="336" height="280" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" id="aswift_0" name="aswift_0" style="max-width: 100%; left: 0px; position: absolute; top: 0px;">

In this tutorial we will see some useful  FFMPEG commands that you can use on Ubuntu/Linux Mint to make screencasting videos, rotate videos, add logo/text watermarks to a video, insert shapes, and so on.

To install ffmpeg and some other packages on Ubuntu/Linux Mint, open the terminal and run these commands:

sudo apt-get install ubuntu-restricted-extras

sudo apt-get install ffmpeg x264

sudo apt-get install frei0r-plugins mjpegtools


Note: The file formats used in this tutorial are selected randomly and you can set any other extension of your choice.

1. Screecasting

To record your screen withh FFMPEG, you can use this command:

ffmpeg -f x11grab -follow_mouse 100 -r 25 -s vga -i :0.0 filename.avi

Now the command will record every spot on your screen you hover your mouse cursor over. Press  Ctrl+C to stop recording. If you want to set a screen resolution for the video to be recorded, you can use this ffmpeg command:

ffmpeg -f x11grab -s 800x600 -r 25 -i :0.0 -qscale 5 filename.avi

To show the region that will be recorded while moving your mouse pointer, use this command:

ffmpeg -f x11grab -follow_mouse centered -show_region 1 -r 25 -s vga -i :0.0filename.avi

If you want to record in fullscreen with better video quality ( HD), you can use this command:

ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq  video.mp4

Her is a video example created with the latter command:

allowfullscreen="allowfullscreen" frameborder="0" height="315" src="http://www.youtube.com/embed/lcX35Lrz0CU" width="560" style="max-width: 100%;">

2. Add Audio To A Static Picture

If you want to add music to a static picture with ffmpeg, run this command from the terminal:

ffmpeg -i audio.mp3 -loop_input -f image2 -i file.jpg -t 188 output.mp4

3. Add Image Watermarks to A Video

To add an image to a video using ffmpeg, you can use one of these commands:

Picture Location: Top Left Corner

ffmpeg -i input.avi -vf "movie=file.png [watermark]; [in][watermark] overlay=10:10 [out]" output.flv


Here is an example:

allowfullscreen="allowfullscreen" frameborder="0" height="315" src="http://www.youtube.com/embed/O45jrw7-V-0" width="560" style="max-width: 100%;">

Picture Location: Top Right Corner

ffmpeg –i input.avi -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" output.flv


Picture Location: Bottom Left Corner

ffmpeg –i input.avi -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=10:main_h-overlay_h-10 [out]" output.flv

Picture Location: Bottom Right Corner

ffmpeg –i input.avi -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" output.flv

4. Add Text Watermarks To Videos


To add text to a video, use this command:

ffmpeg -i input.mp4 -vf drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf: text='YOUR TEXT HERE':fontcolor=red@1.0:fontsize=70:x=00: y=40" -youtput.mp4

An example:

allowfullscreen="allowfullscreen" frameborder="0" height="315" src="http://www.youtube.com/embed/MgUb7zxBwPQ" width="560" style="max-width: 100%;">

To use another text font, you can list them from the terminal with this command:

ls /usr/share/fonts/truetype/freefont/

4. Rotate Videos


To rotate a video 90 degrees with ffmpeg, run this command:

ffmpeg -i input.avi -vf transpose=1 output.avi

Here is an example for a video rotated with ffmpeg:

allowfullscreen="allowfullscreen" frameborder="0" height="315" src="http://www.youtube.com/embed/WNf-gvtYBXQ" width="420" style="max-width: 100%;">

Here is all parameters:

  • 0 = 90 degrees CounterCLockwise  (Vertical Flip (default))
  • 1 = 90 degrees Clockwise
  • 2 = 90 degrees CounterClockwise
  • 3 = 90 degrees Clockwise (Vertical Flip)

5. Adjust Audio/Video Volume
    You can use ffmpeg to change volume of a video file with this command:

    ffmpeg -i input.avi -vol 100  output.avi

    To change volume of an audio file, run this command:

    ffmpeg -i input.mp3 -vol 100 -ab 128 output.mp3

    6. Insert A Video Inside Another Video


    To do this, run this command:

    ffmpeg -i video1.mp4 -vf "movie=video2.mp4:seek_point=5, scale=200:-1, setpts=PTS-STARTPTS [movie]; [in] setpts=PTS-STARTPTS, [movie]overlay=270:240 [out]" output.mp4

    Here is an example:

    allowfullscreen="allowfullscreen" frameborder="0" height="315" src="http://www.youtube.com/embed/8BON6nW7Eis" width="420" style="max-width: 100%;">

    7. Add a Rectangle To A Video

    To draw for example an orange rectangle in a video, you can use this command:

    ffmpeg -i input.avi -vf "drawbox=500:150:600:400:orange@0.9" -sameq -youtput.avi

    Video example:

    allowfullscreen="allowfullscreen" frameborder="0" height="315" src="http://www.youtube.com/embed/OEvVWePVng8" width="560" style="max-width: 100%;">

    If you have something to add or report a mistake, please use the comment form below.

    • 0
      点赞
    • 0
      收藏
      觉得还不错? 一键收藏
    • 3
      评论

    “相关推荐”对你有帮助么?

    • 非常没帮助
    • 没帮助
    • 一般
    • 有帮助
    • 非常有帮助
    提交
    评论 3
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值