This repository contains commands for beginner level image and video editing in Ubuntu OS.
- Open the terminal or press CTRL+ALT+T
- Run following command
sudo apt-get install imagemagick
- Use PPA. Open the terminal or press CTRL+ALT+T
- Run following commands-
sudo add-apt-repository ppa:mc3man/trusty-media sudo apt-get update sudo apt-get install ffmpeg gstreamer0.10-ffmpeg
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
convert input.jpg -crop 640x620+0+0 output.jpg
- Convert
PNG
toJPG
by specifing the compression level using following command
convert input.png -quality 95 output.jpg
mkdir resized-imgs
mogrify -resize 25.4% -quality 95 -path resized-imgs *.jpg
mogrify -resize 1024x768 -quality 95 -path resized-imgs *.jpg
mogrify -format jpg *.png
mogrify -strip *.jpg
for file in *.HEIC; do heif-convert $file ${file%.HEIC}.jpg; done
mogrify -format jpg *.HEIC
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
mogrify -brightness-contrast 10 *.JPG
- 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
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"
- 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
- 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
ffmpeg -i input.mov -q:v 0 output.mp4
ffmpeg -i input.mov -vcodec h264 -acodec mp2 output.mp4
ffmpeg -i input.mp4 -c copy -an output.mp4
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
ffmpeg -i left.mp4 -i right.mp4 -filter_complex hstack output.mp4
$ 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
- 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
convert -density 600 input.pdf -quality 90 -background white -alpha remove output.jpg
pdftk input.pdf cat 12-15 output outfile_p12-15.pdf
pdftk file1.pdf file2.pdf cat output mergedfile.pdf
pdftk input.pdf input_pw <yourpassword> output output.pdf
mogrify -layers 'optimize' -fuzz 7% file.gif
latex input.tex
dvips -o output.eps input.dvi
The above information is taken from various sources such as following-
- Video Stackexchange
- Unix Stackexchange
- Stackoverflow
- FFmpeg
- Reduce Gif Size
- FFmpeg with Palette
- Mov2Mp4
- Mov2Mp4
- Remove Audio from Video
- Convert Heic to Jpg
- Add Text on Video
- Add Text on Image
- Preview Video
- Increase Brightness on Image
- Crop Image
- Place Two Videos Side-by-Side
- Cut Video from Beginning
- Concatenate Videos
- Batch converting PNG to JPG
- Batch resize Images
- Extract Pages from PDF
- Join PDFs
- Remove password from PDF