Giter Site home page Giter Site logo

ravijo / image-video-editing Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 2.0 75 KB

This repository contains commands for beginner level image and video editing in Ubuntu OS.

License: MIT License

video-editing aspect-ratio ffmpeg ubuntu-os imagemagick crop

image-video-editing's Introduction

Image and Video Editing

This repository contains commands for beginner level image and video editing in Ubuntu OS.

Tools Required

  1. ImageMagick
  2. ffmpeg

Install ImageMagick on Ubuntu 14.04

  1. Open the terminal or press CTRL+ALT+T
  2. Run following command sudo apt-get install imagemagick

Install FFmpeg on Ubuntu 14.04

  1. Use PPA. Open the terminal or press CTRL+ALT+T
  2. Run following commands-
    sudo add-apt-repository ppa:mc3man/trusty-media
    sudo apt-get update
    sudo apt-get install ffmpeg gstreamer0.10-ffmpeg

Image Editing

Resizing

Resizing can be done in following ways-

  • Provide the height and width in pixel convert input.png -resize 800x600 output.png
  • The above command preserves the aspect ratio. If you want to force the image to become exactly specific size, add exclamation mark like this convert input.png -resize 800x600! output.png
  • By providing width only and keeping the aspect ratio preserve convert input.png -resize 800 output.png
  • By providing height only and keeping the aspect ratio preserve convert input.png -resize x600 output.png
  • By providing percentage such as convert input.png -resize 50% output.png

Crop Image

convert input.jpg -crop 640x620+0+0 output.jpg

Convert PNG to JPG

  • Convert PNG to JPG by specifing the compression level using following command
convert input.png -quality 95 output.jpg

Batch resize Images

mkdir resized-imgs
mogrify -resize 25.4% -quality 95 -path resized-imgs *.jpg
mogrify -resize 1024x768 -quality 95 -path resized-imgs *.jpg

Batch converting PNG to JPG

mogrify -format jpg *.png

Remove Image Metadata

mogrify -strip *.jpg

Convert HEIC image to JPG

for file in *.HEIC; do heif-convert $file ${file%.HEIC}.jpg; done

mogrify -format jpg *.HEIC

Add Text on Image

convert -font helvetica -fill white -pointsize 40 -gravity north \
    -draw "text 0,100 'TEXT TO BE DISPLAYED'" input.jpg output.jpg

convert -font helvetica -undercolor white -fill black -pointsize 40 \
    -gravity northwest -draw "text 0,0 'TEXT TO BE DISPLAYED'" input.jpg output.jpg

Increase Brightness on Image

mogrify -brightness-contrast 10  *.JPG

Video Editing

Crop

  • Command syntax ffmpeg -i input.mp4 -filter:v "crop=out_w:out_h:x:y" output.mp4. For example To crop a 80x60 section, starting from position (200, 100) use the following command:
ffmpeg -i input.mp4 -filter:v "crop=80:60:200:100" -c:a copy output.mp4

Preview

It is better to check the preview before cropping a video.

ffplay -i input.mp4 -vf "crop=80:60:200:100"

# Use following, if above command says "ffplay: command not found" 
ffmpeg.ffplay -i input.mp4 -vf "crop=80:60:200:100"

Cut

  • A part in between
    ffmpeg -i input.mp4 -ss 00:00:03 -to 00:00:16 -c copy output.mp4
  • From beginning
    ffmpeg -i input.mp4 -t 00:00:30 -c copy output.mp4

Reduce Size

  • By decreasing frame rate 30 frames/sec ffmpeg -i input.mp4 -r 30 output.mp4
  • By resizing video ffmpeg -i input.avi -vf scale=1024:-1 output.avi
  • By decreasing video bit rate use a bitrate of 64kb/sec ffmpeg -i input.mp4 -b:v 64k output.mp4

Convert MOV to MP4

ffmpeg -i input.mov -q:v 0 output.mp4
ffmpeg -i input.mov -vcodec h264 -acodec mp2 output.mp4

Remove Audio from Video

ffmpeg -i input.mp4 -c copy -an output.mp4 

Add Text on Video

ffmpeg -i input.mp4 -vf "drawtext=:text='Stack Overflow':\
    fontcolor=white:fontsize=50:box=1:[email protected]:\
    boxborderw=5:x=(w-text_w)/2:y=(h-text_h)/2" -codec:a copy output.mp4

Place Two Videos Side-by-Side

ffmpeg -i left.mp4 -i right.mp4 -filter_complex hstack output.mp4

Concatenate Videos

$ cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
    
$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4

Gif from Video

  • Normal mode:
    ffmpeg -i input.mp4 output.gif
  • Advance mode:
    ffmpeg -y -i input.mp4 -vf palettegen palette.png
    ffmpeg -y -i input.mp4 -i palette.png -filter_complex paletteuse \
        -r 10 -s 320x480 output.gif

PDF Editing

Convert PDF to JPEG

convert -density 600 input.pdf -quality 90 -background white -alpha remove output.jpg

Extract Pages from PDF

pdftk input.pdf cat 12-15 output outfile_p12-15.pdf

Join PDFs

pdftk file1.pdf file2.pdf cat output mergedfile.pdf

Remove password from PDF

pdftk input.pdf input_pw <yourpassword> output output.pdf

Miscellaneous

Reduce Gif Size

mogrify -layers 'optimize' -fuzz 7% file.gif

Create EPS from Latex

latex input.tex
dvips -o output.eps input.dvi 

References

The above information is taken from various sources such as following-

image-video-editing's People

Contributors

ravijo avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

swipswaps

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.