import videos to raws dir

This commit is contained in:
Gabriel Radureau
2025-10-11 19:15:58 +02:00
parent d20f00f7ac
commit 4f80b8b70d
3 changed files with 90 additions and 14 deletions

View File

@@ -26,6 +26,8 @@ un programme se déclenche pour synchroniser son contenu avec le dossier de sort
1. Mac
2. Une carte SD nommée SD_DANSE formatée en `MS-DOS (FAT32)` pour un meilleur support des projecteurs
3. les programmes parallel, exiftool et ffmpeg
`brew install parallel exiftool ffmpeg`
## [Surveillance des répertoires](./doc/01.SurveillerRepertoire.md)

77
program1/program1.sh Executable file
View File

@@ -0,0 +1,77 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# === CONFIGURATION ===
export DOSSIER_SOURCE="${HOME}/Downloads"
export DOSSIER_DESTINATION_RAW="${HOME}/Documents/.DanceVideos/raw"
sanitize_name() {
local name="$1"
basename "$name" \
| tr '[:upper:]' '[:lower:]' \
| tr ' ' '_' \
| tr -cd '[:alnum:]._-\n'
}
export -f sanitize_name
# Fonction pour vérifier et déplacer un fichier
check_and_move() {
local fichier="$1"
local taille1 taille2
taille1=$(stat -f "%z" "$fichier")
sleep 5
taille2=$(stat -f "%z" "$fichier")
if [ "$taille1" -eq "$taille2" ] && [ "$taille2" -gt 0 ]; then
echo "Déplacement de $(basename "$fichier")"
rsync -av --remove-source-files "$fichier" "$DOSSIER_DESTINATION_RAW/$(sanitize_name "$(basename "$fichier")")"
else
echo "Fichier $(basename "$fichier") encore en cours de réception."
fi
}
export -f check_and_move
import_downloaded_file() {
find "$DOSSIER_SOURCE" -maxdepth 1 -type f \( -iname "*.mp4" -o -iname "*.mov" \) -print0 \
| parallel -0 -j 4 check_and_move
}
import_downloaded_file
##
export DOSSIER_DESTINATION_MP4="$(dirname $DOSSIER_DESTINATION_RAW)/videos"
iphone_video() {
local raw="$1"
echo iphone $raw
}
export -f iphone_video
screen_video() {
local raw="$1"
echo screen $raw
}
export -f screen_video
whatsapp_video() {
local raw="$1"
echo whatsapp $raw
}
export -f whatsapp_video
convert_raws() {
# ##_##.mov
find "$DOSSIER_DESTINATION_RAW" -type f \
-name "*.mov" \
-print0 | parallel -0 -j 4 iphone_video
find "$DOSSIER_DESTINATION_RAW" -type f \
-name "screenrecording*.mp4" \
-print0 | parallel -0 -j 4 screen_video
find "$DOSSIER_DESTINATION_RAW" -type f \
-name '*[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]*.mp4' \
-print0 | parallel -0 -j 4 whatsapp_video
}
convert_raws

View File

@@ -1,18 +1,15 @@
#! /bin/bash
set -eux
date
echo `date` >> /tmp/heho
find ${HOME}/Downloads
mkdir -p ${HOME}/Documents/.DanceVideos
find ${HOME}/Documents/.DanceVideos
set -euo pipefail
DLDIR=${HOME}/Downloads
SCRIPTS_DIR=$(dirname `realpath ${BASH_SOURCE[0]}`)
DESTDIR=${HOME}/Documents/.DanceVideos
program1="$SCRIPTS_DIR/../program1/program1.sh"
DL_VIDEOS=`find $DLDIR -type f -iname "*.mp4" -or -iname "*.mov" -maxdepth 1`
[ -z "$DL_VIDEOS" ] || {
for v in "$DL_VIDEOS"; do
echo `basename "$v"` >> /tmp/foo
done
}
if [ ! -f "$program1" ]; then
>&2 echo "program1 not found"
exit 1
fi
export PATH="/opt/homebrew/bin:${PATH}"
$program1