Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
software:video [2008/01/30 07:36] 127.0.0.1 external edit |
software:video [2024/05/12 22:48] (current) cyril [ffmpeg] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Multimedia encoding ====== | ====== Multimedia encoding ====== | ||
- | ===== Windows ===== | ||
- | VirtualDub | + | ===== Images ===== |
- | ===== Linux ===== | + | ==== convert |
+ | === size operations === | ||
+ | |||
+ | * resize: scale image< | ||
+ | convert in.png -resize 640x480 out.png | ||
+ | </ | ||
+ | * crop: crop image< | ||
+ | convert in.png -crop 640x480+10+10 out.png | ||
+ | </ | ||
+ | * extent: add margins or crops< | ||
+ | convert in.png -gravity center -extent 1420x1420 | ||
+ | convert in.png | ||
+ | </ | ||
+ | |||
+ | === Annotate an image with text === | ||
+ | Simple text: | ||
+ | < | ||
+ | convert in.png \ | ||
+ | -pointsize 20 -fill red -draw 'text 10,30 "My text" ' \ | ||
+ | out.png | ||
+ | </ | ||
+ | |||
+ | Text with shadow: | ||
+ | < | ||
+ | convert in.png \ | ||
+ | -gravity SouthEast \ | ||
+ | -stroke '# | ||
+ | -stroke none -fill white -annotate 0 "My text" \ | ||
+ | out.png | ||
+ | </ | ||
+ | |||
+ | === Append images === | ||
+ | |||
+ | < | ||
+ | convert in1.png in2.png +append out.png # horizontally | ||
+ | convert in1.png in2.png -append out.png # vertically | ||
+ | </ | ||
+ | |||
+ | More complex: | ||
+ | < | ||
+ | convert im1.png -resize 640x480 ppm:- \ | ||
+ | | convert im2.png - +append ppm:- \ | ||
+ | | convert im3.png - -append final.png | ||
+ | </ | ||
+ | |||
+ | === Create animated GIF === | ||
+ | |||
+ | < | ||
+ | |||
+ | === Formats === | ||
+ | * EPS to RGB:< | ||
+ | convert -density 600x600 -flatten -depth 8 -colorspace RGB file.eps ppm:- | convert - file.png | ||
+ | </ | ||
+ | |||
+ | ==== Exif ==== | ||
+ | === exiftool === | ||
+ | * restore exif Orientation tag: if you have photos captured with a device that sets the orientation tag, but you used a viewer that doesn' | ||
+ | exiftool -overwrite_original -Orientation=" | ||
+ | </ | ||
- | ==== Video ==== | ||
- | => '' | + | ===== Video ===== |
+ | ==== mencoder | ||
+ | (comes with mplayer). | ||
[[http:// | [[http:// | ||
- | Example with xvid codec : | + | General syntax: |
<code bash> | <code bash> | ||
mencoder \ | mencoder \ | ||
+ | <input data> \ | ||
+ | <input options> \ | ||
+ | <output options> \ | ||
+ | <output data> | ||
+ | </ | ||
+ | |||
+ | === Input data and options === | ||
+ | * Video files< | ||
+ | mencoder \ | ||
+ | < | ||
+ | <input options> \ | ||
+ | <output options> \ | ||
+ | <output data> | ||
+ | </ | ||
+ | |||
+ | * Image files< | ||
+ | mencoder \ | ||
+ | " | ||
+ | -mf fps=25 \ | ||
+ | <output options> \ | ||
+ | <output data> | ||
+ | </ | ||
+ | |||
+ | * Image files from stdin (only works with jpg images, but you can use convert to pipe to mencoder)< | ||
+ | mencoder \ | ||
+ | - \ | ||
+ | -demuxer lavf -lavfdopts format=mjpeg \ | ||
+ | <output options> \ | ||
+ | <output data> | ||
+ | </ | ||
+ | |||
+ | * Video filters: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | === Output data and options === | ||
+ | |||
+ | Specify the video codec with '' | ||
+ | |||
+ | * **xvid** < | ||
+ | mencoder \ | ||
+ | <input data> \ | ||
+ | <input options> \ | ||
-ovc xvid -xvidencopts bitrate=800: | -ovc xvid -xvidencopts bitrate=800: | ||
+ | -o < | ||
+ | </ | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | * **h264** < | ||
+ | mencoder \ | ||
+ | <input data> \ | ||
+ | <input options> \ | ||
+ | -ovc x264 -x264encopts bitrate=800 \ | ||
+ | -o < | ||
+ | </ | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | * **WebM** < | ||
+ | mencoder \ | ||
+ | <input data> \ | ||
+ | <input options> \ | ||
+ | -ovc lavc -ffourcc VP80 -of lavf -lavfopts format=webm -lavcopts vcodec=libvpx: | ||
+ | -o < | ||
+ | </ | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | * **mp3** < | ||
+ | mencoder \ | ||
+ | <input data> \ | ||
+ | <input options> \ | ||
-oac mp3lame -lameopts abr:br=128 \ | -oac mp3lame -lameopts abr:br=128 \ | ||
- | | + | -o < |
- | K7-1-DV-1.avi K7-1-DV-2.avi | + | |
</ | </ | ||
+ | === Other operations === | ||
- | Options | + | * cut the file (here from 10' |
- | | + | mencoder -ss 10:00 -endpos 30 -ovc copy -oac copy movie.avi -o submovie.avi |
- | * trellis : speeds up encoding | + | </ |
- | * oac = audio codec | + | |
- | * vf = video filters | + | |
- | * pp = post processing subfilters | + | |
- | * yadif : deinterlace | + | |
+ | ==== ffmpeg ==== | ||
+ | * video codec: '' | ||
+ | * audio codec: '' | ||
+ | * codec bitrate: video '' | ||
+ | * codec quality: video '' | ||
- | ==== Audio ==== | + | * crop: '' |
+ | * resize: '' | ||
+ | * pad: '' | ||
+ | * rotate: '' | ||
- | === mp3 === | + | * blur: '' |
+ | * overlay two videos:< | ||
+ | ffmpeg -i in1.avi -vf " | ||
+ | </ | ||
+ | ffmpeg -i in1.avi -i in2.avi -filter_complex " | ||
+ | </ | ||
+ | |||
+ | * append side by side two videos:< | ||
+ | ffmpeg -i in_left.avi -vf " | ||
+ | </ | ||
+ | |||
+ | * encode video from images sequence (eg for timelapse):< | ||
+ | ffmpeg -r 50 -i 01/ | ||
+ | ffmpeg -r 10 -pattern_type glob -i " | ||
+ | </ | ||
+ | |||
+ | * cut clip (ss is start time, t is duration):< | ||
+ | ffmpeg -i in.avi -ss 00:00:23 -t 00:00:19 -vcodec copy -acodec copy out.avi | ||
+ | </ | ||
+ | |||
+ | * render subtitles (requires to be compiled with libass): '' | ||
+ | |||
+ | * transform portrait video 640x480 to landscape 1280x720 with blurry repeated sides:< | ||
+ | ffmpeg -i in.avi -filter_complex "[0:v] transpose=2, | ||
+ | ' | ||
+ | </ | ||
+ | ==== AviDemux ==== | ||
+ | |||
+ | A GUI easier to use, like VirtualDub for Windows. | ||
+ | |||
+ | |||
+ | ==== PhotoFilmStrip ==== | ||
+ | |||
+ | |||
+ | |||
+ | ==== Kdenlive ==== | ||
+ | |||
+ | Tried Openshot and Cinelerra but seem crappy, Kdenlive seems to have better design. | ||
+ | |||
+ | * Transitions : works between two video tracks that overlap (eg dissolve). | ||
+ | * Audio track volume : add effect "Audio Correction / Volume (keyframable)", | ||
+ | ===== Audio ===== | ||
+ | |||
+ | ==== mp3 ==== | ||
=> '' | => '' | ||
Line 43: | Line 224: | ||
</ | </ | ||
- | === ogg === | + | => '' |
+ | |||
+ | To cut an mp3 file (warning: ID3 tags are not copied): | ||
+ | <code bash> | ||
+ | mp3cut -o output.mp3 -t 00: | ||
+ | </ | ||
+ | |||
+ | To concatenate mp3 files: | ||
+ | <code bash> | ||
+ | mp3cut -o output.mp3 input1.mp3 input2.mp3 input3.mp3 | ||
+ | </ | ||
+ | |||
+ | => '' | ||
+ | |||
+ | To copy ID3 tags from a file to another one. | ||
+ | |||
+ | => '' | ||
+ | |||
+ | To view and edit ID3 tags in command line. | ||
+ | |||
+ | => '' | ||
+ | |||
+ | To view and edit ID3 tags in GUI. | ||
+ | |||
+ | |||
+ | ==== ogg ==== | ||
+ | (using vorbis-tools package) | ||
=> '' | => '' | ||
Line 49: | Line 256: | ||
To encode from wav to ogg in " | To encode from wav to ogg in " | ||
<code bash> | <code bash> | ||
- | oggenc -b 32 --downmix --resample 22050 file.wav file.ogg | + | oggenc -b 32 --downmix --resample 22050 file.wav |
</ | </ | ||
Line 55: | Line 262: | ||
<code bash> | <code bash> | ||
oggdec -b 16 -R file.ogg -o - | oggenc -r -B 16 -C 1 -b 32 --resample 22050 - -o file_recomp.ogg | oggdec -b 16 -R file.ogg -o - | oggenc -r -B 16 -C 1 -b 32 --resample 22050 - -o file_recomp.ogg | ||
+ | </ | ||
+ | |||
+ | ==== sox ==== | ||
+ | play, record, process | ||
+ | |||
+ | * Cut: (start position / length)< | ||
+ | sox in_file.wav out_file.wav trim 2:37:32 4:00 | ||
+ | </ | ||
+ | * Reencode:< | ||
+ | sox in_file.type1 out_file.type2 | ||
+ | sox in_file.type1 -t type2 - | oggenc ... | ||
+ | </ | ||
+ | |||
+ | ==== ffmpeg ==== | ||
+ | |||
+ | * extract sound track from video: < | ||
+ | ffmpeg -i video.avi sound.mp3 | ||
</ | </ |