useful commands¶
Batch convert PNG to JPG:
magick mogrify -format jpg *.png
Compress single JPG:
magick convert [original image] -resize '1024>' -quality 50 [converted image name]
Batch compress JPG:
magick mogrify -resize '1024>' -quality 50 *.jpg
Convert and compress MOV to MP4 and remove audio:
ffmpeg -i input.mov -q:v 0 -vcodec libx264 -b:v 500k -vf scale=-2:500 -an output.mp4
Compress, scale MP4 and remove audio:
ffmpeg -i input.mp4 -vcodec libx264 -b:v 500k -vf scale=-2:500 -an output.mp4
Trim video from timemarker (11 seconds) to timemarker (20 seconds):
ffmpeg -ss 11s -accurate_seek -i input.mp4 -t 20s output.mp4
Rotate video 90 degrees counter-clockwise (use transpose=1 for clockwise):
ffmpeg -i input.mp4 -vf "transpose=2" output.mp4
Speed up video 24x:
ffmpeg -i input.mp4 -filter:v "setpts=PTS/24" output.mp4
Add text to a video:
ffmpeg -i input.mp4 -vf "drawtext=text=Hello World!:font=Arial:fontsize=50:fontcolor=white:x=20:y=10" -codec:a copy output.mp4
Add video to markdown (using obsidian):
<video controls>
<source src="../assets/video.mp4" type="video/mp4">
</video>
(not sure why it doesn’t play in obsidian though)
Linux¶
Check sizes of files:
ncdu
(install using sudo apt install ncdu
)
Git¶
git status
-> get git status of the files
git add .
-> add all files to stage
git commit -m "commit comment"
-> commit the staged files with a comment
git push
-> push committed files to the repo
git rm -r <file/path>
-> stage file (or complete folder) to be removed from repo (next do a commit and push to effectuate)
git restore --staged <file/path>
-> undo git add. So remove file from staged list.
.gitignore
is a file that allows you to define files and folders to NOT be added to your git repo.
If you do a git status
you should not see the file listed in gitignore (that means the gitignore works).
If the files have already been commited once, they are already tracked and thus skipping .gitignore.