Oct 26, 2015

(Portuguese) Como fazer videos Youtube a partir de musica e uma imagem

Como pegar numa musica mp3 e numa imagem e rapidamente fazer um vídeo que se possa fazer upload para o youtube com bons resultados?

Versão rápida:

Em Linux, garantir que os pacotes mp3gain e ffmpeg estão instalados e correr o seguinte comando (atenção, o mp3gain altera permanente o volume do ficheiro de musica utilizado: se necessário fazer backup):

mp3gain -m 100 -k -r path_to_music_here.mp3 && ffmpeg -loop 1 -framerate 2 -i path_to_image_here.jpg -i path_to_music_here.mp3 -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p ~/output.mkv

E fazer upload do output para o youtube.

Versão extensa:

Usando o Linux precisamos de  dois pacotes instalados: ffmpeg e m3gain.

O uso do mp3gain não é estritamente necessário mas é bom para garantir a boa qualidade da musica quando ouvida no youtube.

O ffmpeg é que cria o vídeo. O site do ffmpeg é https://ffmpeg.org

Se os links abaixo tiverem partidos, tentar procurar no site oficial pelas localizações actuais.

Instalar o ffmpeg na sua versão mais recente:

Instalar o mp3gain:

A partir do Ubuntu 15, o mp3gain foi removido do repositorio por não ter sido actualizado.

Pode-se instalar o pacote com apt-get ou sacar o .deb:

O pacote está aqui http://packages.ubuntu.com/trusty/mp3gain . Pode-se instalar o pacote com dpkg -i pacote.deb ou procurar o binário compilado e extraír algures, mudando o comando para corresponder à localização do binário.

Escolher a combinação audio imagem:

Isto segue princípios básicos. Deve-se escolher uma musica de alta qualidade. Deve-se escolher uma imagem de alta qualidade. É educado ter autorizações para as duas ou que sejam de livre utilização. Pelo menos deve-se na descrição do vídeo referir o artista da musica e da imagem e suas respectivas homepage.

Normalizar o ficheiro audio:

mp3gain -m 100 -k -r path_to_music_here.mp3

Este comando faz o audio ficar o mais alto que puder sem ocorrer clipping.

Isto altera o ficheiro, portanto se se desejar  manter o ficheiro original, deve-se fazer backup e aplicar o mp3gain depois.

Criar o ficheiro vídeo:

Correr o seguinte comando:

ffmpeg -loop 1 -framerate 2 -i path_to_image_here.jpg -i path_to_music_here.mp3 -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p ~/output.mkv

Instruções retiradas daqui: https://trac.ffmpeg.org/wiki/Encode/YouTube
Convem consultar antes para verificar se permanecem actualizadas.

O que faz cada parametro, pode ser consultado no manual do ffmpeg. Há parametros que estão só no manual secundário do encoder (por exemplo no manual do encoder libx264).

Fazer upload para o youtube: 

Esta parte é fácil :)

Jun 15, 2015

Linux Adventures! Chapter Three: I'm Confused (Jun 2015)

Here's a list of misc stuff, more directed to confused Windows users.

A very basic Linux introduction for Windows users.

On Linux everything is a file. On Windows you are used to when opening the file explorer, to see the root as the partitions. And go from there. In Linux not so. Partitions are part of the main directory structure. But that directory structure is always the same. This can lead to some confusion, but you know *shrugs*. On Windows you got random file locations on different machines with different disks/partitions. Not so on Linux. You'll find the stuff where you expect to find it, and then have to figure out where it is physically. On Windows, a file's logical location is more random and a file's physical location more evident.

On Linux .exe doesn't mean anything. Executable is a property a file can have. Any file can be executable. The system you have (xfce, lxde, gnome) tries to guess what the file is based on the extension. But being executable is not related to the extension.

Easiest way to find cool Linux software to try out is to Google of course. But the fun way is to use Synaptic! Search it and be amazed.

How to install stuff without using the Software Center/Synaptic

To install stuff via command line is sometimes the easiest sudo apt-get install something

You can use the tab key to figure out the name of what you want to install. If you want to install something from the web, download the .deb file and install it with sudo dpkg -i file.deb

If installation involves running a file you have to go to it's location and do ./filename

But sometimes the file is not executable, so you have to do chmod +x  filename first.

How to play windows games and run windows applications on Linux

Easiest way to install and run windows stuff is an app called playonlinux. It supports loads of stuff. Install like any other app and check out the website for the supported stuff. The way it works: it makes a virtual disk with libraries to run your windows app in it, and it runs the windows installer inside that. It also has a way to install additional windows stuff inside, kinda like the way synaptic works. So you can install stuff like .net framework, directx, etc. If your app doesn't run you usually install some of that stuff and it starts running.

For example, there was a windows game I couldn't play online and all I did was install directplay in it's virtual drive, and then it started allowing online play :)

If you come from windows and have another question or something that confused you, post it on the comments, and I'll add it here!

Linux Adventures! Chapter Two: Making It All Work Better (Jun 2015)

Howdy partner!

This here is chapter two. If you are looking for chapter one, here ya go.

If not, let's continue.

So you got yourself a brand new installation of Linux. If you went along with the suggestion, you have Lubuntu. This guide assumes you did at least picked something similar to Lubuntu. If you didn't, good for you. This guide may still help you, but you will probably need more help.

Also, this guide assumes the machine is connected to the internet . If your wireless card is not working on Linux, this guide can help you. But you will still need to get stuff from the internet, either by connecting a cable or using another computer.

So what you should know?

Well, now I could teach you the basic stuff, or just go ahead and try to finish the installation. Or... do both at the same time. Bad for referencing, good for learning and that's what I am going to do.

