1 # [babooshka.tv](https://babooshka.tv) old-school tv-box video player
3 This simple and lightweight package could turn your RPi into a video player. The package is designed primarily for your grandparents, for whom the use of a computer is a difficult task. You can upload your home kittens-kids videos or add videos from Youtube/Vimeo that you like.
5 The package is fully written in bash.
7 ![babooshka.tv RPi based prototype](https://repository.interplaymedium.org/babooshka.tv/babooshka.tv.rpi.jpeg)
11 [Pi Zero IO Pinout](https://pinout.xyz/pinout/io_pi_zero)
13 The yellow LED connected to +3,3v via 470R
15 GPIO 0 BCM17 LED green, booting
16 GPIO 2 BCM27 LED red, video status
18 Lowering resistors are required for all diodes (Red LEDs normally brighter, so I would recommend ~470R for yellow and green and about 1K for red)
20 ### Infrared interface
27 +-----------------------+ 3
28 | +---------------------o +3.3V
32 | \______________ +---------------------o GND
35 | data -> +---------------------o GPIO 4 (BCM23)
36 +-----------------------+
39 950nm emitting diode (e.g. TSUS5400)
44 | | 51 Ohm (depending on MOSFET maybe not required)
53 o-----|___|-----| MOSFET
66 ![RPi Zero Audio](https://repository.interplaymedium.org/babooshka.tv/pi-zero-audio_bb.jpg)
67 Picture taken [from here](https://shallowsky.com/blog/hardware/pi-zero-audio.html), thanks :)
71 ![RPi TV out](https://repository.interplaymedium.org/babooshka.tv/RPi_TV_out.jpeg)
72 Picture taken [from here](https://magpi.raspberrypi.org/articles/rca-pi-zero), thanks :)
76 Download, copy to microSD and install oficial [Raspberry Pi OS Lite image](https://www.raspberrypi.org/downloads/raspberry-pi-os/)
78 The procedure of adding a login and password for your access point, as well as the ssh configuration is omitted. It is assumed that you know how to do so :)
79 If you not sure, [ddg it](https://duckduckgo.com/?q=RPi+headless+how+setup+and+ssh).
81 Further operations are performed on device.
85 Update repository list and install dependencies
88 apt install mc fbi omxplayer sox
90 Try to install freefonts (required by omxplayer)
92 apt install ttf-freefont
94 By some reason recently *freefonts* package has been removed from official RPi repository. So in case of unsuccess just copy included freefonts to /usr/share/fonts/truetype/...
97 cp -r freefont /usr/share/fonts/truetype/freefont
98 chown root:root /usr/share/fonts/truetype/freefont
99 chown root:root /usr/share/fonts/truetype/freefont/*
101 ### IR interface setup
105 edit /etc/lirc/hardware.conf
107 # Run "lircd --driver=help" for a list of supported drivers.
110 # usually /dev/lirc0 is the correct setting for systems using udev
112 MODULES="gpio_ir_recv"
114 edit /etc/lirc/lirc_options.conf
115 NOTE! add new line in the end of the file !!!! [known bug](https://forum.odroid.com/viewtopic.php?t=32181)
120 First try to find you device using
122 irdb-get find YOUR_DEVICE
124 If you did it, copy YOUR_DEVICE.conf to */etc/lirc/lircd.conf.d/*
125 In case of unsiccess try to find and copy here: [List of devices](http://lirc-remotes.sourceforge.net/remotes-table.html) supported by Lirc 'from the box'. However, you always can record your own, see below...
127 Copy template lircd.conf
129 cp /etc/lirc/lircd.conf.dist /etc/lirc/lircd.conf
131 Make changes in */boot/config.txt* to set up PAL video output and run appropriate kernel overlays for IR interface:
137 framebuffer_width=720
138 framebuffer_height=576
140 # enable PWM audio (add this line)
141 dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
143 # uncomment for composite PAL
146 # uncomment if hdmi display is not detected and composite is being output
147 # hdmi_force_hotplug=1
149 # Uncomment this to enable the gpio-ir module
150 dtoverlay=gpio-ir,gpio_pin=23,gpio_pull=up
151 dtoverlay=gpio-ir-tx,gpio_pin=22
153 ### Make IR works as TX and RX simultanoiously
155 This part taken from [this GitHub comment](https://github.com/raspberrypi/linux/issues/2993#issuecomment-497420228) thank you [@elmicha](https://github.com/elmicha) :)
157 Add these rules in */etc/udev/rules.d/71-lirc.rules* to get stable */dev/lirc-rx* and */dev/lirc-tx* device names:
159 ACTION=="add", SUBSYSTEM=="lirc", DRIVERS=="gpio_ir_recv", SYMLINK+="lirc-rx"
160 ACTION=="add", SUBSYSTEM=="lirc", DRIVERS=="gpio-ir-tx", SYMLINK+="lirc-tx"
161 ACTION=="add", SUBSYSTEM=="lirc", DRIVERS=="pwm-ir-tx", SYMLINK+="lirc-tx"
163 Change the device and listening address in /etc/lirc/lirc_options.conf:
165 device = /dev/lirc-rx
166 listen = 0.0.0.0:8766
168 Copy lirc_options.conf to lirc_tx_options.conf and edit these lines:
170 device = /dev/lirc-tx
171 output = /var/run/lirc/lircd-tx
172 pidfile = /var/run/lirc/lircd-tx.pid
173 listen = 0.0.0.0:8765
174 connect = 127.0.0.1:8766
176 Create */etc/systemd/system/lircd-tx.service* (from the output of *systemctl cat lircd*) and edit it like this:
179 Documentation=man:lircd(8)
180 Documentation=http://lirc.org/html/configure.html
181 Description=Second lircd, the transmitter
182 Wants=lircd-setup.service
183 After=network.target lircd-setup.service lircd.service
187 ExecStart=/usr/sbin/lircd --nodaemon --options-file /etc/lirc/lirc_tx_options.conf
190 WantedBy=multi-user.target
191 Create /etc/systemd/system/lircd-tx.socket (from the output of systemctl cat lircd.socket) and edit it:
194 ListenStream=/run/lirc/lircd-tx
197 WantedBy=sockets.target
198 Also=lircd-tx.service
201 Create /usr/local/bin/irsend and make it executable
204 exec /usr/bin/irsend --device=/var/run/lirc/lircd-tx "$@"
205 chmod +x /usr/local/bin/irsend
207 Start lircd-tx (with *sudo*)
209 systemctl daemon-reload
210 systemctl start lircd-tx
211 systemctl enable lircd-tx
213 Enable RX (with *sudo*)
214 systemctl enable lircd.service
215 systemctl enable lircd.socket
217 systemctl restart lircd
219 NOTE: there maybe the Warning of duplication of "begin remote .. end remote", it is fine. Ignore it.
221 Reboot and check status :)
225 systemctl status lircd.service
226 systemctl status lircd.socket
230 Send some command. replace vendor and command with your
232 irsend SEND_ONCE SONY-TV KEY_1
238 Record your own (if you have no compatible remote control or incomplete config)
240 systemctl stop lircd.socket
241 systemctl stop lircd.service
243 record with own key names
244 irrecord --disable-namespace
246 systemctl start lircd.socket
247 systemctl start lircd.service
249 Force raw record mode (normally not required)
251 irrecord -f -d /dev/lirc0 ~/lirc.conf
253 ## IR remote setup and button assignment
255 If everything went fine and your remote reading by Raspbery, you have to choose buttons that you going to use for Babooshka control. Here is a list of current commands:
262 - pause on switching-off
267 This is how they marked in *remoteir.sh*
269 To assign comands you need to edit "ARR_DOWN", "ARR_UP" and so on in *remoteir.sh*. Change it for that you see in *irw* stdout when pressing buttons.
273 ## Main package installation
276 git clone <this repo> (see above)
279 Make sure that all .sh files inside are executable (have x flag)
283 if required make them *chmod +x *.sh*
285 ### Early stage systemd service (launching led driver and creating splash image)
287 Create */etc/systemd/system/splash.service* file and add there
290 DefaultDependencies=no
291 After=local-fs.target
296 ExecStart=/home/pi/BABOOSHKA.TV/early_init.sh
299 WantedBy=sysinit.target
303 sudo systemctl enable splash.service
307 Add this line to */etc/rc.local*
309 sudo -H -u pi /home/pi/BABOOSHKA.TV/start.babooshka.sh > /dev/null &
315 if everything has been done properly, you will see the splash babooshka.tv logo
317 - add testing video in *~/BABOOSHKA.TV/VIDEO/* directory
318 - check playlist (that the video link has been added)
319 - click PLAY on your remote
320 - if something went wrong, see Debug section below
322 ## Cosmetic polishing
324 Edit */boot/cmdline.txt*. Make sure that you have *console=tty3 quiet consoleblank=0* and *logo.nologo*, this is my cmdline:
326 console=serial0,115200 console=tty3 quiet consoleblank=0 loglevel=1 root=PARTUUID=6c586e13-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait logo.nologo
328 Disable blinking cursor (probably not required)
330 vt.global_cursor_default=0
332 Remove tty login service to eliminate blinking cursor
334 sudo systemctl disable getty@tty1
336 ## Additional software
338 If' you're going to watch videos from YouTube, Vimeo and so on, this packages would be required. Most porbably probably would beed to install youtube-dl globally. So do that with *sudo -H ...*. It would be recommended wor futher compatibility.
340 apt install mkvtoolnix python-pip
341 pip install -U youtube-dl
345 converting video. Note *-level 3.0* option! it is required for RPi HW codec. I've been breaking by brain until found that RPi HW codec can't play *low profile* (or maybe it is driver limitation). However [here is](https://superuser.com/questions/489087/what-are-the-differences-between-h-264-profiles) some technical details, if you interested in.
347 ffmpeg -i FILEIN -vcodec libx264 -preset slow -level 3.0 -b 700k -s 720x404 FILEOUT
349 upload new video from local PC
351 scp <your_super_cool_kitten_flick.mp4> <babooshka>:BABOOSHKA.TV/VIDEO/
353 download new video from youtube (on device)
355 youtube-dl -f 'bestvideo[vcodec=avc1][height<=720]+bestaudio/best[abr<=120]' --merge-output-format mp4 -o '%(playlist_index)s - %(title)s.%(ext)s' <youtube link>
357 click PLAY button and enjoy :)
361 tail -F /tmp/babooshka.log
365 - Not changing the state on finish (WATCHED) if video has been resumed (time of resuming is disregarded)
369 - WiFi auto-reconnect, probably *sudo iw dev wlan0 set power_save off* would be helpful
370 - youtube-dl, autoupdate
371 - youtube-dl download from downloadlist
372 - check free storage space
373 - auto removing of old videos + commenting in playlist
374 - splash info, Nth video from COUNT videos
375 - Make a single package
379 Download this nice babooshka.tv [sticker and logo](https://repository.interplaymedium.org/babooshka.tv/babooshka_sticker.svg)
381 ![babooshka.tv found enclosure and cool sticker](https://repository.interplaymedium.org/babooshka.tv/babooshka.tv.enclosure_front.jpeg)
385 Copyright © 2020 Dmitry Shalnov [interplaymedium.org]
387 Licensed under the Apache License, Version 2.0 (the "License");
388 you may not use this files except in compliance with the License.
389 You may obtain a copy of the License at
391 http://www.apache.org/licenses/LICENSE-2.0
393 Unless required by applicable law or agreed to in writing, software
394 distributed under the License is distributed on an "AS IS" BASIS,
395 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
396 See the License for the specific language governing permissions and
397 limitations under the License.
401 If you would like to contribute to a project, you can always [help with a penny](https://paypal.me/shalnov).