├── programs
├── crtmpserver
│ ├── .gitignore
│ ├── jwplayer-6.10.zip
│ ├── index.rtsp.html
│ ├── index.flv.html
│ └── flvplayback.lua
├── faac-1.28.tar.gz
├── lame-3.99.5.tar.gz
├── motion-mmal-opt.tar.gz
├── motion-rpi-cam.html
├── shutdown_button
│ ├── Makefile
│ ├── shutdown_button_init
│ └── shutdown_button.c
├── bbpicam_stream
├── TEMPered-fix-broken-cmakelists.patch
├── temper2led_init
├── bbpicam
├── ffmpeg-reduce-max-interleave-delta.patch
└── TEMPered-add-temper2led.patch
├── kernel
├── .gitignore
├── build_env
├── README
├── bcm2708-i2s-sync-to-gpclk0.patch
├── rpi-mbed-use-gpclk0-as-mclk.patch
├── add-rpi-mbed.patch
└── add-leds-pca9635.patch
├── docs
├── day.jpg
├── night.jpg
├── pca9635.png
├── bbPiCam_mini.jpg
├── mic_circuit.png
├── reset_button.png
├── mbed-codec-mods.jpg
├── cap1988l-2-camera.jpg
└── mbed_audio_codec_i2s.jpg
├── .gitmodules
├── tests
├── test_pca9635
└── plot_wave
├── LICENSE
└── README.md
/programs/crtmpserver/.gitignore:
--------------------------------------------------------------------------------
1 | jwplayer
2 |
--------------------------------------------------------------------------------
/kernel/.gitignore:
--------------------------------------------------------------------------------
1 | modules/*
2 | modules.tar.gz
3 |
--------------------------------------------------------------------------------
/docs/day.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/docs/day.jpg
--------------------------------------------------------------------------------
/docs/night.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/docs/night.jpg
--------------------------------------------------------------------------------
/docs/pca9635.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/docs/pca9635.png
--------------------------------------------------------------------------------
/docs/bbPiCam_mini.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/docs/bbPiCam_mini.jpg
--------------------------------------------------------------------------------
/docs/mic_circuit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/docs/mic_circuit.png
--------------------------------------------------------------------------------
/docs/reset_button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/docs/reset_button.png
--------------------------------------------------------------------------------
/docs/mbed-codec-mods.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/docs/mbed-codec-mods.jpg
--------------------------------------------------------------------------------
/docs/cap1988l-2-camera.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/docs/cap1988l-2-camera.jpg
--------------------------------------------------------------------------------
/programs/faac-1.28.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/programs/faac-1.28.tar.gz
--------------------------------------------------------------------------------
/programs/lame-3.99.5.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/programs/lame-3.99.5.tar.gz
--------------------------------------------------------------------------------
/docs/mbed_audio_codec_i2s.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/docs/mbed_audio_codec_i2s.jpg
--------------------------------------------------------------------------------
/programs/motion-mmal-opt.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/programs/motion-mmal-opt.tar.gz
--------------------------------------------------------------------------------
/programs/crtmpserver/jwplayer-6.10.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasaw/bbPiCam/HEAD/programs/crtmpserver/jwplayer-6.10.zip
--------------------------------------------------------------------------------
/programs/motion-rpi-cam.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/programs/shutdown_button/Makefile:
--------------------------------------------------------------------------------
1 | ifneq ($(SRC),)
2 | VPATH=$(SRC)
3 | endif
4 |
5 | CFLAGS += -I. -I$(SRC) -Wall -std=c99 -D_BSD_SOURCE=1 -D_GNU_SOURCE=1
6 |
7 | all: shutdown_button
8 |
9 | shutdown_button: shutdown_button.o
10 | $(CC) -o $@ $^
11 |
12 | clean:
13 | rm -rf *.o $(all)
14 |
--------------------------------------------------------------------------------
/kernel/build_env:
--------------------------------------------------------------------------------
1 | export ARCH=arm
2 | export CROSS_COMPILE=/home/jooaun/work/bbPiCam/kernel/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-
3 | export INSTALL_MOD_PATH=/home/jooaun/work/bbPiCam/kernel/modules
4 | export KERNEL_SRC=/home/jooaun/work/bbPiCam/kernel/linux
5 |
6 |
--------------------------------------------------------------------------------
/programs/bbpicam_stream:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | PATH=/sbin:/usr/sbin:/bin:/usr/bin
4 |
5 | sleep 10
6 |
7 | FIFO=/tmp/live.h264
8 |
9 | #raspivid -w 1280 -h 960 -fps 24 -g 24 -t 0 -b 600000 -o - | LD_LIBRARY_PATH=/usr/local/lib ffmpeg -fflags +nobuffer -re -i - -fflags +nobuffer -re -f alsa -ar 16000 -ac 2 -i hw:1,0 -map 0:0 -map 1:0 -c:v copy -strict -2 -c:a aac -b:a 16k -ac 1 -af "pan=1c|c0=c1" -f rtsp -metadata title=bbPiCam rtsp://0.0.0.0:554
10 |
11 | mkfifo $FIFO
12 | raspivid -w 1280 -h 960 -fps 24 -g 24 -t 0 -b 600000 -o $FIFO &
13 | export LD_LIBRARY_PATH=/usr/local/lib
14 | exec ffmpeg -fflags +nobuffer -re -i $FIFO -fflags +nobuffer -re -f alsa -ar 16000 -ac 2 -i hw:1,0 -map 0:0 -map 1:0 -c:v copy -strict -2 -c:a aac -b:a 16k -ac 1 -af "pan=1c|c0=c1" -f rtsp -metadata title=bbPiCam rtsp://0.0.0.0:554
15 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "kernel/tools"]
2 | path = kernel/tools
3 | url = git://github.com/raspberrypi/tools.git
4 | [submodule "kernel/linux"]
5 | path = kernel/linux
6 | url = https://github.com/raspberrypi/linux.git
7 | [submodule "programs/ffmpeg"]
8 | path = programs/ffmpeg
9 | url = git://source.ffmpeg.org/ffmpeg.git
10 | [submodule "programs/hidapi"]
11 | path = programs/hidapi
12 | url = https://github.com/signal11/hidapi.git
13 | [submodule "programs/motion-mmal"]
14 | path = programs/motion-mmal
15 | url = https://github.com/dozencrows/motion.git
16 | [submodule "programs/psips"]
17 | path = programs/psips
18 | url = https://github.com/AndyA/psips.git
19 | [submodule "programs/TEMPered"]
20 | path = programs/TEMPered
21 | url = https://github.com/edorfaus/TEMPered.git
22 | [submodule "programs/x264"]
23 | path = programs/x264
24 | url = git://git.videolan.org/x264
25 |
--------------------------------------------------------------------------------
/tests/test_pca9635:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | LED_PATH="/sys/bus/i2c/devices/1-0007"
4 |
5 | echo 02020202020202020202020202020202 > ${LED_PATH}/led_state
6 | echo 000100200300400500600700800900a00b00c00d00e00f00 > ${LED_PATH}/led_brightness
7 | sleep 3
8 |
9 | echo 0ff100200300400500600700800900a00b00c00d00e00f00 > ${LED_PATH}/led_brightness
10 | sleep 3
11 |
12 | echo 0001ff200300400500600700800900a00b00c00d00e00f00 > ${LED_PATH}/led_brightness
13 | sleep 3
14 |
15 | echo 0001002ff300400500600700800900a00b00c00d00e00f00 > ${LED_PATH}/led_brightness
16 | sleep 3
17 |
18 | echo 0ff1002ff300400500600700800900a00b00c00d00e00f00 > ${LED_PATH}/led_brightness
19 | sleep 3
20 |
21 | echo 0ff1ff200300400500600700800900a00b00c00d00e00f00 > ${LED_PATH}/led_brightness
22 | sleep 3
23 |
24 | echo 0001ff2ff300400500600700800900a00b00c00d00e00f00 > ${LED_PATH}/led_brightness
25 | sleep 3
26 |
27 | echo 0ff1ff2ff3ff4ff5ff6ff7ff8ff9ffaffbffcffdffefffff > ${LED_PATH}/led_brightness
28 | sleep 3
29 |
30 | echo 000100200300400500600700800900a00b00c00d00e00f00 > ${LED_PATH}/led_brightness
31 |
--------------------------------------------------------------------------------
/programs/TEMPered-fix-broken-cmakelists.patch:
--------------------------------------------------------------------------------
1 | commit dc366a2fbfeab5686241967968f36eaf1c458370
2 | Author: Joo Aun Saw
3 | Date: Fri Sep 19 17:18:35 2014 +1000
4 |
5 | fix broken cmakelists.
6 |
7 | diff --git a/CMakeLists.txt b/CMakeLists.txt
8 | index b3cd007..5c95f13 100644
9 | --- a/CMakeLists.txt
10 | +++ b/CMakeLists.txt
11 | @@ -17,7 +17,7 @@ if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
12 | # directory with the name GNUInstallDirs (without the extension).
13 | endif()
14 |
15 | -option(BUILD_HIDAPI_SHARED "Build with shared version of HIDAPI" ON)
16 | +option(BUILD_HIDAPI_SHARED "Build with shared version of HIDAPI" OFF)
17 |
18 | option(BUILD_SHARED_LIB "Build shared version of tempered library" ON)
19 | option(BUILD_STATIC_LIB "Build static version of tempered library" OFF)
20 | @@ -54,7 +54,7 @@ else()
21 | )
22 | set(HIDAPI_STATIC_OBJECT ${HIDAPI_OBJECT})
23 | find_package(PkgConfig REQUIRED)
24 | - if (HIDAPI_OBJECT MATCHES \(-libusb|/libusb/(.libs/)?hid\)\\.o\$)
25 | + if (HIDAPI_OBJECT MATCHES \(-libusb|/libusb/\(.libs/\)?hid\)\\.o\$)
26 | pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
27 | set(HIDAPI_LINK_LIBS ${LIBUSB_LIBRARIES} rt pthread)
28 | else()
29 |
--------------------------------------------------------------------------------
/programs/temper2led_init:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | ### BEGIN INIT INFO
3 | # Provides: temper2led
4 | # Required-Start: $local_fs $remote_fs
5 | # Required-Stop: $local_fs $remote_fs
6 | # Default-Start: 2 3 4 5
7 | # Default-Stop: 0 1 6
8 | # Short-Description: Temperature to LED
9 | # Description: Temperature to LED.
10 | ### END INIT INFO
11 |
12 | # Author: Joo Aun Saw
13 |
14 | PATH=/sbin:/usr/sbin:/bin:/usr/bin
15 | DESC="Temperature to LED"
16 | NAME=temper2led
17 | DAEMON=/opt/temper2led/temper2led
18 | PIDFILE=/var/run/$NAME.pid
19 | SCRIPTNAME=/etc/init.d/${NAME}_init
20 |
21 | [ -x $DAEMON ] || exit 0
22 |
23 | . /lib/init/vars.sh
24 | . /lib/lsb/init-functions
25 |
26 |
27 |
28 | case $1 in
29 | start)
30 | log_daemon_msg "Starting $DESC " "$NAME"
31 | start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile --exec $DAEMON
32 | status=$?
33 | log_end_msg $status
34 | ;;
35 | stop)
36 | log_daemon_msg "Stopping $DESC" "$NAME"
37 | start-stop-daemon --stop --quiet --pidfile $PIDFILE
38 | status=$?
39 | log_end_msg $status
40 | rm -f $PIDFILE
41 | ;;
42 | restart|force-reload)
43 | $0 stop && sleep 2 && $0 start
44 | ;;
45 | status)
46 | status_of_proc "$DAEMON" "$NAME"
47 | ;;
48 | *)
49 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}"
50 | exit 2
51 | ;;
52 | esac
53 |
--------------------------------------------------------------------------------
/programs/bbpicam:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | ### BEGIN INIT INFO
3 | # Provides: bbpicam
4 | # Required-Start: $network $local_fs $remote_fs crtmpserver nginx
5 | # Required-Stop: $network $local_fs $remote_fs crtmpserver nginx
6 | # Default-Start: 3 4 5
7 | # Default-Stop: 0 1 6
8 | # Short-Description: Raspivid to ffmpeg
9 | # Description: Video capture via raspivid and ffmpeg.
10 | ### END INIT INFO
11 |
12 | # Author: Joo Aun Saw
13 |
14 | PATH=/sbin:/usr/sbin:/bin:/usr/bin
15 | DESC="Video Capture"
16 | NAME=bbpicam
17 | DAEMON=/opt/bbpicam/bbpicam_stream
18 | PIDFILE=/var/run/$NAME.pid
19 | SCRIPTNAME=/etc/init.d/$NAME
20 |
21 | [ -x $DAEMON ] || exit 0
22 |
23 | . /lib/init/vars.sh
24 | . /lib/lsb/init-functions
25 |
26 |
27 |
28 | case $1 in
29 | start)
30 | log_daemon_msg "Starting $DESC " "$NAME"
31 | start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile --exec $DAEMON
32 | status=$?
33 | log_end_msg $status
34 | ;;
35 | stop)
36 | log_daemon_msg "Stopping $DESC" "$NAME"
37 | start-stop-daemon --stop --quiet --pidfile $PIDFILE
38 | status=$?
39 | log_end_msg $status
40 | rm -f $PIDFILE
41 | ;;
42 | restart|force-reload)
43 | $0 stop && sleep 2 && $0 start
44 | ;;
45 | status)
46 | status_of_proc "$DAEMON" "$NAME"
47 | ;;
48 | *)
49 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}"
50 | exit 2
51 | ;;
52 | esac
53 |
54 |
--------------------------------------------------------------------------------
/programs/shutdown_button/shutdown_button_init:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | ### BEGIN INIT INFO
3 | # Provides: shutdown_button
4 | # Required-Start: $local_fs $remote_fs
5 | # Required-Stop: $local_fs $remote_fs
6 | # Default-Start: 2 3 4 5
7 | # Default-Stop: 0 1 6
8 | # Short-Description: Shutdown Button
9 | # Description: Shuts down when shutdown button is pressed.
10 | ### END INIT INFO
11 |
12 | # Author: Joo Aun Saw
13 |
14 | PATH=/sbin:/usr/sbin:/bin:/usr/bin
15 | DESC="Shutdown Button"
16 | NAME=shutdown_button
17 | DAEMON=/opt/shutdown_button/shutdown_button
18 | PIDFILE=/var/run/$NAME.pid
19 | SCRIPTNAME=/etc/init.d/$NAME
20 |
21 | [ -x $DAEMON ] || exit 0
22 |
23 | . /lib/init/vars.sh
24 | . /lib/lsb/init-functions
25 |
26 |
27 |
28 | case $1 in
29 | start)
30 | log_daemon_msg "Starting $DESC " "$NAME"
31 | start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile --exec $DAEMON
32 | status=$?
33 | log_end_msg $status
34 | ;;
35 | stop)
36 | log_daemon_msg "Stopping $DESC" "$NAME"
37 | start-stop-daemon --stop --quiet --pidfile $PIDFILE
38 | status=$?
39 | log_end_msg $status
40 | rm -f $PIDFILE
41 | ;;
42 | restart|force-reload)
43 | $0 stop && sleep 2 && $0 start
44 | ;;
45 | status)
46 | status_of_proc "$DAEMON" "$NAME"
47 | ;;
48 | *)
49 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}"
50 | exit 2
51 | ;;
52 | esac
53 |
--------------------------------------------------------------------------------
/tests/plot_wave:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | """ Plots wav file """
3 |
4 | import os
5 | current_dir = os.path.dirname(os.path.realpath(__file__))
6 | import sys
7 |
8 | import wave
9 | import numpy as np
10 | import matplotlib.pyplot as plt
11 |
12 | #mpl.rcParams['examples.directory'] = current_dir
13 |
14 |
15 |
16 |
17 |
18 | def print_usage(prog_cmd):
19 | print "Usage: %s " % prog_cmd
20 |
21 |
22 | def run():
23 | if len(sys.argv) != 2:
24 | print_usage(sys.argv[0])
25 | sys.exit(-1)
26 |
27 | wavefile = sys.argv[1]
28 |
29 | if not os.path.isfile(wavefile):
30 | print "Error: Wave file \"%s\" not found." % wavefile
31 | sys.exit(-1)
32 |
33 | spf = wave.open(wavefile,'r')
34 | # Extract Raw Audio from Wav File
35 | raw = spf.readframes(-1)
36 | signal = np.fromstring(raw, 'Int16').reshape((-1,spf.getnchannels()))
37 |
38 | fig = plt.figure()
39 |
40 | # Write raw samples to file
41 | #outfile = 'raw.out'
42 | #with open(outfile, "w") as ofile:
43 | # for idx, values in enumerate(signal):
44 | # for v in values:
45 | # ofile.write("%11d\t" % v)
46 | # ofile.write("\n")
47 |
48 | for i in range(spf.getnchannels()):
49 | ax = fig.add_subplot(spf.getnchannels(), 1, i+1)
50 | ax.set_title('Channel %d' % (i+1))
51 | ax.plot(signal[:, i])
52 |
53 | plt.show()
54 |
55 |
56 |
57 | if __name__ == "__main__":
58 | run()
59 |
--------------------------------------------------------------------------------
/programs/ffmpeg-reduce-max-interleave-delta.patch:
--------------------------------------------------------------------------------
1 | diff --git a/libavformat/options_table.h b/libavformat/options_table.h
2 | index eb4115c..f4c3813 100644
3 | --- a/libavformat/options_table.h
4 | +++ b/libavformat/options_table.h
5 | @@ -88,7 +88,7 @@ static const AVOption avformat_options[] = {
6 | {"flush_packets", "enable flushing of the I/O context after each packet", OFFSET(flush_packets), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E},
7 | {"metadata_header_padding", "set number of bytes to be written as padding in a metadata header", OFFSET(metadata_header_padding), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, E},
8 | {"output_ts_offset", "set output timestamp offset", OFFSET(output_ts_offset), AV_OPT_TYPE_DURATION, {.i64 = 0}, -INT64_MAX, INT64_MAX, E},
9 | -{"max_interleave_delta", "maximum buffering duration for interleaving", OFFSET(max_interleave_delta), AV_OPT_TYPE_INT64, { .i64 = 10000000 }, 0, INT64_MAX, E },
10 | +{"max_interleave_delta", "maximum buffering duration for interleaving", OFFSET(max_interleave_delta), AV_OPT_TYPE_INT64, { .i64 = 500000 }, 0, INT64_MAX, E },
11 | {"f_strict", "how strictly to follow the standards (deprecated; use strict, save via avconv)", OFFSET(strict_std_compliance), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, D|E, "strict"},
12 | {"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, D|E, "strict"},
13 | {"strict", "strictly conform to all the things in the spec no matter what the consequences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_STRICT }, INT_MIN, INT_MAX, D|E, "strict"},
14 |
--------------------------------------------------------------------------------
/programs/crtmpserver/index.rtsp.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | BB Pi Camera RTMP stream
4 |
5 |
6 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
49 |
50 |