Skip to content

Instantly share code, notes, and snippets.

@abhijitparida
Last active December 23, 2020 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abhijitparida/48bd27ff75a71398b5704758febfe19e to your computer and use it in GitHub Desktop.
Save abhijitparida/48bd27ff75a71398b5704758febfe19e to your computer and use it in GitHub Desktop.
A collection of useful scripts/snippets

Useful Scripts

  1. FFmpeg
  2. Take screenshots thru adb
  3. Serve current directory
  4. Fix boot
  5. /etc/fstab entry for NTFS partitions
  6. Force time sync on Ubuntu/Windows dual boot
  7. Windows
  8. Base64
  9. File Hashes

FFmpeg

hvec -> h.264 (for gopro)

$ ffmpeg -i input.mp4 -c:v libx264 -crf 18 -c:a copy output.mp4

Ref: https://superuser.com/a/1381151

m4a -> mp3

Useful for converting .m4a's downloaded with youtube-dl.

(Runs on all files in the current directory)

$ for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -ab 192k "${f%.m4a}.mp3"; done

compress/rencode mp4

From lukehedger/ffmpeg-compress-mp4

Adjust -threads, -hwaccel and scale according to hardware capability and need.

(Runs on all files in the current directory)

$ for f in *.mp4; do ffmpeg -threads 4 -hwaccel auto -i "$f" -vf scale=-1:1080 -vcodec h264 -acodec mp2 "${f%.mp4}_rencode.mp4"; done

resize images

Adjust -threads and scale according to hardware capability and need.

(Runs on all files in the current directory)

$ for f in *.jpg; do ffmpeg -threads 4 -i "$f" -vf scale=-1:2160 "${f%.jpg}_rencode.jpg"; done

timelapse from an existing video

$ ffmpeg -i in.mp4 -vf select='not(mod(n\,30))',setpts=N/FRAME_RATE/TB -an out.mp4

Take screenshots thru adb

Useful for taking Geanymotion screenshots.

$ adb shell screencap -p | sed 's/\r$//' > screenshot_`date "+%Y-%m-%d-%H-%M-%S"`.png

Serve current directory

with Python 2

$ python2 -m SimpleHTTPServer 8000

with Python 3

$ python3 -m http.server 8000

Fix boot

Change sda1 wherever mentioned to your disk name. Use fdisk -l to find disk names.

for Arch

# mount /dev/sda1 /mnt
# arch-chroot /mnt
# grub-install /dev/sda
# grub-mkconfig -o /boot/grub/grub.cfg

dirty NTFS partitions

# ntfsfix /dev/sda1
# ntfsfix -d /dev/sda1

for Ubuntu (and similar)

Boot from a DVD/live USB.

# mount /dev/sda1 /mnt
# for i in /sys /proc /run /dev; do mount --bind "$i" "/mnt$i"; done
# chroot /mnt
# grub-install /dev/sda
# update-grub

for Windows

Use the System Recovery Environment Command Prompt.

> bootrec /FixMbr
> bootrec /FixBoot

/etc/fstab entry for NTFS partitions

Use fsblk or blkid to get UUID. Make sure /media/disk1 directory exists.

UUID=XXXXXXXXXXXXXXXX  /media/disk1  ntfs  defaults  0  0

Force time sync on Ubuntu/Windows dual boot

$ timedatectl set-local-rtc 1

Windows

Turn off Xbox DVR on Windows 10

From https://support.steampowered.com/kb_article.php?ref=6239-DZCB-8600#appreg

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\System\GameConfigStore]
"GameDVR_Enabled"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\GameDVR]
"AllowGameDVR"=dword:00000000

Reboot to apply changes.

Internet shortcut -> normal shortcut

%windir%\explorer.exe https://example.com

Base64

$ base64 <filename>
$ base64 -d <filename>

File Hashes

$ md5sum <filename>
$ sha1sum <filename>

HashTab: http://implbits.com/products/hashtab/

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