===== ffmpeg toolbox =====
//⚠ This page probably uses CLI tools referenced [[en:tools:linux:misc-tools|here]]//
* [[man>ffmpeg]]
* [[man>parallel]]
==== Davinci Resolve ====
[[en:tools:misc:davinci-startup|Davinci Resolve]]
conversion of 1 ''.mov'' file:
ffmpeg -i monfichier.truc -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov monfichier.mov
The ''-q:v x'' option defines the quality of the conversion.
Convert a folder at once :
for i in *.MTS; do ffmpeg -i "$i" -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov "${i%.*}.mov"; done
convert all tree at once :
find . -type f -not -name "*.jpg" -not -name "*.png" -not -name "*.JPG" -not -name "*.JPEG" -print0 | parallel -0 --eta ffmpeg -loglevel 0 -i {} -vcodec mjpeg -q:v 2 -acodec pcm_s16be -q:a 0 -f mov {.}-trans.mov
//⚠ Beware, this command takes into account several file types that could be found on a SD card and converts everything that doesn't match an image extension.//
option to change size : ''-s 720x480''
proxy creation command : mkdir proxy; for i in *.MOV; do ffmpeg -i "$i" -vcodec mjpeg -q:v 10 -acodec pcm_s16be -q:a 0 -f mov "proxy/${i%.*}.mov"; done
==== Conversion to x.265 ====
In order to gain space on warez, the ideal is to convert the ''x264'' encoded movies to the ''x265'' allowing for size reduction up to a factor of 10!
The ''-crf 26'' option defines the compression, with a value of ''0'' it is lossless, up to ''51'' the worst. The value ''26'' corresponds to the usual compression level of x264 media and allows therefore a good gain of space with minimal loss of quality.
the pixel format defined by ''format=yuv420p'' (8bits) can be replaced by ''format=yuv420p10le'' (10bits) for compatible media at the cost of space advantage. (to find the pixel format of the original media: ''ffprobe -i myfile.mkv''
[[https://trac.ffmpeg.org/wiki/Encode/H.264|ffmpeg documentation]]
find . -type f -name "*mkv" -print0 | parallel -0 --eta ffmpeg -loglevel 0 -i {} -map 0 -c:v libx265 -crf 26 -vf format=yuv420p -c:a copy {.}-x265.mkv
==== Reduce the size of MP3s ====
Command to reduce the size of a whole tree of ''.mp3'' files to use an ancestral mp3 player with only 256MB of internal memory:
find -type f -name "*.mp3" -o -name "*.wav" -print0 | parallel -0 --eta ffmpeg -loglevel 0 -i {} -vn -ac 2 -b:a 96k {.}-smol.mp3