Git Product home page Git Product logo

helpful-commands's Introduction

Helpful commands

Commands I use regularly.

Open and Save JSON

# Open
f = open('data.json')
data = json.load(f)

# Save
with open(<path>, 'w') as f:
    json.dump(<dict>, f, indent=4, sort_keys=True)

Imshow

cv2.imshow("window name", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

Convert video to images

ffmpeg -i s1v1.avi %06d.png

# Vice versa
ffmpeg -i %06d.png output.mp4

# If the filenames don't begin with 0 or have missing indices
ffmpeg -framerate 5 -pattern_type glob -i '*.png' out.mp4

Clip video (order of arguments matter!)

ffmpeg -ss 0 -t 15 -i squats_feedback.mp4 -acodec copy -vcodec copy side_view.mp4

Crop video

# out_w is the width of the output rectangle
# out_h is the height of the output rectangle
# x and y specify the top left corner of the output rectangle
ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4

Recode

ffmpeg -i %06d.png -c:v copy -pix_fmt yuv420p out.mp4

Leading zeros

"{:04d}.png".format(counter)

Scan size of /root

cd /
ncdu -x / 

Clean tmp

cd /tmp/
pwd
sudo rm -r *

Clean logs

sudo journalctl --vacuum-size=100M

helpful-commands's People

Contributors

saafke avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.