-
-
Save NitroNils/b77aac9e779cec37e77d880e20b11dc0 to your computer and use it in GitHub Desktop.
PinePhone record video with rear camera
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/ash | |
| # Credits to Kevin Kofler | |
| # https://forum.pine64.org/showthread.php?tid=16539&pid=109333#pid109333 | |
| if [ -z "$1" ] ; then | |
| echo "usage: ./record.sh videoname" | |
| exit 1 | |
| fi | |
| VF="" | |
| CUR_X=$(cat /sys/bus/iio/devices/iio\:device4/in_accel_x_raw) | |
| CUR_Y=$(cat /sys/bus/iio/devices/iio\:device4/in_accel_y_raw) | |
| ABS_CUR_X=${CUR_X#-} | |
| ABS_CUR_Y=${CUR_Y#-} | |
| if [ $ABS_CUR_X -ge $ABS_CUR_Y ] ; then | |
| if [ $CUR_X -ge 0 ] ; then | |
| echo "portrait" | |
| VF="-vf transpose,hflip" | |
| else | |
| echo "portrait inverted" | |
| VF="-vf transpose,vflip" | |
| fi | |
| else | |
| if [ $CUR_Y -lt 0 ] ; then | |
| echo "landscape clockwise" | |
| VF="" | |
| else | |
| echo "landscape counterclockwise" | |
| VF="-vf hflip,vflip" | |
| fi | |
| fi | |
| media-ctl -d1 -l'"gc2145 4-003c":0->1:0[0],"ov5640 4-004c":0->1:0[1]' || exit $? | |
| media-ctl -d1 -V'"ov5640 4-004c":0[fmt:UYVY8_2X8/1280x720@1/30]' || exit $? | |
| ffmpeg -input_format yuv420p -s 1280x720 -f video4linux2 -thread_queue_size 4096 -i /dev/video2 -f pulse -thread_queue_size 256 -i alsa_input.platform-sound.HiFi__hw_PinePhone_0__source -c:a flac -c:v ffvhuff "$1.mkv" || exit $? | |
| ffmpeg -i "$1.mkv" $VF -c:v libvpx-vp9 -c:a libopus "$1.webm" || exit $? | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment