Delay by 5 seconds (the audio starts 5 seconds after the video):
ffmpeg -i in.mp4 -itsoffset 5 -i in.mp4 -map 1:v -map 0:a -c copy out.mp4
Trim by 5 seconds using negative number. Remember: it's the opposite way of how VLC displays this (negative is positive).
ffmpeg -i input.mkv -map 0 -c:v libx264 -crf 18 -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -c:a copy output.mkv
En considérant que le stream des sous-titres est 0:3 :
ffmpeg -i input.mkv -map 0:0 -map 0:1 -map 0:2 -map 0:3 -disposition:s -default -default_mode infer_no_subs -c copy output.mkv
Traitement de masse :
for i in *.mkv; do ffmpeg -i "$i" -map 0:0 -map 0:1 -map 0:2 -map 0:3 -disposition:s -default -default_mode infer_no_subs -c copy "./DONE/${i%.mkv}-test.mkv"; done
ffmpeg -loop 1 -i img.jpg -i music.mp3 -shortest -acodec aac -vcodec libx264 result.mp4
# Batch download
youtube-dl -i -F -a ~/Desktop/list.txt # Get the format
youtube-dl -i -f <format> -a ~/Desktop/list.txt # Use the format
# Automagically download the desired resolution
youtube-dl -i -f "bestvideo[height<=720]+bestaudio/best[height<=720]" -a ~/Desktop/list.txt
## Avoid throttling
youtube-dl -i --external-downloader aria2c --external-downloader aria2c --external-downloader-args "-j 8 -s 8 -x 8 -k 5M" -f mp4-240p -a ~/Desktop/list.txt
youtube-dl -f 18 -4 -i https://www.youtube.com/watch?v=uhikhkih # Use IPv4
## Rate limit
youtube-dl -i -r 120k -a ~/Desktop/list.txt
# Batch download
wget -r -H -nc -np -nH --cut-dirs=1 -e robots=off -l1 -i ~/Desktop/list.txt
# Rate limit
wget --no-check-certificate --limit-rate 60k https://trucmuche.com/truc.mp3
wget --no-check-certificate --limit-rate 20k -i ~/Desktop/list.txt # Batch download
# Recursively fetch a directory
wget -r --no-parent --reject "index.html*" -e robots=off http://example.com/configs/.vim/
## To avoid downloading the directory structure as well
wget -r -nH -nd -np -R index.html* -e robots=off http://example.com/configs/.vim/
# Avoid the robots.txt issue
-e robots=off (See http://www.krazyworks.com/wget-and-user-agent-header/)
# Download one type only
-A jpeg,jpg,bmp,gif
# Use a user-agent
-U -U "Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.0.2) Gecko/20121223 Ubuntu/9.25 (jaunty) Firefox/3.8"
# So, get only fonts in an entire site
wget -r --no-parent --reject "index.html*" -e robots=off --limit-rate 60k -A otf,ttf,ttc,dfont
# Convert multiple video to audio
for i in *.mp4; do ffmpeg -i "$i" -vn "${i%mp4}mp3"; done
# Convert avi to mp4
for i in *.avi; do ffmpeg -i "$i" -c:a aac -b:a 128k -c:v libx264 -crf 23 -preset fast -profile:v baseline -level 3.0 -threads 2 "${i%avi}mp4"; done
# Convert mkv to mp4
for i in *.mkv; do ffmpeg -i "$i" -c:a aac -b:a 128k -c:v libx264 -crf 23 -preset fast -s 720x480 -threads 2 "${i%mkv}mp4"; done
# Convert .png to .jpg
for i in *.png; do mogrify -format jpg "$i" && rm "$i"; echo "$i converted to ${i%.*}.jpg"; done
# Same, but recursive
find . -iname '*.png' | while read i; do mogrify -format jpg "$i" && rm "$i"; echo "Converted $i to ${i%.*}.jpg"; done
# Randomize name
for i in *.mp4; do mv -i "$i" "${RANDOM}.mp4"; done
# Recursive copy
find . -name "*.zip" -exec cp -t ./direction_dir {} +
find . -type f -name "*.mp3" -exec cp {} /tmp/MusicFiles \ # Alternative
# Recursive deletion
find . -name "*.*" -print0 | xargs -0 rm -rf
# Recursive md5sum
find -type f -exec md5sum "{}" + > checklist.chk
# Recursive rename with modified date
j=1; for i in `find . -type f`; do mv -- "$i" "$(date +%Y-%m-%d_%H\'%M\'%S -r $i)_$j.${i##*.}"; j=$((j + 1)); done
## Will output: 2021-02-01_15'16'06_foo.webm
## Note: use IFS=$'\n' before the loop, for find to understand space in filename (mandatory on Windows)
# Recursive move from multiple folder, renaming the files to add the folder they was in
ls . > list; while read LINE <&3; do for i in `find $LINE -name "*.svg"`;do filename=$(basename -- "$i"); cp $i "$LINE-$filename"; done; done 3< list; rm list;
# Recursive move in folders
for j in {01..31}; do for i in `find . -name "*\-$j\_*"`; do mkdir -p "$j" && cp "$i" "$j/"; done; done
## Use case: we have a bunch of files named 2021-02-01_15'16'06_bar.webm, we want them to be moved into the folder corresponding to their month (01 to 31)
# Simple
for i in *.mp4; do ffmpeg -i "$i" -an -s 320x240 -pix_fmt rgb24 -r 10 "${i%mp4}gif"; done
# Optimal with compression
for i in *.webm; do ffmpeg -i "$i" -vf fps=10,scale=320:-1:flags=lanczos,palettegen "$i.png"; ffmpeg -i "$i" -i "$i.png" -filter_complex 'fps=10,scale=320:-1:flags=lancz os[x];[x][1:v]paletteuse' "${i%webm}gif"; rm "$i.png"; done
# Recursive on the first 15 seconds with deletion of step's products
for i in `find . -name "*.webm"`;do ffmpeg -ss 0 -t 15 -i "$i" -vf fps=10,scale=320:-1:flags=lanczos,palettegen "$i.png"; ffmpeg -ss 0 -t 15 -i "$i" -i "$i.png" -filter_complex 'fps=10, scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse' "${i%webm}gif"; rm "$i.png"; rm "$i";done
# Get filename and extension
filename=$(basename -- "$fullfile")
extension="${filename##*.}"
filename="${filename%.*}"
ffmpeg -i "concat:1.mp3|2.mp3|3.mp3|4.mp3|5.mp3|6.mp3|7.mp3|8.mp3|9.mp3|10.mp3|11.mp3|12.mp3|13.mp3|14.mp3|15.mp3|16.mp3|17.mp3|18.mp3|19.mp3|20.mp3" -codec copy test.mp3
ffmpeg -i fichier_entree.avi -pix_fmt rgb24 \
-s 120x120\
-r 5\
fichier_sortie.gif
ffmpeg -i input.avi -c:a aac -b:a 128k -c:v libx264 -crf 23 output.mp4
mkdir anim && cd anim
ffmpeg -ss 14:55 -i video.mkv -t 5 -s 480x270 -f image2 %03d.png
seq -f %03g.png 10 3 72
convert -delay 1x8 `seq -f %03g.png 10 3 72` \
-coalesce -layers OptimizeTransparency animation.gif
convert -fuzz 1% -delay 1x8 `seq -f %03g.png 10 3 72` \
-coalesce -layers OptimizeTransparency animation.gif
or even :
convert -delay 1x8 `seq -f %03g.png 10 3 72` \
-ordered-dither o8x8,8 \
-coalesce -layers OptimizeTransparency \
+map animation.gif
find . -iname '*.mov' -type f -exec ffmpeg -i {} -f flv {} \;
ffmpeg -i input.mov -c:v libx264 -preset slow -crf 18 -c:a aac -b:a 192k -pix_fmt yuv420p output.mkv
Stabilisons nos vidéos avec FFmpeg et VidStab !
for i in *.mp4; do ffmpeg -i "$i" -ab 128k "${i%mp4}mp3"; done
ffmpeg -i input.mp4 -ss 00:00:50.0 -codec copy -t 20 output.mp4
ffmpeg -i video.mp4 -t 00:00:50 -c copy small-1.mp4 -ss 00:00:50 -codec copy small-2.mp4
ffmpeg -i video.mp4 -an mute-video.mp4
ffmpeg -i video.mp4 -vn -ab 256 audio.mp3
ffmpeg -i video.mp4 -vf scale=500:-1 -t 10 -r 10 image.gif
ffmpeg -ss 00:00:15 -i video.mp4 -vf scale=800:-1 -vframes 1 image.jpg
ffmpeg -i movie.mp4 -r 0.25 frames_%04d.png
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -strict experimental output.mp4
ffmpeg -i input.mp4 -s 480x320 -c:a copy output.mp4
ffmpeg -r 1/5 -i img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p slideshow.mp4
ffmpeg -loop 1 -i image.jpg -i audio.mp3 -c:v libx264 -c:a aac -strict experimental -b:a 192k -shortest output.mp4
-t
parameter is the video duration)
ffmpeg -loop 1 -i image.png -c:v libx264 -t 30 -pix_fmt yuv420p video.mp4
ffmpeg -i movie.mp4 -i subtitles.srt -map 0 -map 1 -c copy -c:v libx264 -crf 23 -preset veryfast output.mkv
ffmpeg -ss 00:01:30 -t 30 -acodec copy -i inputfile.mp3 outputfile.mp3
ffmpeg -i input.wav -af 'volume=0.5' output.wav
ffmpeg -i input.mp4 -filter:v 'transpose=1' rotated-video.mp4
ffmpeg -i input.mp4 -filter:v 'transpose=2,transpose=2' rotated-video.mp4 # 180° counter-clockwise
ffmpeg -i input.mp4 -filter:v "setpts=0.125*PTS" output.mp4
ffmpeg -i input.mkv -filter:a "atempo=2.0" -vn output.mkv
$ cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4