Wednesday, December 2, 2020

Choice of partition for bootloader

 Taken integrally from https://askubuntu.com/questions/219514/where-to-install-bootloader-when-installing-ubuntu-as-secondary-os

Here's an example that could help you out:

Installation type

Under "Device for boot loader installation":

  • if you choose dev/sda, it will use Grub (Ubuntu's boot loader) to load all systems on this hard drive.
  • if you choose dev/sda1, Ubuntu need to be manually added to drive's boot loader after installation. (for example, you previously have Windows installed on another partition of this drive, you'll need manually add Ubuntu into mbr)

Thursday, September 24, 2020

bash - copy files from one directory into an existing directory

 Original post: https://stackoverflow.com/questions/3643848

 cp -R t1/. t2/

 The dot at the end tells it to copy the contents of the current directory, not the directory itself. This method also includes hidden files and folders.

 
If you copy a directory, cp will create a directory and copy all the files into it. If you use the pretend folder called ".", which is the same as the directory holding it, the copy behaves this way. Let's say t1 contains a file called "file". cp will perform the operation equivalent to "cp t1/./file t2/./". It is copying the folder ".", but copying files into t2's "." folder strips the "./" because "t2/./" is the same as "t2/". Technically, this means it's POSIX built in behavior... but probably not in the way you might have been expecting!

Monday, August 17, 2020

ubuntu unzip encrypted

 Source: https://stackoverflow.com/questions/42186512/

 In Ubuntu, I've to install 7zip (7z) archive tool using following command:

sudo apt-get install p7zip-full

Then, you can use Ubuntu's default Archive Manager to unzip the password protected zip files

 

Friday, June 12, 2020

Rename drive label in KDE


kdepartitionmanager > right click on partition > properties > Label

I had to unplug and plug again the USB drive to see the changes on dolphin.

https://forum.kde.org/viewtopic.php?f=225&t=106855

Sunday, May 24, 2020

ffmpeg add mp3 audio

ffmpeg -i video.mp4 -i audio.mp3 -c copy -map 0:v:0 -map 1:a:0 output.mp4


https://superuser.com/questions/277642/how-to-merge-audio-and-video-file-in-ffmpeg

ffmpeg strong compression

 ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4
 
https://unix.stackexchange.com/questions/28803/how-can-i-reduce-a-videos-size-with-ffmpeg 

ffmpeg scale video

If we'd like to keep the aspect ratio, we need to specify only one component, either width or height, and set the other component to -1. For example, this command line:
ffmpeg -i input.jpg -vf scale=320:-1 output_320.png
 
 *** will fail if other dimension does not divide to an integer result
 
https://trac.ffmpeg.org/wiki/Scaling 

ffmpeg wav to mp3

ffmpeg -i input.wav -vn -ar 44100 -ac 2 -b:a 192k output.mp3


https://stackoverflow.com/questions/3255674/convert-audio-files-to-mp3-using-ffmpeg

ffmpeg concatenate videos

concat_mp4.sh

#!/bin/bash
# usage ./concat_mp4.sh input1.mp4 input2.mp4 output.mp4
ffmpeg -i $1 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i $2 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc $3


inspiration: https://trac.ffmpeg.org/wiki/Concatenate

Friday, April 24, 2020

convert .ogv to .mp4

ffmpeg -i vid.ogv -crf 18 vid.mp4

https://stackoverflow.com/questions/37325629/efficient-ogv-video-conversion-in-linux

crop video with ffmpeg

$ ffmpeg -i in.mp4 -vf "crop=w:h:x:y" out.mp4

* for screen captures, the true size of capture may be lower than sreen size, check the stdout of a failed conversion to see this:

Tuesday, April 7, 2020

python unzip list

for pairs of values:

[(key1, val1), (key2, val2), ...]

[keys, values] = list(zip(*KeyValueList))


https://www.geeksforgeeks.org/python-unzip-a-list-of-tuples/

C++ static methods in template classes

In C++, when declaring a static method in a templated class, it is mandatory that the definition of the function be placed in the .h file, not the .cpp file.