Skip to content

Instantly share code, notes, and snippets.

@jaimemrjm
Last active May 12, 2025 22:01
Show Gist options
  • Save jaimemrjm/7ab3b2c0923e3c8efbc199e7747485a7 to your computer and use it in GitHub Desktop.
Save jaimemrjm/7ab3b2c0923e3c8efbc199e7747485a7 to your computer and use it in GitHub Desktop.
Multimedia tips for Linux about format conversions, removing noise, etc.

Video tips for Linux

Convert any video file to HEVC

HEVC

Convert any video file to HEVC (H.265) keeping audio tracks:

ffmpeg -i <input_file> -c:v libx265 -x265-params crf=23 -c:a copy <output_file>

AVC

Convert a Bluray disc to AVC (H.264) by using VA-API hardware acceleration. Replace 5000k to your choosen bitrate:

sudo mount -o loop bluray_dumped.iso /mnt/bluray`
ls -lh /mnt/bluray/BDMV/STREAM/ | sort -k 5 -h # Check the biggest m2ts files
fmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -i /mnt/bluray/BDMV/STREAM/00002.m2ts -vf 'format=nv12,hwupload' -map 0:0 -map 0:1 -threads 8 -aspect 16:9 -y -f matroska -acodec copy -b:v 5000k -vcodec h264_vaapi output.mkv

Source: https://gist.github.com/Brainiarc7/95c9338a737aa36d9bb2931bed379219#encoding-with-vaapi

Convert ASS / SSA subtitles to SRT in batch

To avoid server transcoding or playing issues in limited devices:

for i in *.mkv; do ffmpeg -i "$i" -map 0:v -map 0:a -map 0:s -c copy -c:s srt "${i%.*}-new.mkv"; done

Convert audio format in a Matroska video (.mkv file) to get wider compatibility:

ffmpeg -i input_file.mkv -c:v copy -c:a libmp3lame -b:a 128k output_file.mkv 

Extract audio from Youtube video

 youtube-dl --output "%(title)s.%(ext)s" --extract-audio --audio-format mp3 "http://youtube.com/the_video"

Remember to keep youtube-dl updated from pip.

Check codecs using vaapi

ffmpeg -codecs | grep vaapi 

Audio tips for Linux

Remove noise or echo in the microphone input

Edit the /etc/pulse/default.pa file as root and comment out or add this line:

load-module module-echo-cancel

Source: [1]: https://askubuntu.com/questions/18958/realtime-noise-removal-with-pulseaudio

Photo and image editing

Resize images automatically

find . -iname "*.jpg" | xargs -l -i convert -resize 50% -quality 80 {} /tmp/xxxxx/{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment