Skip to content

Instantly share code, notes, and snippets.

@edsu
edsu / mix.sh
Last active May 27, 2024 13:44
Concat two mp4 files with different resolutions.
# concatenate two videos with different resolution
ffmpeg -i part1.mp4 -i part2.mp4 -filter_complex "[0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1[v0];[1]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1[v1];[v0][0:a:0][v1][1:a:0]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" out.mp4
@marcduiker
marcduiker / ffmpeg_video_for_twitter.md
Last active June 1, 2024 04:35
FFmpeg command for creating video for Twitter

Convert pngs to mp4

This FFmpeg command reads images named frame_[4 char digit].png and converts it to an mp4 using the h264 encoding which Twitter accepts. The bitrate is set to 5M to reduce blocking as much as possible while keeping the size small.

ffmpeg -framerate 10 -i frame_%04d.png -c:v h264_qsv -b:v 5M video.mp4

Convert and scale an existing mp4 to 1080:

ffmpeg -i input.mp4 -c:v h264_qsv -vf: scale=1080:-1 -b:v 5M output.mp4

@kimus
kimus / ufw.md
Created March 2, 2014 22:46
NAT and FORWARD with Ubuntu’s ufw firewall

UFW

I use Ubuntu’s Uncomplicated firewall because it is available on Ubuntu and it's very simple.

Install UFW

if ufw is not installed by default be sure to install it first.