Convert Still Photos to a GIF or Video

smallWalk

Really just a technical note for myself. I thought I had written this down somewhere here, but I couldn’t find it, so, here it is.

Converting png to a video in Linux:

ffmpeg -framerate 24 -pattern_type glob -i ‘*.png’ -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4

Setting the framerate sets the speed of the video. You can replace png with jpeg or jpg if needed. This does, of course, require the ffmpeg utility/package.

And, converting png to a GIF in Linux:

convert -delay 10 -loop 0 *.png myimage10.gif

The delay sets the milliseconds of delay between frame, so lower makes a faster video, higher makes a slower video. 8 to 10 seems about right for something that should look “real time”. This requires the imagemagick package.

Linux – keep it simple.

Bluetooth Breakdown: Sending gatttool commands from my Ubuntu Touch Phone!

Here I am, typing commands from my phone and controlling a Bluetooth Feather!

Of course, the moment of truth! The goal of this whole Bluetooth breakdown project was to figure out how to make my home made auto start work on my Ubuntu Touch phone. Well, here it is, working!

Although the interface could use a face lift.

Last we looked at this, we saw that we could write custom scripts to send the commands from the desktop computer to the BLE auto start, or use interactive mode of gatttool and do the work there. Now we can actually do the same from the terminal of the cell phone.

While this technically counts. We now need a snazzy program that just works with clicky buttons and that sort of thing. So, I suppose that will be the next phase of this project! Stay tuned for adventure!

Linux – keep it simple.

Bluetooth Breakdown: Sending my own commands with gatttool

Yes, there is purposely one too many t’s in GattTool.

bt_success

Last time we looked at the Bluetooth Low Energy (BLE) packets being sent from my Android app to my home made auto start. Here’s what we saw:

214231313a – Button 1 pressed
214231303b – Button 1 released
2142323139 – Button 2 pressed
214232303a – Button 2 released

With a little more digging, I also found that the “handle” is important, and per the Bluetooth packet breakdown in WireShark, that handle is 0x001a. Further, my particular Bluetooth feather’s MAC address is F4:64:8E:90:D8:C3.

With all of this in mind, I entered gatttool in the interactive mode, but I kept having trouble connecting to my device. With further research, I found an article on WordPress by a guy named Jack. He got me pointed in the right direction!

What I needed to do before connecting was this:

# btmgmt le on
# btmgmt bredr off

To set the computer’s Bluetooth manager to the proper Low Energy reading/writing state. Then I entered interactive mode while monitoring my auto start with a USB serial monitor. Here’s what I typed:

root@alaskalinuxuser-OptiPlex-7010:/home/alaskalinuxuser# gatttool -t random -b F4:64:8E:90:D8:C3 -I
[F4:64:8E:90:D8:C3][LE]> connect
Attempting to connect to F4:64:8E:90:D8:C3
Connection successful
[F4:64:8E:90:D8:C3][LE]> char-write-cmd 0x001a 214231313a
[F4:64:8E:90:D8:C3][LE]> char-write-cmd 0x001a 214231303b
[F4:64:8E:90:D8:C3][LE]> char-write-cmd 0x001a 2142323139
[F4:64:8E:90:D8:C3][LE]> char-write-cmd 0x001a 214232303a
[F4:64:8E:90:D8:C3][LE]> char-write-cmd 0x001a 214232303a
[F4:64:8E:90:D8:C3][LE]> char-write-cmd 0x001a 214231303b
[F4:64:8E:90:D8:C3][LE]> char-write-cmd 0x001a 2142323139
[F4:64:8E:90:D8:C3][LE]> char-write-cmd 0x001a 214232303a
[F4:64:8E:90:D8:C3][LE]> char-write-cmd 0x001a 2142323139
[F4:64:8E:90:D8:C3][LE]> disconnect

(gatttool:22352): GLib-WARNING **: Invalid file descriptor.

[F4:64:8E:90:D8:C3][LE]> disconnect
[F4:64:8E:90:D8:C3][LE]> exit
root@alaskalinuxuser-OptiPlex-7010:/home/alaskalinuxuser#

And here is what I saw on the monitor:

Less than 13v, Pin A3: 0.00
Less than 13v, Pin A3: 0.00
Less than 13v, Pin A3: 0.00
Less than 13v, Pin A3: 0.00
Button 1 released
Less than 13v, Pin A3: 0.00
startTimer 4
Less than 13v, Pin A3: 0.00
startTimer 3
Less than 13v, Pin A3: 0.00
startTimer 2
Less than 13v, Pin A3: 0.00

