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 | data -> +---------------------o +3.3V
32 | \______________ + +---------------------o GND
35 | - +---------------------o GPIO 4 (BCM23)
36 +-----------------------+
39 950nm emitting diode (e.g. TSUS5400)
44 | | 51 Ohm (depending on MOSFET maybe not required)
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)
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 In case of unsiccess try to find and copy YOUR_DEVICE.conf for your remote controller to */etc/lirc/lircd.conf.d/*
125 Here is a [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 "$@"
206 Start lircd-tx (with *sudo*)
208 systemctl daemon-reload
209 systemctl start lircd-tx
210 systemctl enable lircd-tx
212 Enable RX (with *sudo*)
213 systemctl enable lircd.service
214 systemctl enable lircd.socket
216 systemctl restart lircd
218 NOTE: there maybe the Warning of duplication of "begin remote .. end remote", it is fine. Ignore it.
220 Reboot and check status :)
224 systemctl status lircd.service
225 systemctl status lircd.socket
229 Send some command. replace vendor and command with your
231 irsend SEND_ONCE SONY-TV KEY_1
236 Record your own (if you have no compatible remote control or incomplete config)
238 systemctl stop lircd.socket
239 systemctl stop lircd.service
241 record with own key names
242 irrecord --disable-namespace
244 systemctl start lircd.socket
245 systemctl start lircd.service
247 Force raw record mode (normally not required)
249 irrecord -f -d /dev/lirc0 ~/lirc.conf
251 ## Main package installation
254 git clone <this repo> (see above)
257 Make sure that all .sh files inside are executable (have x flag)
261 if required make them *chmod +x *.sh*
263 ### Early stage systemd service (launching led driver and creating splash image)
265 Create */etc/systemd/system/splash.service* file and add there
268 DefaultDependencies=no
269 After=local-fs.target
274 ExecStart=/home/pi/BABOOSHKA.TV/early_init.sh
277 WantedBy=sysinit.target
281 sudo systemctl enable splash.service
285 Add this line to */etc/rc.local*
287 sudo -H -u pi /home/pi/babooshka.tv/start.babooshka.sh > /dev/null &
293 if everything has been done properly, you will see the splash babooshka.tv logo
295 - add testing video in *~/BABOOSHKA.TV/VIDEO/* directory
296 - check playlist (that the video link has been added)
297 - click PLAY on your remote
298 - if something went wrong, see Debug section below
300 ## Cosmetic polishing
302 Edit */boot/cmdline.txt*. Make sure that you have *console=tty3 quiet consoleblank=0* and *logo.nologo*, this is my cmdline:
304 console=serial0,115200 console=tty3 quiet consoleblank=0 loglevel=1 root=PARTUUID=6c586e13-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait logo.nologo
306 Disable blinking cursor (probably not required)
308 vt.global_cursor_default=0
310 Remove tty login service to eliminate blinking cursor
312 sudo systemctl disable getty@tty1
314 ## Additional software
316 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.
318 apt install mkvtoolnix python-pip
319 pip install -U youtube-dl
323 converting video (note -level 3.0 option! it is required for RPi HW codec)
325 ffmpeg -i FILEIN -vcodec libx264 -preset slow -level 3.0 -b 700k -s 720x404 FILEOUT
327 upload new video from local PC
329 scp <your_super_cool_kitten_flick.mp4> <babooshka>:BABOOSHKA.TV/VIDEO/
331 download new video from youtube (on device)
333 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>
335 click PLAY button and enjoy :)
339 tail -F /tmp/babooshka.log
343 - Not changing the state on finish (WATCHED) if video has been resumed (time of resuming is disregarded)
347 - WiFi auto-reconnect, probably *sudo iw dev wlan0 set power_save off* would be helpful
348 - youtube-dl, autoupdate
349 - youtube-dl download from downloadlist
350 - check free storage space
351 - auto removing of old videos + commenting in playlist
352 - splash info, Nth video from COUNT videos
353 - Make a single package
357 Download this nice babooshka.tv [sticker and logo](https://repository.interplaymedium.org/babooshka.tv/babooshka_sticker.svg)
359 ![babooshka.tv found enclosure and cool sticker](https://repository.interplaymedium.org/babooshka.tv/babooshka.tv.enclosure_front.jpeg)
363 Copyright © 2020 Dmitry Shalnov [interplaymedium.org]
365 Licensed under the Apache License, Version 2.0 (the "License");
366 you may not use this files except in compliance with the License.
367 You may obtain a copy of the License at
369 http://www.apache.org/licenses/LICENSE-2.0
371 Unless required by applicable law or agreed to in writing, software
372 distributed under the License is distributed on an "AS IS" BASIS,
373 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
374 See the License for the specific language governing permissions and
375 limitations under the License.