# FFMPEG ## AVI to MP4 ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a aac -strict experimental -b:a 192k -ac 2 out.mp4 # or ffmpeg -i input.avi -c:v libx264 -crf 19 -preset slow -c:a libfaac -b:a 192k -ac 2 out.mp4 ## AVI to HEVCMP4 ffmpeg -i input.avi -c:v libx265 -crf 21 -c:a aac -c:s mov_text -f mp4 -pix_fmt yuv420p -tag:v hvc1 -movflags faststart out.mp4 ## MKV to MP4 ffmpeg -i input.mkv -codec copy output.mp4 ## to remove audio - `-an` ## reduce file size ffmpeg -vaapi_device /dev/dri/renderD129 -i interstellar.mkv -vf 'format=nv12,hwupload' -c:v hevc_vaapi -crf 23 -c:a aac -f mp4 -tag:v hvc1 Interstellar2160p.mp4 ## save a frame ffmpeg -ss 01:23:45 -i input -vframes 1 -q:v 2 output.jpg ## convert images to video ### 1 frame per image ffmpeg -i calibrate%d.jpg -c:v libx264 -pix_fmt yuv420p calibrate.mp4 ### each image shown for 5 secs at 25fps at 125 frames per image ffmpeg -framerate 1/5 -i calibrate%d.jpg -c:v libx264 -vf fps=25 -pix_fmt yuv420p calibrate.mp4 ### convert images to gif giving only 1/5th of the image to a second ./ffmpeg.exe -f image2 -r 1/5 -i assets/calibrate%d.jpg assets/calibrate.gif ## scale video ffmpeg -i input.avi -filter:v scale=720:-1 -c:a copy output.mkv ## crop video w:h:x:y ./ffmpeg.exe -i assets/clock.mp4 -c:v libx264 -pix_fmt yuv420p -filter:v "crop=300:300:0:0,fps=20" assets/clock300x300r20.mp4 ### by time -ss 00:00:07.8 -to 00:02:00 ## record screens ``` ffmpeg -video_size 800x600 -framerate 25 -f x11grab \ -i :0.0+, screenreocrd1.mp4 ``` ## create live m3u8 stream ffmpeg -video_size 800x600 -framerate 15 -f x11grab -i :0.0+5,60 -f pulse -i default -c:v libx264 -pix_fmt yuv420p -profile:v baseline -level 3.0 -b:v 1000k -preset ultrafast -tune zerolatency -keyint_min 45 -g 45 -sc_threshold 0 -c:a aac -b:a 96k -f hls -hls_time 3 -hls_list_size 10 -hls_segment_type mpegts -hls_flags program_date_time -hls_segment_filename /mnt/ventoy/workspace/WWW-development/files/user/necktwi/doom/stream%04d.ts /mnt/ventoy/workspace/WWW-development/files/user/necktwi/doom/stream.m3u8 ## list supported formats ffmpeg -formats ffmpeg -codecs ffmpeg -encoders ffmpeg -decoders ffmpeg -h encoder=h264 ffmpeg -hwaccels ## build on qnx export SYSROOT=/c/qnx700/target/qnx7/aarch64le export TOOLCHAIN=/c/qnx700/host/win64/x86_64 ../configure --disable-x86asm --prefix=./install --target-os=qnx --cross-prefix="$TOOLCHAIN/usr/bin/aarch64-unknown-nto-qnx7.0.0-" --arch=aarch64 --sysroot=$SYSROOT --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-pthreads --enable-small --enable-cross-compile --enable-static --enable-nonfree --extra-cflags="-I$TOOLCHAIN/usr/lib/gcc/aarch64-unknown-nto-qnx7.0.0/5.4.0/include" --nm=$TOOLCHAIN/usr/bin/aarch64-unknown-nto-qnx7.0.0-nm ## yt-dlp