Skip to content

Instantly share code, notes, and snippets.

(57.617-50.337)/57.617 = 12.6%
BEFORE:
ncalls tottime percall cumtime percall filename:lineno(function)
1038/1 0.042 0.000 63.622 63.622 {built-in method builtins.exec}
1 0.000 0.000 63.622 63.622 video:2(<module>)
1 0.004 0.004 60.960 60.960 videoprocessor.py:56(process_and_play)
1 0.999 0.999 60.954 60.954 videoprocessor.py:104(__process_and_play_video)
1776 0.011 0.000 57.617 0.032 videoplayer.py:25(playFrame)
1776 7.538 0.004 52.474 0.030 videoplayer.py:41(__setFramePixels)
python3 -m cProfile -s cumtime video --url https://www.youtube.com/watch?v=AxuvUAjHYWQ --color-mode color 2>/dev/null | grep -v '2019-07-06' | head -15 && python3 -m cProfile -s cumtime video --url https://www.youtube.com/watch?v=AxuvUAjHYWQ --color-mode bw 2>/dev/null | grep -v '2019-07-06' | head -15 && python3 -m cProfile -s cumtime video --url https://www.youtube.com/watch?v=AxuvUAjHYWQ --color-mode r 2>/dev/null | grep -v '2019-07-06' | head -15 && python3 -m cProfile -s cumtime video --url https://www.youtube.com/watch?v=AxuvUAjHYWQ --color-mode g 2>/dev/null | grep -v '2019-07-06' | head -15 && python3 -m cProfile -s cumtime video --url https://www.youtube.com/watch?v=AxuvUAjHYWQ --color-mode b 2>/dev/null | grep -v '2019-07-06' | head -15
Comparing videoplayer::playFrame speeds with https://github.com/dasl-/lightness/commit/4de4dcab9dbdab18c4cd3b6d82a3b7a48b8173b0 :
COLOR: (52.464 - 30.186)/52.464 = 42% faster
BW: (55.319 - 35.988) / 55.319 = 35% faster
R: (39.269-29.927)/39.269 = 24% faster
@dasl-
dasl- / install-numba.sh
Created July 6, 2019 22:59
how to install numba on a raspberry pi
curl -o /home/pi/clang+llvm-8.0.0-armv7a-linux-gnueabihf.tar.xz http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-armv7a-linux-gnueabihf.tar.xz
tar -xf /home/pi/clang+llvm-8.0.0-armv7a-linux-gnueabihf.tar.xz
rm /home/pi/clang+llvm-8.0.0-armv7a-linux-gnueabihf.tar.xz
mv /home/pi/clang+llvm-8.0.0-armv7a-linux-gnueabihf clang_8.0.0
sudo mv /home/pi/clang_8.0.0 /usr/local
printf 'PATH=/usr/local/clang_8.0.0/bin:$PATH\nLD_LIBRARY_PATH=/usr/local/clang_8.0.0/lib:$LD_LIBRARY_PATH' | sudo tee /etc/profile.d/clang_8.0.0.sh
sudo -i pip3 install numba
sudo apt-get install bluealsa 
bluetoothctl
power on
agent on
scan on
pair XX:XX:XX:XX:XX
trust XX:XX:XX:XX:XX
connect XX:XX:XX:XX:XX
quit
@dasl-
dasl- / fps.diff
Last active July 12, 2019 16:49
Currently we get video info from youtube-dl twice. Once to get the video URL to ffprobe it for FPS before processing the video. Proof of concept diff to calculate FPS as part of the processing. Improves time to first LED light by a few seconds: https://gist.github.com/dasl-/9c0e6eb3912e17d82cb923aa92282f14
diff --git a/lightness/videoprocessor.py b/lightness/videoprocessor.py
index 7a75480..d6d7615 100644
--- a/lightness/videoprocessor.py
+++ b/lightness/videoprocessor.py
@@ -100,11 +100,12 @@ class VideoProcessor:
def __process_and_play_video(self, video_player):
self.__do_pre_cleanup()
- fps = self.__calculate_fps()
+ # fps = self.__calculate_fps()
time to first LED lights with two youtube-dl calls (seconds)
21
14
14
11
14
14
11
12
13
{
"custom_video_args": "--flip-x"
}
pi@raspberrypi:~/lightness $ sudo npm run build --prefix /home/pi/lightness/app
(node:20378) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
npm ERR! Error: ENOENT: no such file or directory, open '/home/pi/lightness/package.json'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Linux 4.19.56-v7+
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "run" "build" "--prefix" "/home/pi/lightness/app"
npm ERR! cwd /home/pi/lightness
pi@raspberrypi:~/lightness $ ./install/install.sh
> [email protected] build /home/pi/lightness/app
> react-scripts build
sh: 1: react-scripts: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
{
"server_config": {
},
"video_settings": {
"flip_x": true,
"flip_y": true
}
}