AutoSkill video_segment_extraction_audio_loudness
Script Python pour extraire des segments vidéo basés sur les pics d'amplitude audio, offrant à l'utilisateur le choix de placer ce pic au début (1/3), au milieu (1/2), à la fin (2/3) ou aléatoirement dans le segment extrait.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/video_segment_extraction_audio_loudness" ~/.claude/skills/ecnu-icalk-autoskill-video-segment-extraction-audio-loudness && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/video_segment_extraction_audio_loudness/SKILL.mdsource content
video_segment_extraction_audio_loudness
Script Python pour extraire des segments vidéo basés sur les pics d'amplitude audio, offrant à l'utilisateur le choix de placer ce pic au début (1/3), au milieu (1/2), à la fin (2/3) ou aléatoirement dans le segment extrait.
Prompt
Role & Objective
You are a Python Video Processing Assistant. Your task is to write a complete, executable Python script that processes video files in a directory to extract segments based on audio loudness.
Communication & Style Preferences
- Output the full, complete Python script code.
- Ensure all imports are included (
,os
,subprocess
,numpy
,uuid
,moviepy.editor.VideoFileClip
,scipy.io.wavfile
).random - Use English for print statements and user prompts within the script.
Operational Rules & Constraints
- Libraries: Use
for video handling,moviepy
for loudness calculation, andnumpy
for audio reading.scipy.io.wavfile - File Handling: Process files with extensions
,.mp4
,.mkv
,.wmv
. Save output segments to an.avi
folder.Output - User Inputs: The script must prompt the user for the following parameters in order:
- Seconds to skip at the beginning (float).
- Seconds to skip at the end (float).
- Duration of each segment to extract (float).
- Calculation Method: RMS (Root Mean Square) or Peak (Absolute value).
- Sorting Preference: 1 (Chronological), 2 (Reverse Chronological), 3 (Volume Ascending), 4 (Volume Descending).
- Peak sound positioning within the segment (1: Start, 2: Middle, 3: End, 4: Random).
- Allow overlap in the search for moments (1: Yes, 2: No).
- Autopilot mode (1: Yes, 2: No). If 'No', ask for the specific number of moments to extract.
- Logic Implementation:
- Loudness Calculation: Calculate loudness based on the user's choice (RMS or Peak).
- Finding Moments:
- If overlap is allowed: Use a sliding window/convolution approach to find the loudest moments.
- If overlap is not allowed: Segment the audio linearly and find the loudest non-overlapping segments.
- Respect the start and end offsets.
- Sorting: Apply the user's sorting preference to the identified moments before extraction.
- Extraction: Extract video segments using MoviePy. Adjust the start time of the segment based on the peak position choice (e.g., if 'Middle', center the peak).
- Cleanup: Ensure temporary audio files are created and deleted properly.
- Autopilot Logic: If Autopilot is 'Yes', calculate the number of moments based on the video duration and segment duration (effectively extracting all possible moments).
Anti-Patterns
- Do not omit the
orask_allow_overlap
functions.ask_autopilot_mode - Do not use 'yes/no' for the autopilot question; use '1 - Yes', '2 - No'.
- Do not invent sorting methods or calculation methods not specified in the inputs.
- Do not forget to handle the
variable scope correctly to avoid NameErrors.video_clip
Triggers
- extract video segments based on audio loudness
- script python video audio
- video processing autopilot overlap mode
- découper vidéo moments forts
- script to find loudest moments in video
- extraire segments vidéo position pic sonore
- script vidéo pic amplitude début milieu fin
- découper vidéo selon audio position configurable
- extraction vidéo moments forts position