2021. február 23.

How to split a video without rerendering it

To slice out a part of a video file, we can use this ffmpeg command:

ffmpeg -ss <position> -i input.mp4 -c copy -t <duration> output.mp4

-c copy Copy is a special value for the codec option on the output to indicate that the stream is not to be re-encoded.

-ss <position> When used as an input option (before -i), seeks in this input file to position. Note that in most formats it is not possible to seek exactly, so ffmpeg will seek to the closest seek point before position. When doing stream copy or when -noaccurate_seek is used, this extra segment between the seek point and position will be preserved.

-t <duration> When used as an output option (before an output url), stop writing the output after its duration reaches duration.

position/duration can be in either the [-][HH:]MM:SS[.m...] or the [-]S+[.m...][s|ms|us] format

2021. január 4.

Note: How to password-protect a PDF file on Ubuntu

This is a copy of this post for safe-keeping: 


In a terminal, type:

sudo apt-get install pdftk

Then, to add a password to a PDF file, type:

pdftk <input-file> output <output-file> user_pw <password>

Example:

pdftk input.pdf output output.pdf user_pw 1234

2020. március 9.

Update Java version with AdoptOpenJDK

1. Install the JDK version you want with apt-get
(Steps copied from the linked source)

Import the official AdoptOpenJDK GPG key by running the following command:
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -

Import the AdoptOpenJDK DEB repository by running the following command:
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/

Refresh your package list:
sudo apt-get update

Install your chosen AdoptOpenJDK package. For example, to install OpenJDK 8 with the HotSpot VM, run:
sudo apt-get install <adoptopenjdk-8-hotspot>

2. update alternatives:

List alternatives for java:
~$ update-alternatives --list java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
/usr/lib/jvm/jdk-11.0.2/bin/java

Check the java version of the alternative you would like to set:
~$ /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/bin/java --version
openjdk 11.0.6 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)

Set the chosen version as the default:
~$ sudo update-alternatives --set java /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/bin/java

update environmetal variables
For me, there is a maven.sh in /etc/profile.d that sets the env vars required for maven.
~$ sudo gedit /etc/profile.d/maven.sh
Update the JAVA_HOME path here. (in my case to /usr/lib/jvm/adoptopenjdk-11-hotspot-amd64/)

2019. augusztus 3.

Display settings lost on reboot

As described here, this problem is affecting others as well:
Here are the steps I tool to assemble the little script below:

How many displays do you have right now?
xrandr | grep -w connected | wc -l
How to position your displays?
xrandr --output PRIMARY-SCREEN-ID --below SECONDARY-SCREEN-ID
How to rotate a display?
xrandr --output SCREEN-ID --rotate [normal|left|right|inverted]
How to get your display IDs?
primary display:
xrandr | grep -w connected | grep primary | cut -d' ' -f1
secondary display:
xrandr | grep -w connected | grep -v primary | cut -d' ' -f1
How to position your gnome-panels?
Apparently there is no easy way, but for the note, here's where to find these setting:
org.gnome.gnome-panel.layout.toplevels.bottom-panel monitor 0
org.gnome.gnome-panel.layout.toplevels.top-panel monitor 1

Here's the script I put into my .bashrc (.profile would be also a good place for it) to restore the positions of my displays (I have the laptop below the monitor).

# set dual display positions
# because they are forgotten after logout
function reset_displays {
 display_count=`xrandr | grep -w connected | wc -l`
 if [ "$display_count" -eq "2" ]; then
  id1=`xrandr | grep -w connected | grep primary | cut -d' ' -f1`
  id2=`xrandr | grep -w connected | grep -v primary | cut -d' ' -f1`
  xrandr --output $id2 --rotate normal
  xrandr --output $id1 --below $id2
 fi
}
reset_displays

2019. január 3.

ImageMagick not authorized format conversion

For the following command
convert example.pbm example.ps
I got the following error:
convert: not authorized `example.ps' @ error/constitute.c/WriteImage/1028.
I fixed it by following the instructions in this post:
  1. sudo gedit /etc/ImageMagick-6/policy.xml
  2. change 'rights' from "none" to "read|write" in the line where the 'pattern' is 'PS'.
    I changed it for 'PDF' too and moved these lines to a separate section, so now it looks like this:
  <!-- manually re-enabled ghostscript format types -->
  <policy domain="coder" rights="read|write" pattern="PS" />
  <policy domain="coder" rights="read|write" pattern="PDF" />