Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Saturday, October 14, 2023

Linux Cheat sheet

1) CLI Equivalent of "Safely Remove Drive"?
fdisk -l | grep Disk | egrep '/sd'

Tested on Ubuntu 20.04

Using udisks2: Detach a disk with udisks2:

udisksctl unmount -b /dev/sdXY
udisksctl power-off -b /dev/sdX
Example if my drive is /dev/sdb1:
udisksctl unmount -b /dev/sdb1
udisksctl power-off -b /dev/sdb
Similarly to above, power-off can be used to detach the drive even if there are no partitions mounted, or no partition was ever mounted:
udisksctl power-off -b /dev/sdb
2)

Saturday, July 29, 2023

Youtube-dl examples

Install

To install it right away for all UNIX users (Linux, OS X, etc.), type:
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

Ffmpeg vIdeo edit example for FB reels

ffmpeg

1. Go to directory.

cd ~/Videos/20230816-imsa

2. Generate cut/trim script.

ls V*.mp4 | sed 's/^/ffmpeg -i /; s/$/ -ss 00 -to 05 -c copy o.mp4/'

3. Edit the cut/trim script.

ffmpeg -i VID_20230816_060307.mp4 -ss  0 -to  6 -c copy o1.mp4
ffmpeg -i VID_20230816_060551.mp4 -ss 15 -to 22 -c copy o2.mp4
ffmpeg -i VID_20230816_060635.mp4 -ss  3 -to 23 -c copy o3.mp4
ffmpeg -i VID_20230816_060635.mp4 -ss  6 -to 10 -c copy o0.mp4 #fb reels thumbnail
ffmpeg -i VID_20230816_060758.mp4 -ss  8 -to 20 -c copy o4.mp4
ffmpeg -i VID_20230816_061349.mp4 -ss 1:44 -to 2:0 -c copy o5.mp4
ffmpeg -i VID_20230816_061821.mp4 -ss  0 -to 25 -c copy o7.mp4

4. Generate the concat list.

ls o*.mp4 | sed 's/^/file /' > list.txt

5. Edit concat list.

file o0.mp4
file o1.mp4
file o2.mp4
file o3.mp4
file o4.mp4
file o5.mp4
file o7.mp4

6. Execute concat.

ffmpeg -f concat -i list.txt -c copy o.mp4

7. Create title file.

cat << EOF > title.txt
2023/08/16
Bagong pisa
EOF

8. Generate the final script.

vid-vlog-reels.sh o.mp4  title.txt  reels.mp4

9. Final cript.

ffmpeg -t 90 -i o.mp4 \
  -filter_complex "
    [0:v]scale=-2:1920
      ,drawtext=enable='between(t,1,6)' \
        :fontsize=96 \
        :fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf :fontcolor=white@0.99 \
        :textfile=title.txt :x=(w-text_w)/2 :y=h/100 \
        :shadowcolor=black :shadowx=4 :shadowy=4  \
      ,drawtext=enable='between(t,1,89)'   \
        :fontsize=76 \
        :fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf :fontcolor=white@1.0 \
        :text='©TotsPo' \
        :box=1 :boxcolor=black@0.5 :x=(w-text_w)-text_h/2: y=(h-1.5*text_h)  \
      [v]    
" -map [v] \
  -map 0:a -c:a copy \
  -preset veryfast \
  -movflags faststart \
-y reels.mp4
echo
ls -lh reels.mp4
See output video.