FFMpeg
FFMpeg¶
Transcode¶
Rewrap a file
ffmpeg -i input_video.mkv -c copy -map 0 input_video.avi
ReTranscode a file to h.264
ffmpeg -i input_file -c:v libx264 -pix_fmt yuv420p -c:a aac -preset veryslow -movflags +faststart output_file
ReTranscode a file to h.264
ffmpeg -i input_file -c:v libx265 -pix_fmt yuv420p -c:a aac -preset veryslow -crf 18 -movflags +faststart output_file
Create high quality GIF:
ffmpeg -ss HH:MM:SS -i input_file -filter_complex "fps=10,scale=500:-1:flags=lanczos,palettegen" -t 3 palette.png
Change or view audio properties¶
Fix MP3 tags:
ffmpeg -i file_orig.mp3 -acodec copy file_fixed.mp3
Extract and encode Audio from video:
ffmpeg -i input-video.avi -vn -acodec copy output-audio.aac
Add another Audio from video:
ffmpeg -i input_video.mkv -i new_audio.mp3 -map 0 -map 1:a -c:v copy -shortest output.mkv
Split audio and video tracks:
ffmpeg -i input_file -map 0:v:0 video_output_file -map 0:a:0 audio_output_file
Fix Audio Sync
ffmpeg -i input_file -c:v copy -c:a pcm_s16le -af "aresample=async=1000" output_file
Transcode to FLAC:
flac --best --keep-foreign-metadata --preserve-modtime --verify input.wav
Transcode from FLAC:
flac --decode --keep-foreign-metadata --preserve-modtime --verify input.flac
Join, trim, or create an excerpt¶
Join video files together:
ffmpeg -i input_1.avi -i input_2.mp4 -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[video_out][audio_out]" -map "[video_out]" -map "[audio_out]" output_file
Split file into segments:
ffmpeg -i input_file -c copy -map 0 -f segment -segment_time 60 -reset_timestamps 1 output_file-%03d.mkv
Trim File:
ffmpeg -i input_file -ss 00:02:00 -to 00:55:00 -c copy -map 0 output_file
Merge audio and video tracks:
ffmpeg -i video_file -i audio_file -map 0:v -map 1:a -c copy output_file
Subtitles¶
Embed a subtitle file into a movie file:
ffmpeg -i input_file -i subtitles_file -c copy -c:s mov_text output_file
Strips metadata from video file:
ffmpeg -i input_file -map_metadata -1 -c:v copy -c:a copy output_file
Video¶
Bluray¶
Rip a Blueray:
#Rip from a bluray the main file is usually at index 0 but you can always rip all indexes replacing the 0 index with all
makemkvcon -r --decrypt --progress=-same mkv dev:/dev/sr0 0 .
Renecode 1080p BluRay:
Renecode 4K BluRay:
#https://www.thewebernets.com/2023/07/02/best-optimal-handbrake-settings-to-convert-4k-bluray-to-h-265-hevc-on-mac-windows-linux/