Quality Filtering
Included with Lifetime
$97 forever
Accept/reject logic and quality scoring heuristics for media content
media-curator
What this skill does
# Quality Filtering Skill
## Overview
Implements the quality assessment logic used by the Quality Assessor agent. Provides reusable scoring heuristics, threshold configuration, and acceptance criteria for media content evaluation.
## Title Keyword Scoring
### Positive Quality Indicators
| Pattern | Score Modifier | Match Examples | Confidence |
|---------|---------------|----------------|------------|
| `4K\|2160p` | +3 | "4K Official", "2160p Pro Shot" | High |
| `1080p\|HD\|High Definition` | +2 | "1080p HD", "High Definition" | High |
| `Pro Shot\|Professional` | +3 | "Pro Shot Concert", "Professional Recording" | High |
| `Official\|Verified` | +2 | "Official Music Video", "Verified Upload" | High |
| `Studio Session\|Soundboard\|Board Recording` | +3 | "Studio Session Live", "Soundboard Audio" | High |
| `FLAC\|Lossless\|WAV\|ALAC` | +3 | "FLAC Audio", "Lossless Recording" | High |
| `Remastered\|Restored\|Enhanced` | +2 | "Remastered 2024", "Audio Restored" | Medium |
| `Multicam\|Multi-Camera` | +2 | "Multicam Mix", "Multi-Camera Edit" | Medium |
| `60fps\|HFR` | +1 | "60fps Smooth", "HFR Recording" | Medium |
### Negative Quality Indicators
| Pattern | Score Modifier | Match Examples | Confidence |
|---------|---------------|----------------|------------|
| `phone\|mobile\|cell` | -4 | "phone recording", "mobile upload" | High |
| `fan cam\|fancam\|audience` | -3 | "fan cam row 20", "audience recording" | High |
| `crowd\|venue mic\|distant` | -2 | "crowd recording", "distant mic" | Medium |
| `shaky\|unstable\|handheld` | -3 | "shaky camera", "unstable footage" | High |
| `bad audio\|poor quality\|low quality` | -4 | "bad audio sorry", "poor quality" | High |
| `240p\|360p\|potato` | -3 | "240p upload", "potato quality" | High |
| `vertical\|portrait mode` | -2 | "vertical video", "portrait mode" | High |
| `bootleg\|pirated\|ripped` | -1 | "bootleg copy", "ripped from DVD" | Low |
| `compressed\|low bitrate` | -2 | "compressed audio", "low bitrate" | Medium |
| `cropped\|zoomed\|partial` | -1 | "cropped video", "zoomed in" | Medium |
### Scoring Implementation
```javascript
function calculateTitleScore(title) {
let score = 0;
const normalizedTitle = title.toLowerCase();
// Positive indicators
const positivePatterns = [
{ regex: /4k|2160p/, modifier: 3 },
{ regex: /1080p|hd|high definition/, modifier: 2 },
{ regex: /pro shot|professional/, modifier: 3 },
{ regex: /official|verified/, modifier: 2 },
{ regex: /studio session|soundboard|board recording/, modifier: 3 },
{ regex: /flac|lossless|wav|alac/, modifier: 3 },
{ regex: /remastered|restored|enhanced/, modifier: 2 },
{ regex: /multicam|multi-camera/, modifier: 2 },
{ regex: /60fps|hfr/, modifier: 1 }
];
// Negative indicators
const negativePatterns = [
{ regex: /phone|mobile|cell/, modifier: -4 },
{ regex: /fan cam|fancam|audience/, modifier: -3 },
{ regex: /crowd|venue mic|distant/, modifier: -2 },
{ regex: /shaky|unstable|handheld/, modifier: -3 },
{ regex: /bad audio|poor quality|low quality/, modifier: -4 },
{ regex: /240p|360p|potato/, modifier: -3 },
{ regex: /vertical|portrait mode/, modifier: -2 },
{ regex: /bootleg|pirated|ripped/, modifier: -1 },
{ regex: /compressed|low bitrate/, modifier: -2 },
{ regex: /cropped|zoomed|partial/, modifier: -1 }
];
// Apply positive modifiers
for (const pattern of positivePatterns) {
if (pattern.regex.test(normalizedTitle)) {
score += pattern.modifier;
}
}
// Apply negative modifiers
for (const pattern of negativePatterns) {
if (pattern.regex.test(normalizedTitle)) {
score += pattern.modifier;
}
}
return score;
}
```
## Metadata Assessment Commands
### Resolution Detection
```bash
# Extract video resolution
get_resolution() {
local file="$1"
ffprobe -v error -select_streams v:0 \
-show_entries stream=width,height \
-of csv=s=x:p=0 "$file"
}
# Score based on resolution
score_resolution() {
local resolution="$1"
local width height
IFS='x' read -r width height <<< "$resolution"
if [[ $width -ge 3840 ]]; then
echo 10 # 4K+
elif [[ $width -ge 1920 ]]; then
echo 8 # 1080p
elif [[ $width -ge 1280 ]]; then
echo 6 # 720p
elif [[ $width -ge 640 ]]; then
echo 4 # 480p
else
echo 2 # <480p
fi
}
```
### Audio Bitrate Detection
```bash
# Extract audio bitrate
get_audio_bitrate() {
local file="$1"
ffprobe -v error -select_streams a:0 \
-show_entries stream=bit_rate \
-of default=noprint_wrappers=1:nokey=1 "$file"
}
# Score based on bitrate
score_audio_bitrate() {
local bitrate="$1"
if [[ $bitrate -ge 1000000 ]]; then
echo 10 # Lossless (>1000kbps)
elif [[ $bitrate -ge 256000 ]]; then
echo 8 # High (256-320kbps)
elif [[ $bitrate -ge 192000 ]]; then
echo 6 # Medium (192-256kbps)
elif [[ $bitrate -ge 128000 ]]; then
echo 4 # Low (128-192kbps)
else
echo 2 # Very low (<128kbps)
fi
}
```
### Duration Sanity Check
```bash
# Extract duration in seconds
get_duration() {
local file="$1"
ffprobe -v error \
-show_entries format=duration \
-of default=noprint_wrappers=1:nokey=1 "$file"
}
# Validate duration makes sense
validate_duration() {
local duration="$1"
local expected_min="$2" # Optional minimum duration
local expected_max="$3" # Optional maximum duration
# Check duration is reasonable (>5 seconds, <12 hours)
if (( $(echo "$duration < 5" | bc -l) )); then
echo "ERROR: Duration too short ($duration seconds)"
return 1
elif (( $(echo "$duration > 43200" | bc -l) )); then
echo "ERROR: Duration suspiciously long ($duration seconds)"
return 1
fi
# Check against expected range if provided
if [[ -n "$expected_min" ]] && (( $(echo "$duration < $expected_min" | bc -l) )); then
echo "WARNING: Duration shorter than expected ($duration < $expected_min)"
fi
if [[ -n "$expected_max" ]] && (( $(echo "$duration > $expected_max" | bc -l) )); then
echo "WARNING: Duration longer than expected ($duration > $expected_max)"
fi
return 0
}
```
### Format Detection
```bash
# Detect audio codec
get_audio_codec() {
local file="$1"
ffprobe -v error -select_streams a:0 \
-show_entries stream=codec_name \
-of default=noprint_wrappers=1:nokey=1 "$file"
}
# Detect video codec
get_video_codec() {
local file="$1"
ffprobe -v error -select_streams v:0 \
-show_entries stream=codec_name \
-of default=noprint_wrappers=1:nokey=1 "$file"
}
# Score audio codec quality
score_audio_codec() {
local codec="$1"
case "$codec" in
flac|alac|wav|ape)
echo 10 # Lossless
;;
aac|opus)
echo 8 # Modern lossy (efficient)
;;
mp3|vorbis)
echo 6 # Standard lossy
;;
*)
echo 4 # Unknown/old codec
;;
esac
}
```
## Post-Download Verification
### Audio Quality Analysis
```bash
# Analyze volume levels and detect clipping
analyze_audio_quality() {
local file="$1"
local tmpfile=$(mktemp)
# Volume detection
ffmpeg -i "$file" -af "volumedetect" -f null /dev/null 2>&1 | \
grep -E "(mean_volume|max_volume)" > "$tmpfile"
local mean_volume=$(grep "mean_volume" "$tmpfile" | awk '{print $5}')
local max_volume=$(grep "max_volume" "$tmpfile" | awk '{print $5}')
# Clipping detection
local clipping=$(ffmpeg -i "$file" -af "astats=metadata=1:reset=1" \
-f null /dev/null 2>&1 | grep -c "clipping")
echo "mean_volume=$mean_volume"
echo "max_volume=$max_volume"
echo "clipping_samples=$clipping"
rm "$tmpfile"
# Score based on analysis
if [[ $clipping -gt 100 ]]; then
echo "WARNING: Significant clipping detected ($clipping samples)"
return 2 # Poor quality due to clipping
elif (( $(echo "$mean_volume < -30" | bc -l) )); then
echo "WARNING: Very quiet audio (mean volume $mean_volume dB)"
return 4 # Acceptable but quiet
else
return 8 # Good Related in media-curator
Archive Acquisition
IncludedPatterns for acquiring content from Internet Archive and archival sources
media-curator
YouTube Acquisition
Includedyt-dlp patterns for acquiring content from YouTube and video platforms
media-curator
Integrity Verification
IncludedSHA-256 checksum manifest generation, self-verification, and PREMIS fixity patterns
media-curator
Cover Art Embedding
IncludedPatterns for finding, processing, and embedding cover artwork into media files
media-curator
Metadata Tagging
Includedopustags and ffmpeg patterns for applying metadata to audio and video files
media-curator
Transcribe Media
IncludedProduce timestamped transcript sidecars for acquired audio/video with hashes, source metadata, speaker labels when available, and explicit degraded plans when STT tooling is missing
media-curator