Command Line Magic - sgould/fun_and_games GitHub Wiki
This page contains useful commands that I use often but always forget.
Converting mp4 files to play on Windows:
ffmpeg -i <input>.mp4 -c:v libx264 -strict -2 -preset slow -pix_fmt yuv420p <output>.mp4
Converting from avi to mpeg:
avconv -i <input>.avi -vcodec mpeg4 -b:v 1200k <output>.mp4
ffmpeg -i <input>.avi -c:v mpeg4 <output>.mp4
Create a video from a sequence of images:
avconv -i "<input>%d.png" -vcodec mpeg4 <output>.mp4
avconv -i "<input>%04d.png" -vcodec h264 -crf 1 -r 24 <output>.mp4
Combining multiple videos into a single video: see this stackoverflow post.
Displaying frame size for each video in a directory:
for i in <dir>/*; do ffprobe -v error -show_streams ${i} | grep "^width"; done
Counting video frames in input.mp4
:
ffprobe -v error -select_streams v:0 -count_packets -show_entries stream=nb_read_packets -of csv=p=0 input.mp4
Remove flicker from fluorescent lights (60fps):
ffmpeg -fflags +genpts -i ${INPUT} -fflags +genpts -i ${INPUT} \
-filter_complex "[0:v]setpts=PTS-STARTPTS[top]; [1:v]setpts=PTS-STARTPTS+.017/TB, format=yuva420p, colorchannelmixer=aa=0.5[bottom]; [top][bottom]overlay=shortest=1" \
-c:v libx264 -crf 26 -an ${OUTPUT}
sudo service network-manager restart
<command> # run the command and enter input needed
[Ctrl-Z] # pause the job
ps # get list of currently running processes
disown -h <process id> # disown the process so that it continues running when the shell is closed
jobs # get list of suspended jobs
bg <job id> # continue running the job in the background
- from localhost
ssh <user>@<host> -NL 9999:localhost:1234
- on
<host>
runjupyter notebook --no-browser --port=1234
- open browser on localhost and go to
localhost:9999
- from localhost:
ssh -L 9998:<host2>:22 -N <user>@<host1>
ssh -L 9999:localhost:1234 -N -p 9998 <user>@localhost
- start job on
<host2>
listening on port 1234 (e.g.,jupyter notebook --no-browser --port=1234
) - open browser and go to
localhost:9999
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dColorImageResolution=75 -dDownsampleColorImages=true -dColorImageDownsampleType=/Bicubic -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=${out} ${in}
The PDFSETTINGS
parameter can also be /screen
, /ebook
, /prepress
and /printer
.