Thursday, November 30, 2023

Reducing a video's size with FFMPEG

 The following command uses the H.265 codec that compresses more for the same quality:

ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4

Other options for further compression are the following:

To scale to half size:

ffmpeg -i input.mkv -vf "scale=trunc(iw/4)*2:trunc(ih/4)*2" -c:v libx265 -crf 28 half_the_frame_size.mkv

One-third size:

ffmpeg -i input.mkv -vf "scale=trunc(iw/6)*2:trunc(ih/6)*2" -c:v libx265 -crf 28 a_third_the_frame_size.mkv

One-quarter size:

ffmpeg -i input.mkv -vf "scale=trunc(iw/8)*2:trunc(ih/8)*2" -c:v libx265 -crf 28 a_fourth_the_frame_size.mkv

One-fifth size:

ffmpeg -i input.mkv -vf "scale=trunc(iw/10)*2:trunc(ih/10)*2" -c:v libx265 -crf 28 a_fifth_the_frame_size.mkv

In these examples, the size is divided by twice of the reduction value and multiplied by two to ensure the pixel size is a multiple of two, which is required for some codecs, including H265. Changing the resolution always requires re-encoding.



Saturday, March 25, 2023

Removing Hidden Chars from a File

Removing the garbage characters with the Linux/Unix 'tr' command:

To get the binary characters out of your files, there are several approaches, probably the easiest solution involves using the Linux/Unix 'tr' command. To remove non-printable binary characters (garbage) from a Linux/Unix text file do the following:


tr -cd '\11\12\40-\176' < input.c > output.c

----

Thursday, March 09, 2023

Using a Mplayer option to keep the pitch at higher speeds of video or audio.

If you like to listen to an audio or watch a video at higher speed, the sound could get distorted, i.e. with the wrong pitch ("chipmunk mode"). In mplayer when you change the speed using the keys "[" to decrease or "]" to increase; the tempo is not adjusted accordingly. In command line a solution is with the use of  "-af scaletempo" option, example: 

mplayer -af scaletempo videofile.mp4

The speed can be included as 

mplayer -af scaletempo -speed 2 videofile.mp4

or being changed later with  the keys "[" or "]". 

In the case of using a "Mplayer" GUI, like in the case of "SMPlayer", the "-af scaletempo" functionality is already integrated. 



Tuesday, February 28, 2023

MousePad Text Editor Bug

This issue is happening in Ubuntu 22.04 with the MousePad text editor version 0.5.8 

Files are automatically saved in a directory at: ~/.local/share/Mousepad

The files have no extension, they get the name "autosave-0", "autosave-1", "autosave-2", . . . , "autosave-n".

At some point, after a reboot, if you have not saved any of those files and you try to open the MousePad text editor, it won't come up unless you call it through the command line and you will get the following message:


(mousepad:21465): Mousepad-WARNING **: 19:56:09.717: Some 'autosave-*' files in directory '~/.local/share/Mousepad' do not correspond to any session backup anymore. They will not be deleted automatically: please do it manually to remove this warning.


You can go there and delete those files, or save them, or move them to another directory; they are plain text files, you can open those with VIM, NANO, or any other text editor. After those files are removed from that default directory the MousePad text file app will work fine and it will respond to the calls from the GUI.

----

Monday, February 13, 2023

Downloading subtitles from YouTube videos

 This works with youtube-dl and with yt-dlp

yt-dlp --write-auto-sub --sub-lang es --convert-subs=srt --skip-download URL

---