ffmpeg, convert (imagemagick) and MeshLab crib sheetAssembled by Paul BourkeStarted June 2018, ongoing ...
A small collection of helpful command lines for ffmpeg and convert (imagemagick). Certainly not trying to be comprehensive but a note to myself for things I seem to need to do regularly. Collated here to save myself digging around on-line and/or through the respective manuals. Hopefully others may find them useful also. If you think the following are incomplete, can be improved, or if you would like to add your own please drop me an email. ffmpegConvert mp4 to mov.
ffmpeg -i inputmoviename -acodec copy -vcodec copy -f mov outputmovienameConvert frames to movie using Apple animation codec ffmpeg -framerate 30 -i inputframes%04d.png -vcodec qtrle outputmovienameConvert from mov to mp4 ffmpeg -i inputmoviename -vcodec copy -acodec copy outputmovienameConvert from mov to mp4 using h265 compression, default preset is medium, default crf is 28 ffmpeg -i inputmoviename -c:v libx265 -preset slow -crf 25 -acodec copy outputmovienameAdd audio to existing movie, transcoding the audio ffmpeg -i inputvideo.mp4 -i inputaudio.wav -c:v copy -c:a aac output.mp4Used for making mp4 for Gear VR, this was 2015, may have changed now. ffmpeg -framerate 30 -i inputframename%04d.png -c:v libx264 -profile:v high -crf 18 -pix_fmt yuv420p outputmovienameExtract frames ffmpeg -i inputmoviename -q:v 1 directoryname/outputframename%04d.tgaExtract a single frame ffmpeg -ss 00:01:00 -i inputmoviename -vframes 1 -q:v 1 outputimagenameExtract a time range from a movie ffmpeg -i inputmoviename -ss 00:03:00 -t 00:01:00 outputmovienameExtract 16 bit from greater than 8 bit movies, eg: GH5 ffmpeg -i inputmoviename -vf "format=pix_fmts=rgb48" directoryname/outputframename%04d.pngExtract frames and scale ffmpeg -i inputmoviename -vf scale=2048:1080 -q:v 1 directoryname/outputframename%04d.tgaExtract frames and rotate by multiples of 90 degrees (see transpose options) ffmpeg -i inputmoviename -vf transpose=2 -q:v 1 directoryname/outputframename%04d.tgaBuild mp4 movie from frames ffmpeg -r 30 -i scene%04d.tga -c:v libx265 -crf 20 outputmovienameBuild mp4 movie from frames for system that don't fully support yuv444p ffmpeg -r 30 -i scene%04d.jpg -c:v libx264 -crf 20 -pix_fmt yuv420p outputmoviename ffmpeg -r 30 -i scene%04d.png -c:v libx265 -crf 26 -tag:v hvc1 -pix_fmt yuv420p outputmovienameBuild mp4 from frames and audio ffmpeg -r 30 -i dirname/frame_%d.jpg -i audio.mp4 -c:a copy -c:v libx265 outputmovie.mp4 ffmpeg -r 30 -i dirname/frame_%d.jpg -i audio.mp4 -c:a copy -c:v libx265 -crf 24 outputmovie.mp4 ffmpeg -r 30 -i dirname/frame_%d.jpg -i audio.mp4 -c:a copy -c:v libx264 -crf 18 outputmovie.mp4Convert and apply remap filter ffmpeg -i inputmoviename -i 0001_x.pgm -i 0001_y.pgm -lavfi remap outputmovienameFor missing values the chroma key colour is used, to change from green to black ffmpeg -i inputmovie -i x.pgm -i y.pgm -lavfi remap=fill=black outputmovieConvert and apply cropping ffmpeg -i inputmoviename -filter:v "crop=out_w:out_h:x:y" outputmovienameMovie encoding from frames, proposed for fulldome video using Watchout ffmpeg -threads auto -r 30 -i "inputframedirectory/inputframename%04d.png" -f vob -vcodec mpeg2video -b:v 30000k -minrate 30000k -maxrate 30000k -g 15 -bf 2 -an -trellis 2 "outputmoviename.m2v"Movie encoding from frames with HAP codec, proposed for Vioso Wings fulldome playback. Ensure ffmpeg is installed "with-snappy". ffmpeg -r 30 -i "inputframedirectory/inputframename%04d.tga" -vcodec hap -format hap -r 30 outputmovienameMovie information. ffmpeg -i movienameScale a movie. ffmpeg -i inputmoviename -filter:v scale=640:480 -c:a copy outputmovienameExtract a time segment from a movie. ffmpeg -i inputmoviename -ss 00:00:30 -t 00:00:50 -codec copy outputmovienameQuickTime movie to animated gif. (Contributed by Jordi VallverdĂș Alcover) ffmpeg -ss 00:00:00.000 -i input.mov -pix_fmt rgb24 -r 10 -s 320x240 -t 00:00:10.000 output.gif convert -layers Optimize output.gif output_optimized.gifRecord from webcam (Mac OSX) ffmpeg -f avfoundation -list_devices true -i "" ffmpeg -f avfoundation -framerate 30 -video_size 1280x720 -pixel_format rgb24 -i "0:0" out.mov ffmpeg -f avfoundation -framerate 30 -video_size 1280x720 -i "0:0" -c:v libx264 -crf 22 out.mp4Append two movies side by side ffmpeg -i inputmovie1 -i inputmovie2 -filter_complex "[0:v:0]pad=iw*2:ih[bg]; [bg][1:v:0]overlay=w" -c:v libx264 outputmovienameAppend two movies side by side or top and bottom ffmpeg -i inputmovie1 -i inputmovie2 -filter_complex vstack outputmoviename ffmpeg -i inputmovie1 -i inputmovie2 -filter_complex hstack outputmoviename convert (imagemagick)Resize proportionatelyconvert inputfilename -resize 4096x2048 outputfilename.jpgResize forced convert inputfilename -resize 4096x2048\! outputfilename.jpgCrop, supply size and origin convert -crop 256x256+1024+0 inputfilename.exr outputfilename.jpgConcatenate N images horizontally convert inputfilename1.jpg inputfilename2.jpg ... inputfilenameN.jpg +append outputfilename.jpgConcatenate N images vertically convert inputfilename1.jpg inputfilename2.jpg ... inputfilenameN.jpg -append outputfilename.jpgSpecify jpeg compression quality convert -quality 90 -verbose inputfilename.tga outputfilename.jpgCreate pyramidal tiff convert inputimagename.tif -define tiff:tile-geometry=256x256 -compress jpeg 'ptif:outputfilename.ptif'Create an animated gif. convert -delay 120 -loop 0 inputframesequence*.png outputfilename.gifConvert a raw RGB file to tiff. convert -size WIDTHxHEIGHT -depth 16 inputfilename.rgb outputfilename.tiff MeshLabWhile most people engage with MashLab through the graphical interface, it is possible to script operations on the command line. This is accomplished through the meshlabserver. Details on different platforms may differ, for example in the location of the server, but on the Mac it might be invoked as follows: /Applications/meshlab.app/Contents/MacOS/meshlabserver -i $1.obj -o $1_cleaned.obj -m wt -s clean.mlx The .mlx file describes the operations to be performed, in this case clean.mlx might be <!DOCTYPE FilterScript> <FilterScript> <filter name="Remove Unreferenced Vertices"/> <filter name="Remove Zero Area Faces"/> <filter name="Remove Duplicate Vertices"/> <filter name="Remove Duplicate Faces"/> <filter name="Merge Close Vertices"> <Param type="RichAbsPerc" description="Merging distance" min="0" max="0.012423" tooltip="All the vertices that closer than this threshold are merged together. Use very small values, default values is 1/10000 of bounding box diagonal. " name="Threshold" value="0.00012423" isxmlparam="0"/> </filter> </FilterScript>Remove unreferenced vertices <!DOCTYPE FilterScript > <FilterScript> <filter name="Remove Unreferenced Vertices"/> </FilterScript>Decimate a mesh CTYPE FilterScript> <FilterScript> <filter name="Simplification: Quadric Edge Collapse Decimation (with texture)"> <Param value="1000000" name="TargetFaceNum" description="Target number of faces" isxmlparam="0" tooltip="" type="RichInt"/> <Param value="0" name="TargetPerc" description="Percentage reduction (0..1)" isxmlparam="0" tooltip="" type="RichFloat"/> <Param value="0.3" name="QualityThr" description="Quality threshold" isxmlparam="0" tooltip="" type="RichFloat"/> <Param value="1" name="Extratcoordw" description="Texture Weight" isxmlparam="0" tooltip="" type="RichFloat"/> <Param value="false" name="PreserveBoundary" description="Preserve Boundary of the mesh" isxmlparam="0" tooltip="" type="RichBool"/> <Param value="1" name="BoundaryWeight" description="Boundary Preserving Weight" isxmlparam="0" tooltip="" type="RichFloat"/> <Param value="true" name="OptimalPlacement" description="Optimal position of simplified vertices" isxmlparam="0" tooltip="" type="RichBool"/v <Param value="true" name="PreserveNormal" description="Preserve Normal" isxmlparam="0" tooltip="" type="RichBool"/> <Param value="true" name="PlanarQuadric" description="Planar Simplification" isxmlparam="0" tooltip="" type="RichBool"/> <Param value="false" name="Selected" description="Simplify only selected faces" isxmlparam="0" tooltip="" type="RichBool"/> </filter> </FilterScript>Remove zero area faces <!DOCTYPE FilterScript> <FilterScript> <filter name="Remove Zero Area Faces"/> </FilterScript> |