Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
software:video [2010/07/23 07:06]
cyril x264encopts
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 ===
-==== Images ==== +
- +
-=== convert === +
-== size operations ==+
  
   * resize: scale image<code>   * resize: scale image<code>
Line 22: Line 17:
 </code> </code>
  
-== Annotate an image with text==+=== Annotate an image with text ==
 +Simple text: 
 +<code> 
 +convert in.png \ 
 +  -pointsize 20 -fill red -draw 'text 10,30 "My text" ' \ 
 +  out.png 
 +</code> 
 + 
 +Text with shadow:
 <code> <code>
 convert in.png \ convert in.png \
   -gravity SouthEast \   -gravity SouthEast \
-  -stroke '#000C' -strokewidth 2 -annotate 0 'TeST' +  -stroke '#000C' -strokewidth 2 -annotate 0 "My text" 
-  -stroke none     -fill white   -annotate 0 'TeST' \+  -stroke none    -fill white    -annotate 0 "My text" \
   out.png   out.png
 </code> </code>
  
-== Append images ==+=== Append images ===
  
 <code> <code>
Line 38: Line 41:
 </code> </code>
  
-=== Exif === +More complex: 
-== exiftool ==+<code> 
 +convert im1.png -resize 640x480 ppm:- \ 
 + | convert im2.png - +append ppm:- \ 
 + | convert im3.png - -append final.png 
 +</code> 
 + 
 +=== Create animated GIF === 
 + 
 +<code>convert -delay 50 -loop 0 *.jpg out.gif</code> 
 + 
 +=== Formats === 
 +  * EPS to RGB:<code> 
 +convert -density 600x600 -flatten -depth 8 -colorspace RGB file.eps ppm:- | convert - file.png 
 +</code> 
 + 
 +==== 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't use this tag, and rotated the image with a software that doesn't update this tag, then the image is inconsistent and is not well displayed in exif-aware viewers. To reset the orientation tag, you can use the following command:<code>   * restore exif Orientation tag: if you have photos captured with a device that sets the orientation tag, but you used a viewer that doesn't use this tag, and rotated the image with a software that doesn't update this tag, then the image is inconsistent and is not well displayed in exif-aware viewers. To reset the orientation tag, you can use the following command:<code>
 exiftool -overwrite_original -Orientation="Horizontal (normal)" <file> exiftool -overwrite_original -Orientation="Horizontal (normal)" <file>
Line 45: Line 64:
  
  
-==== Video ==== +===== Video ===== 
-=== mencoder ===+==== mencoder ====
 (comes with mplayer). (comes with mplayer).
  
 [[http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide]] [[http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide]]
  
-== From another video file == +General syntax:
- +
-Example with xvid codec :+
 <code bash> <code bash>
 mencoder \ mencoder \
-  -ovc xvid -xvidencopts bitrate=800:quant_type=mpeg:gmc:chroma_opt:vhq=4:bvhq=1:trellis +  <input data> 
-  -oac mp3lame -lameopts abr:br=128 +  <input options> 
-  -vf yadif=0 +  <output options> 
-  K7-1-DV-1.avi K7-1-DV-2.avi -o rush1.avi+  <output data>
 </code> </code>
  
 +=== Input data and options ===
 +  * Video files<code>
 +mencoder \
 +  <input_file_1> <input_file_2> ... \
 +  <input options> \
 +  <output options> \
 +  <output data>
 +</code>
  
-Options : +  Image files<code> 
-  ovc = video codec +mencoder \ 
-    * trellis : speeds up encoding +  "mf://img.o.*.PNG" \ 
-  * oac = audio codec +  -mf fps=25 \ 
-  * vf video filters +  <output options> \ 
-    * pp = post processing subfilters +  <output data> 
-    * yadif : deinterlace+</code>
  
-== From multiple images ==+  * Image files from stdin (only works with jpg images, but you can use convert to pipe to mencoder)<code> 
 +mencoder \ 
 +  - \ 
 +  -demuxer lavf -lavfdopts format=mjpeg \ 
 +  <output options> \ 
 +  <output data> 
 +</code>
  
-<code>+  * Video filters: 
 +    * ''-vf yadif=0'' : deinterlace 
 +    * ''-vf scale=640:480'' : scale video 
 +    * ''-vf crop=w:h:x:y'' : crop video 
 +    * ''-vf "crop=640:360:0:60,scale=1280:720"'' : multiple video filters 
 +    * ''-vf pp=?'' : post processing subfilters 
 + 
 +=== Output data and options === 
 + 
 +Specify the video codec with ''-ovc'' option, and audio codec with ''-oac'' option. ''copy'' is possible with both. 
 + 
 +  * **xvid** <code> 
 +mencoder \ 
 +  <input data> \ 
 +  <input options> \ 
 +  -ovc xvid -xvidencopts bitrate=800:quant_type=mpeg:gmc:chroma_opt:vhq=4:bvhq=1:trellis \ 
 +  -o <output_file> 
 +</code>xvid encode options: 
 +    * ''bitrate=<value>'': constant bitrate, in kbs 
 +    * ''fixed_quant=<1-31>'': constant quantization (quality), lower is better 
 +    * ''trellis'' : speeds up encoding 
 + 
 +  * **h264** <code>
 mencoder \ mencoder \
 +  <input data> \
 +  <input options> \
   -ovc x264 -x264encopts bitrate=800 \   -ovc x264 -x264encopts bitrate=800 \
-  -vf scale=640:480 +  -o <output_file> 
-  "mf://img.o.*.PNG" -mf fps=25 -o img.o.avi+</code>x264 encode options: 
 +    * ''bitrate=<value>''constant bitrate, in kbs 
 +    * ''crf=<1.0-50.0>'': constant quality, lower is better 
 + 
 +  * **WebM** <code> 
 +mencoder 
 +  <input data> \ 
 +  <input options> \ 
 +  -ovc lavc -ffourcc VP80 -of lavf -lavfopts format=webm -lavcopts vcodec=libvpx:vqscale=22.0 \ 
 +  -<output_file> 
 +</code>lavc options: 
 +    ''vbitrate=<value>'': constant bitrate, in kbs 
 +    * ''vqscale=<1.0-31.0>'': constant quantization (quality), lower is better 
 + 
 +  * **mp3** <code> 
 +mencoder \ 
 +  <input data> \ 
 +  <input options> \ 
 +  -oac mp3lame -lameopts abr:br=128 \ 
 +  -o <output_file>
 </code> </code>
  
-x264encopts: +=== Other operations ===
-  * bitrate=<value>: constant bitrate, in kbs +
-  * crf=<1.0-50.0>: constant quality, lower is better+
  
