
Recherche avancée
Autres articles (42)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...) -
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...)
Sur d’autres sites (4545)
-
Script doesnt recognize bars / length right for cutting audio , ffmpeg terminal
14 avril 2024, par totzillarbeatsThis terminal script doesn't recognize bars / length right for cutting audio, maybe somebody knows what's wrong with the calculation ...


Would be happy about any help the cutting already works !


#!/bin/bash

# Function to extract BPM from filename

get_bpm() {
 local filename="$1"
 local bpm=$(echo "$filename" | grep -oE '[0-9]{1,3}' | head -n1)
 echo "$bpm"
}

# Function to cut audio based on BPM
cut_audio() {
 local input_file="$1"
 local bpm="$2"
 local output_file="${input_file%.*}_cut.${input_file##*.}" # Appends "_cut" to original filename

 # Define the number of beats per bar (assuming 4 beats per bar)
 beats_per_bar=4

 # Calculate the duration of each bar in seconds
 bar_duration=$((60 * beats_per_bar / bpm))

 # Define start and end times for each bar range
 start_times=(0 21 33 45 57 69 81 93 105 117 129 141)
 end_times=(20 29 41 53 65 77 89 101 113 125 137 149)

 # Iterate through each bar range
 for ((i = 0; i < ${#start_times[@]}; i++)); do
 start_time=${start_times[$i]}
 end_time=${end_times[$i]}
 echo "Cutting audio file $input_file at $bpm BPM for bar $((i + 1)) ($start_time-$end_time) for $bar_duration seconds..."

 # Cut audio for current bar range using ffmpeg
 ffmpeg -i "$input_file" -ss "$start_time" -to "$end_time" -c copy "$output_file"_"$((i + 1)).${input_file##*.}" -y
 done

 # Check if the output files are empty and delete them if so
 for output_file in "${output_file}"_*; do
 if [ ! -s "$output_file" ]; then
 echo "Output file $output_file is empty. Deleting..."
 rm "$output_file"
 fi
 done

 echo "Audio cut and saved as $output_file"
}


# Main script
if [ "$#" -eq 0 ]; then
 echo "Usage: $0 [audio_file1] [audio_file2] ..."
 exit 1
fi

for file in "$@"; do
 bpm=$(get_bpm "$file")
 if [ -z "$bpm" ]; then
 echo "Error: No BPM found in filename $file"
 else
 cut_audio "$file" "$bpm"
 fi
done



Maybe its only the math calc in the beginning but idk :)


If you need more details just lmk


-
Batch : Looping through folders and subfolders and get them into a script
2 janvier 2017, par arielbejeI want to convert
.flac
files fromX:\Music\flac\flacfolder\name.flac
toX:\Music\mp3\flacfolder\name.mp3
usingffmpeg
, but I couldn’t find how to loop through while passing the directory to a different command and manipulating it. -
Calling pkill to pause a process with subprocess inside a class in python suspends the python script
31 mars 2017, par muammarI have a class that contains a "blocking method". Inside that method, I am listening to keys to perform some actions. The action in question is
pkill
. Below I am pasting it :def show_control(self, control):
"""docstring for control"""
if control == True:
from mkchromecast.getch import getch, pause
self.controls_msg()
try:
while(True):
key = getch()
if(key == 'p'):
if self.videoarg == True:
print('Pausing Casting Process...')
subprocess.call(['pkill', '-STOP', '-f', 'ffmpeg'])
...It turns out that the
ffmpeg
process is paused, but the python script gets suspended ?. I don’t understand why that is the case. If one creates the same function in a regular script (not inside a class to be clearer) this does not happen. I have tried usingmultithreading
andmultiprocessing
modules without success. What am I doing wrong ?. Thanks.