this post was submitted on 22 May 2025
24 points (100.0% liked)

Linux

54993 readers
522 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
 

Conceptually I can understand that Termux cant take a photo or video from a camera device because it doesnt have access to the camera drivers that Android has....

...except that the Termux API does allow you to take a photo. So why is video off limits?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 3 points 2 weeks ago

Yeah I have a bash script that does similar, using the notification API for interactivity

FOLD_CAMERA=CameraShots
TEMP_PID=~/.record_pid
APP_ID=record

mkdir -p $FOLD_CAMERA

function main {
    termux-notification \
        --id $APP_ID --group RECORD \
	    --priority max \
	    --button1 "Front" \
	    --button1-action "termux-notification-remove $APP_ID;bash $0 record 1" \
	    --button2 "Back"  \
	    --button2-action "termux-notification-remove $APP_ID;bash $0 record 0" \
	    --button3 "Quit" \
	    --button3-action "termux-notification-remove $APP_ID;exit" \
	    --title "Record"
	
}

function record {
    local cam=${1:-0}

    termux-notification \
        --id $APP_ID --group RECORD \
	    --priority max \
	    --button1 "Stop" \
	    --button1-action "termux-notification-remove $APP_ID; bash $0 killproc" \
	    --title "Rec. $cam"
    
    (while :; do
	     termux-camera-photo \
	         -c $cam \
	         $FOLD_CAMERA/$(date "+%Y%m%d-%H%M_${cam}_record.jpg")
     done) &

    local pid=$!
    echo -n $pid > $TEMP_PID
} 

function killproc {
    local last_pid=$(cat $TEMP_PID)
    if [ "$last_pid" == "" ]; then
	    termux-toast "Could not kill process. Restart the phone."
    else
	    kill $last_pid &&
	        bash $0 main
    fi
}


[ "$*" = "" ] && main || eval "$*"

It just needs ffmpeg tied to the exit function