-=== AviDemux ===+  * cut the file (here from 10'00" to 10'30"):<code> 
 +mencoder -ss 10:00 -endpos 30 -ovc copy -oac copy movie.avi -o submovie.avi 
 +</code> 
 + 
 +==== ffmpeg ==== 
 + 
 +  * video codec: ''-c:v libx264'' or ''-c:v libxvid'' 
 +  * audio codec: ''-c:a pcm_s16le'' or ''libmp3lame'' for video codec 
 +  * codec bitrate: video ''-b:v 800k'', audio ''-b:a 128k'' 
 +  * codec quality: video ''-q:v 20'', audio ''-q:a 90'', x264 ''-crf 20'' 
 + 
 +  * crop: ''-vf "crop=640:360:0:60"'' 
 +  * resize: ''-vf "scale=1280:720"'' 
 +  * pad: ''-vf "pad=1280:720:370:0"'' 
 +  * rotate: ''-vf "transpose=2"'' (0=CCW+VF, 1=CW, 2=CCW, 3=CW+VF) 
 + 
 +  * blur: ''-vf boxblur=10:1'' 
 +  * overlay two videos:<code> 
 +ffmpeg -i in1.avi -vf "movie=in2.avi [b]; [in][b] overlay=320:0" 
 +</code><code> 
 +ffmpeg -i in1.avi -i in2.avi -filter_complex "[0:v][1:v] overlay=320:0" 
 +</code> 
 + 
 +  * append side by side two videos:<code> 
 +ffmpeg -i in_left.avi -vf "pad=1280:480 [left]; movie=in_right.avi [right]; [left][right] overlay=640:0" -c:v libx264 -b:v 800k out.avi 
 +</code> 
 + 
 +  * encode video from images sequence (eg for timelapse):<code> 
 +ffmpeg -r 50 -i 01/all/image_1_%07d.pgm -c:v libx264 -b:v 800k video_01.avi 
 +ffmpeg -r 10 -pattern_type glob -i "*.JPG" -c:v libsvtav1 -qp 20 video.mp4 
 +</code> 
 + 
 +  * cut clip (ss is start time, t is duration):<code> 
 +ffmpeg -i in.avi -ss 00:00:23 -t 00:00:19 -vcodec copy -acodec copy out.avi 
 +</code> 
 + 
 +  * render subtitles (requires to be compiled with libass): ''-vf "subtitles=in.srt"'' 
 + 
 +  * transform portrait video 640x480 to landscape 1280x720 with blurry repeated sides:<code> 
 +ffmpeg -i in.avi -filter_complex "[0:v] transpose=2,scale=1280:720,boxblur=10:1 [bg]; [0:v] transpose=2,scale=540:720 [fg]; [bg][fg] overlay=370:0 [out]" -map  
 +'[out]' -map 0:a -c:v libx264 -b:v 2000k -c:a copy out.avi 
 +</code> 
 +==== AviDemux ====
  
 A GUI easier to use, like VirtualDub for Windows. A GUI easier to use, like VirtualDub for Windows.
  
-==== Audio ==== 
  
-=== mp3 ===+==== 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)", then double click to add modification points. 
 +===== Audio ===== 
 + 
 +==== mp3 ====
  
 => ''lame'' => ''lame''
Line 99: Line 224:
 </code> </code>
  
-=== ogg ===+=> ''mp3cut'' 
 + 
 +To cut an mp3 file (warning: ID3 tags are not copied): 
 +<code bash> 
 +mp3cut -o output.mp3 -t 00:00:05+700-00:00:07+800 input.mp3 
 +</code> 
 + 
 +To concatenate mp3 files: 
 +<code bash> 
 +mp3cut -o output.mp3 input1.mp3 input2.mp3 input3.mp3 
 +</code> 
 + 
 +=> ''id3cp'' 
 + 
 +To copy ID3 tags from a file to another one. 
 + 
 +=> ''id3v2'' 
 + 
 +To view and edit ID3 tags in command line. 
 + 
 +=> ''kid3'' 
 + 
 +To view and edit ID3 tags in GUI. 
 + 
 + 
 +==== ogg ====
 (using vorbis-tools package) (using vorbis-tools package)
  
Line 106: Line 256:
 To encode from wav to ogg in "speech" quality : To encode from wav to ogg in "speech" quality :
 <code bash> <code bash>
-oggenc -b 32 --downmix --resample 22050 file.wav file.ogg+oggenc -b 32 --downmix --resample 22050 file.wav -o file.ogg
 </code> </code>
  
Line 114: Line 264:
 </code> </code>
  
-=== sox === +==== sox ==== 
-play,record,process+play, record, process 
 + 
 +  * Cut: (start position / length)<code> 
 +sox in_file.wav out_file.wav trim 2:37:32 4:00 
 +</code> 
 +  * Reencode:<code> 
 +sox in_file.type1 out_file.type2 
 +sox in_file.type1 -t type2 - | oggenc ... 
 +</code> 
 + 
 +==== ffmpeg ==== 
 + 
 +  * extract sound track from video: <code> 
 +ffmpeg -i video.avi sound.mp3 
 +</code>
software/video.1279868794.txt.gz · Last modified: 2013/09/19 16:43 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0