Skip to content

Instantly share code, notes, and snippets.

@psu
Last active March 19, 2026 22:28
Show Gist options
  • Select an option

  • Save psu/abe8dec7377883c5a7b5749a87bf7ff2 to your computer and use it in GitHub Desktop.

Select an option

Save psu/abe8dec7377883c5a7b5749a87bf7ff2 to your computer and use it in GitHub Desktop.
Useful Shell Commands

Useful Shell Commands

ffmpeg

Convert .mkv to .mp4

ffmpeg -i "${input_file}" -vcodec copy -acodec copy "${output_file_name}".mp4

Downscale

ffmpeg -i input.mov -vf scale=886:1920 output.mov

H.264

ffmpeg -i input.flv -vcodec libx264 output.mp4

Remove audio

ffmpeg -i $input_file -c copy -an $output_file

Add silent track

ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i video.mov -c:v copy -c:a aac -shortest output.mov

Set framerate

ffmpeg -i input -r 30 output

App Store iPhone-ready output

ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i INPUT.mov -vf scale=886:1920 -vcodec libx264 -acodec aac -shortest -r 30 OUTPUT.mp4

App Store iPad-ready output

ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i INPUT.mov  -vf "crop=1600:1200:118:0" -vcodec libx264 -acodec aac -shortest -r 30 OUTPUT.mp4

File Handling

Change encoding for text file

iconv -f "ISO-8859-1" -t "UTF-8" "${input_file}" -s > "${output_file}"

Remove tags and move to Archive folder

for file in {query}
do

  # remove tag information in extended attributes, FinderInfo contains color info
  xattr -d com.apple.metadata:_kMDItemUserTags "$file"
  xattr -d com.apple.FinderInfo "$file"

  # move file
  mv "$file" "$archive_path"

done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment