Sunday, September 20, 2020

Commands useful along with Youtube-dl

The following is to download a only a particular part of a video from YouTube 

ffmpeg -i $(youtube-dl -f 22 --get-url https://www.youtube.com/watch?v=cmne_rokrs4) -ss 00:10:10 -to 00:12:52 -c:v copy -c:a copy happy.mp4

Or you can download all the video first and then cut some parts following the instructions here.

If you want to concatenate MP4 videos (you can prepare an script):

echo file input1.mp4 >  mylist.txt

echo file input2.mp4 >>  mylist.txt

ffmpeg -f concat -i mylist.txt -c copy output.mp4

To list all subs for a video:

youtube-dl --list-subs URL

To download all subs, but not the video:

youtube-dl --all-subs --skip-download URL

Or you can only download one subtitle

youtube-dl --write-sub --sub-lang en --skip-download URL

Or  for downloading the automatically generated subtitles

youtube-dl --write-auto-sub --skip-download URL

If you want to convert the subtitles do:

ffmpeg -i input.vtt output.srt

The following is to convert videos to a higher speed. For instance, if you want to multiply by 1.15, the command is:

ffmpeg -i input.mkv -filter_complex "[0:v]setpts=0.87*PTS[v];[0:a]atempo=1.15[a]" -map "[v]" -map "[a]" output.mkv

#The "setpts" corresponds to the inversed speed (in this case 100/1.25 = 0.8)

#while the "atempo" corresponds to the desired direct speed of the video.

#Those values are proportionally inversed.

#For a 25% higher speed output video the values

#would be "setpts=0.8*PTS" and "atempo=1.25"

100/1.25 = 0.8

References:

Friday, September 18, 2020

Setting a SSH server in a workstation



sudo apt install openssh-server

systemctl status sshd

sudo systemctl restart ssh

sudo ufw allow ssh

Enable the SSH server to start automatically during the boot.

sudo systemctl enable ssh

Connect from a remote client to your SSH server. First, obtain an IP address of your SSH server. 

ip a

If connecting over the internet you need your external IP address:

echo $(wget -qO - https://api.ipify.org)

Check if IP being used to login via SSH is correct. Re-check IP of device being SSH'd into with:

hostname -I

For Dynamic DNS the freedns.afraid.org works fine with ddclient in Linux.

If you don't want to use the default port 22 for SSH, you need to edit the sshd config file in:

/etc/ssh/sshd_config 

and change the value of "Port 22" in it for another number. You should run SSH on an unprivileged port number, i.e. from 1024 to 65535. You can check what local ports are in use currently to avoid a conflict with:

netstat -taulpn 

and also avoid IANA registered service numbers, check with:

cat /etc/services

Once you have made the appropriate change open a firewall port to correspond with the new SSH port where "xxxx" represent the new number that you chose:

sudo ufw allow xxxx/tcp

Then

sudo systemctl restart ssh

For a SSH connection through a specific port, where "xxxx" is the number chosen, do:

ssh -p xxxx username@{hostname or IP}



----

Sunday, September 06, 2020

Dual Boot Linux and Windows 10

 If Windows was installed to run in UEFI, the Linux OS must also be installed using the UEFI mode. This means that most likely you need to disable in the BIOS the legacy mode and allow secure boot.

Is the "Install Ubuntu alongside Windows 10" option missing?

Please note that in the following circumstances the Ubuntu 20.04 installation option "Install Ubuntu alongside Windows 10" may be missing, if your Windows 10 installation: is not correctly shutdown or is hibernating, has corrupted partition which needs repair, partition has not enough free disk space left for resizing, uses Dynamic Disk or the file system contains uncontrollable file fragmentation.

Another case is if you try to install Linux using legacy boot for your installation media; the installation would be possible but the dual boot won't work. 

-----

References: LinuxConfig.org 


Thursday, August 13, 2020

dd is a great tool to fully wipe out your disk data to forensic levels How to wipe a hard drive clean in Linux

dd is a great tool to fully wipe out your disk data to forensic levels

# dd if=/dev/zero of=/dev/DISK/TO/WIPE bs=4096

# dd if=/dev/zero of=/dev/sda bs=4096

# dd if=/dev/zero of=/dev/sdX bs=512 

If you messed up your master boot record (MBR) you can wipe it using this command:

dd if=/dev/zero of=/dev/hdX bs=446 count=1 #replace X with the target drive letter.

If you are wiping your hard drive for security, you should populate it with random data rather than zeros (This is going to take even longer than the first example.) :

# dd if=/dev/urandom of=/dev/DISK/TO/WIPE bs=4096

# dd if=/dev/urandom of=/dev/sda bs=4096

# dd if=/dev/urandom of=/dev/sdX bs=512 

# dd if=/dev/urandom of=/dev/sdX bs=4096 status=progress

---



Wednesday, April 29, 2020

Set a default audio output device in Ubuntu 18.04


First: List the audio output devices using:

pactl list short sources  

Example of the output:

0 alsa_output.usb-Dell_Dell_AC511_USB_SoundBar-00.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
1 alsa_input.usb-Dell_Dell_AC511_USB_SoundBar-00.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
2 alsa_output.pci-0000_00_1b.0.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz IDLE
3 alsa_input.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
4 alsa_input.usb-046d_HD_Pro_Webcam_C920_627B04DF-02.analog-stereo module-alsa-card.c s16le 2ch 32000Hz SUSPENDED

Now, to make this work at every restart, follow this :

sudo -H gedit /etc/pulse/default.pa

Example of the edit:

### Make some devices default ###  sink(for output) / source(for input)
#set-default-sink output 
#set-default-source input
set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
#set-default-source input

----
Sources:
AskUbuntu
Rastating.