Success! Great! I was able to enter interactive mode, connect, and send the right commands! This is great!

Then I switched to non-interactive mode, by writing a custom script or two. This is the first one, to start the auto start:

#!/bin/bash

btmgmt le on
btmgmt bredr off
gatttool -t random -b F4:64:8E:90:D8:C3 –char-write-req -a 0x001a -n 214231313a
gatttool -t random -b F4:64:8E:90:D8:C3 –char-write-req -a 0x001a -n 214231303b
#gatttool -t random -b F4:64:8E:90:D8:C3 –char-write-req -a 0x001a -n 2142323139
#gatttool -t random -b F4:64:8E:90:D8:C3 –char-write-req -a 0x001a -n 214232303a
exit 0

And one to stop the auto start:

#!/bin/bash

btmgmt le on
btmgmt bredr off
#gatttool -t random -b F4:64:8E:90:D8:C3 –char-write-req -a 0x001a -n 214231313a
#gatttool -t random -b F4:64:8E:90:D8:C3 –char-write-req -a 0x001a -n 214231303b
gatttool -t random -b F4:64:8E:90:D8:C3 –char-write-req -a 0x001a -n 2142323139
gatttool -t random -b F4:64:8E:90:D8:C3 –char-write-req -a 0x001a -n 214232303a
exit 0

And a quick test was successful! Now I can send my commands to start or stop the auto start from the command line with my computer. Now it’s just time to set it up on my Ubuntu Touch phone!

Linux – keep it simple.

My simple calendar script

As some of you know from previous posts, I use JWM as my default window manager. I like to keep things simple and cut down on wasted resources. This helps a lot, as I often run Qemu, Aqemu, or compile Android variants on my older laptop, which is not exactly a resource gold mine. One of the things that I wanted, however, was a lightweight calendar that I could click on and bring up. The original solution was to open up a terminal and simply type “cal”, but that got a little tedious, especially when I already was using the terminal for compiling or something like that.

Eventually, I decided to instead add a shortcut to my JWM start bar, and have that open up a terminal that will run the calendar program for me. The great thing about using a script was that I could specify the colors of the calendar (changing the look), and then give myself an options menu. To make this work with the color, font, or other changes, I actually have the JWM button refer to this first script, by adding this to my .jwmrc file:

[CODE]
exec:/home/alaskalinuxuser/Documents/scripts/xcal.sh
[/CODE]

Then, at that location, I have this simple first script:

[CODE]
#!/bin/bash

xterm -fg black -bg white -e sh /home/alaskalinuxuser/Documents/scripts/cal.sh
[/CODE]

Which in turn runs this script:

[CODE]
#!/bin/bash

cal

read -p “Would you like a different month? Choose a number or choose (n): ” yn
case $yn in
[1]* ) cal -m jan;;
[2]* ) cal -m feb;;
[3]* ) cal -m mar;;
[4]* ) cal -m apr;;
[5]* ) cal -m may;;
[6]* ) cal -m jun;;
[7]* ) cal -m jul;;
[8]* ) cal -m aug;;
[9]* ) cal -m sep;;
[10]* ) cal -m oct;;
[11]* ) cal -m nov;;
[12]* ) cal -m dec;;
[n]* ) exit 0;;
* ) echo “Please choose 1-12.”;;
esac
echo “I’ll give you 10 seconds to read it.”

sleep 10

exit 0
[/CODE]

Here is an example taken from one of the terminals after clicking on it.

[CODE]
June 2016
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30

Would you like a different month? Choose a number or choose (n): 2
February 2016
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29

I’ll give you 10 seconds to read it.
[/CODE]

I played around with the colors and settings for a while. I think that I have it tuned for what I like, but others may wish for something else. Essentially, I found that if I open the calendar, I almost always want to see the current month, so that is the default. Sometimes, however, I found that I wanted a different month. So the script asks you if you want a different month by month number. After choosing another month, or selecting no, the window will close after 10 seconds of viewing. Usually that is ample time for me to look at what I wanted to see. Obviously the time could be adjusted. Perhaps more obviously, there are GUI built in calendar applications that probably work 100 times better for the average person. This just works for me.

Linux – Keep it simple.