So, let's finish the installation. Graphical interfaces are fine, but you need to know that sometimes typing the stuff you want is faster. And also, that most programs exist as command lines before existing as graphical interfaces.


Let's open a terminal. You can look for it in the start menu, (the windows key (called super key in Linux) won't work for that, use either Ctrl+Esc for the start menu) or... just click on the start menu with your mouse? :D

I don't want you to start by getting annoyed that the super/windows key does not work on Linux. The super key does work and does some cool stuff. Here, a quick reference you might want to browse through.

Back to how to open the terminal, you can also search for it by calling the run,  Alt+F2, and type stuff to find what you want. Or you can just use the fastest method besides creating a shortcut icon: Ctrl+Alt+T.

Done? A terminal should be open and ready to receive input.

One of the main advantages that Linux can have is the centralized updating system. This means that by using large online repositories, not only can you keep Linux updated, it will update the software you have installed, and the drivers you have installed. The only care you'll have to take is to install stuff from within the updating system, instead of downloading it and installing like you did in Windows (but you can do that too, of course).

We'll get there. Now, since we are finishing the installation, you should type this:

sudo apt-get update

and when that finishes:

sudo apt-get dist-upgrade

sudo means you are giving permission for the system to alter itself, which is necessary in this case. Everytime you do sudo you have to input your password.

This is what makes linux more virus proof. System changing stuff can't really happen without linux ask you for permission. The price to pay is having to input your password a lot.

apt-get is an application for installing stuff and updating the system.

dist-upgrade is an instruction for apt-get and it's telling it to upgrade everything. It's a more powerful (and some people say dangerous) form of upgrade, as in apt-get upgrade.

A tip: on a terminal you can use the Tab key to auto-complete as you type: try it, it's self explanatory.

So, you just formatted the  machine and already are downloading ~300MB of  updates? You betcha!

Continue only when the updates finish. Because you can't be updating the operating system from two sources at the same time.

Language support and restricted-extras!

Now, go to Start menu->preferences->Language Support

It will complain that Language Support is not fully installed. Why? I dunno, but just install it. Seems like a general Ubuntu annoyance. It will ask for your password after a while. And won't work but also won't complain if you are not online. Install any other languages you need. Check the regional format tab to see if it's the one you want.

Still not done. Now, you should go to the Lubuntu Software Center. I won't tell you where it is, find it, it's easy. There you'll find the restricted-extras and install them. These are some non-free codecs and some other stuff you probably want to have.

We done?

Nope, drivers.


If you are unlucky, stuff like your wireless card will still not be working. Go to Software Updater on the start menu, click on settings and fumble your way to the "Additional Drivers" tab. This thing is funny 'cause it won't ask for your password, and absolutely needs you to be online, but won't complain about you not being online, just fail silently. Also it takes a while to load but doesn't tell you how long.

Still, see the driver you need? If yes, try to install it. If not, you might want to install stuff later, so remember where this is. Some graphic drivers are better than the default free ones, and result in better graphics.

Careful now: drivers seem to be somewhat different from other normal packages that you can install using the software center or the apt-get. Why is this important? Because, if you manually download and install a driver from a website, while having another driver for that same device installed, you'll probably break your system somewhat (but not entirely: Linux is resilient).

If you didn't find the driver you need inside the Software Updater, you should use the Synaptic Package Manager. Which is kind of the real thing that let's you install and update your system. It's the graphical interface that the grandfather of Lubuntu, Debian, uses to install and update software. So you can expect it to be more powerful and lean, and a bit more overwhelming for newbies.

And guess what, except for the powerful dist-upgrade command, everything we did until now could have been done inside Synaptic. Welcome to Linux.

Inside Synaptic you should go to Settings->Repositories. On the first tab make sure everything is selected. Leave the source stuff as it is. On the second tab make sure Canonical Partners is selected.

If you are perceptive, you can see that this screen is the same as the "Settings" screen in the Software Updater we used earlier. I could just have brought you here directly, but I'm trying to show you what you should expect from Linux: lots of ways of doing the same thing.

Close the repositories, and click on reload. This is the equivalent to the sudo apt-get update command we used earlier.

After it finishes fetching the available stuff, you can use the search inside Synaptic to try and find the appropriate driver for your wi-fi card. For example, mine was a Broadcom, with the codename BCM, so I just searched for bcm and installed a bunch of stuff that seemed like it would make it. And BAM! it worked!(maybe after a reboot and/or going back to the additional drivers screen)

Funny thing, my Broadcom wireless card was working without any additional drivers. But it got way better reception after I found and installed its driver.

Again, try to install everything you can from inside Linux instead of downloading.

Are we done? Yes. Yes we are.

I'll now write the short-form protocol that one should take to finish a Ubuntu-type installation:


  1. Go to Synaptic Package Manager
  2. Go to the menu repositories, select all available repositories (except for source code and physical media ones). Let it update if it wants to. Close Synaptic
  3. Open a terminal and type: sudo apt-get update && sudo apt-get dist-upgrade . Let it finish. Close terminal
  4. Go to Language Support, it will complain that something is missing, let it install it. Install other Languages. Check regional settings. Close Language Support.
  5. Go to Synaptic Package Manager. You may need to install it first with sudo apt-get install synaptic
  6. In the repositories screen, switch to the additional drivers tab. Wait for it to populate.
  7. Select and install the drivers you want
  8. If a driver you need is missing from the additional drivers list, try to figure out the brand and model of the device. Go back to Synaptic and usually all you have to do is search for the model or brand name or codename, and the driver packages will show up. Install them. You may have to go back to the additional drivers screen to really install the driver
  9. Find and install your distro's restricted-extras package (example: lubuntu-restricted-extras)
  10. Close everything and reboot
  11. You might want repeat only step 3) at this time, and once a week in the future

Welcome to Linux, you noob :D