🎬 E2py

June 5, 2026 · View on GitHub

E2py — Analyseur de risques Ă©pileptiques pour vidĂ©os Outil open-source basĂ© sur les normes WCAG 2.3 / ITU-R BT.1702 / Harding PSE


🌐 Langue / Language


đŸ‡«đŸ‡· Version française

Table des matiĂšres

  1. À propos
  2. Normes appliquées
  3. RÚgles de détection
  4. Prérequis systÚme
  5. Installation
  6. Lancement
  7. Utilisation pas Ă  pas
  8. Comprendre les résultats
  9. Format du rapport JSON
  10. Compiler un exécutable
  11. Limites et avertissements
  12. FAQ

1. À propos

E2py est une application de bureau GTK4 qui analyse une vidéo frame par frame pour détecter les séquences susceptibles de provoquer des crises d'épilepsie photosensible chez des personnes à risque.

Elle détecte :

  • Les flashs lumineux dĂ©passant la frĂ©quence critique de 3 Hz
  • Les transitions vers du rouge saturĂ© Ă  fort contraste
  • Les zones clignotantes couvrant ≄ 25 % de l'image

L'interface est disponible en français et en anglais, commutable en temps réel.

⚠ Cet outil est indicatif. Pour une certification officielle (diffusion tĂ©lĂ©visĂ©e, cinĂ©ma, publicitĂ©), utilisez le Harding PSE Analyser accrĂ©ditĂ© : hardingfpa.tv


2. Normes appliquées

NormeDescriptionLien
WCAG 2.1 SC 2.3.1CritĂšre "Trois flashs ou sous le seuil"w3.org
ITU-R BT.1702Réduction des crises photosensibles (broadcast)itu.int
Harding PSE CriteriaStandard industrie (BBC, ITV, Ofcom) — seuil rouge rĂ©duit de moitiĂ©hardingfpa.tv

3. RÚgles de détection

RĂšgle 1 — Flash gĂ©nĂ©ral (WCAG 2.3.1 + ITU-R BT.1702)

  • Un flash = transition dark→light ou light→dark avec une variation de luminance relative ≄ 10 %
  • La luminance est calculĂ©e en espace sRGB linĂ©arisĂ© : L = 0.2126·R + 0.7152·G + 0.0722·B
  • > 3 flashs par seconde sur une fenĂȘtre glissante d'1 seconde = RISQUE
  • La zone clignotante doit couvrir ≄ 25 % de l'image pour ĂȘtre prise en compte

RĂšgle 2 — Flash rouge saturĂ© (Harding)

  • DĂ©tection en espace HSV : teinte H ∈ [0°–10°] ou [160°–180°], saturation S ≄ 100/255, valeur V ≄ 100/255
  • Une transition vers du rouge couvrant ≄ 25 % de l'image = RISQUE ACCRU
  • Le rouge est considĂ©rĂ© deux fois plus dangereux que les autres couleurs selon le standard Harding

RĂšgle 3 — FenĂȘtre temporelle

  • Comptage sur une fenĂȘtre glissante stricte d'1 seconde, purgĂ©e frame par frame
  • Conforme aux spĂ©cifications Harding et WCAG

4. Prérequis systÚme

Linux (Ubuntu 22.04+ / Debian 12+ / Fedora 38+)

# Ubuntu / Debian
sudo apt install python3 python3-pip python3-gi python3-gi-cairo  gir1.2-gtk-4.0 gir1.2-adw-1

# Fedora
sudo dnf install python3 python3-pip python3-gobject gtk4 libadwaita

Windows

GTK4 n'est pas natif sous Windows. Installer MSYS2 (msys2.org), puis dans le terminal MSYS2 :

pacman -S mingw-w64-x86_64-python mingw-w64-x86_64-python-pip mingw-w64-x86_64-python-gobject mingw-w64-x86_64-gtk4 mingw-w64-x86_64-libadwaita  mingw-w64-x86_64-opencv mingw-w64-x86_64-python-numpy

Dépendances Python (auto-installées)

Les packages Python suivants sont installés automatiquement au premier lancement si absents :

PackageVersion minimaleRĂŽle
opencv-python4.xDécodage vidéo, traitement HSV
numpy1.21+Calculs matriciels (luminance)

5. Installation

Aucune installation requise. Il suffit de télécharger le fichier :

e2py.py

Et de le lancer directement (voir section suivante).


6. Lancement

python3 e2py.py

Au premier lancement, si opencv-python ou numpy sont absents, le script les installe automatiquement via pip. Un message s'affiche dans le terminal :

[auto-install] Packages manquants : opencv-python
[auto-install] ✅  opencv-python installĂ©.

Si l'installation automatique échoue (environnement Python géré par le systÚme) :

pip3 install opencv-python numpy --break-system-packages

7. Utilisation pas Ă  pas

Étape 1 — SĂ©lectionner la vidĂ©o

Cliquez sur "Parcourir" ou sur l'icĂŽne 📂 dans la barre de titre pour ouvrir le sĂ©lecteur de fichiers.

Formats supportés : MP4, MKV, AVI, MOV, WEBM, FLV, WMV, TS, M4V

Le nom du fichier et son chemin s'affichent dans la zone de sélection.

Étape 2 — Choisir la langue (optionnel)

Utilisez les boutons đŸ‡«đŸ‡· FR / 🇬🇧 EN en haut Ă  droite pour basculer la langue de l'interface.

Étape 3 — Lancer l'analyse

Cliquez sur le bouton "Lancer l'analyse" (bleu).

La barre de progression affiche l'avancement en temps réel :

Frame 1500/3600 — 41%

Pour interrompre Ă  tout moment, cliquez sur "Annuler" (rouge).

Étape 4 — Lire les rĂ©sultats

Une fois l'analyse terminée, trois zones s'affichent :

  • BanniĂšre colorĂ©e : rĂ©sultat global (vert / orange / rouge)
  • Informations vidĂ©o : durĂ©e, FPS, frames, frĂ©quence max
  • Liste des Ă©vĂ©nements : timestamp prĂ©cis de chaque sĂ©quence problĂ©matique

Étape 5 — Exporter le rapport (optionnel)

Cliquez sur l'icĂŽne đŸ’Ÿ dans la barre de titre pour sauvegarder un rapport JSON complet.


8. Comprendre les résultats

Niveaux de risque

RésultatCouleurSignification
✅ PASSVertAucun flash problĂ©matique. Conforme WCAG 2.3 / Harding
⚠ WARNINGOrangeFrĂ©quence proche du seuil (> 2,4 Hz). VĂ©rification manuelle conseillĂ©e
❌ FAILRougeSĂ©quences dangereuses dĂ©tectĂ©es. Modification de la vidĂ©o recommandĂ©e

Informations affichées

ChampDescription
DuréeDurée totale de la vidéo en secondes
FPSNombre d'images par seconde
Frames totalesNombre total de frames analysées
Fréq. flash maximaleFréquence de flash la plus élevée observée (Hz). En rouge si > 3 Hz

Liste des flashs généraux

Chaque ligne correspond à une séquence dépassant 3 flashs/seconde :

⏱  12.34 s   —   4 flashs/seconde
⏱  45.10 s   —   5 flashs/seconde

Liste des flashs rouges

Chaque ligne correspond Ă  une apparition soudaine de rouge saturĂ© sur ≄ 25 % de l'image :

⏱  8.20 s   —   Rouge saturĂ© ≄ 25 % de l'image

Le rouge est traité séparément car il est deux fois plus dangereux selon le critÚre Harding.


9. Format du rapport JSON

Le rapport exporté contient :

{
  "risk_level": "FAIL",
  "fps": 25.0,
  "total_frames": 3750,
  "duration_s": 150.0,
  "max_flash_freq": 5.0,
  "flash_events": [
    {
      "time_s": 12.34,
      "freq_hz": 4,
      "delta_luma": 0.1842
    }
  ],
  "red_flash_events": [8.2, 34.56]
}
ChampTypeDescription
risk_levelstring"PASS", "WARNING" ou "FAIL"
fpsfloatFPS de la vidéo source
total_framesintNombre de frames analysées
duration_sfloatDurée en secondes
max_flash_freqfloatFréquence de flash maximale observée (Hz)
flash_eventsarrayListe des séquences dépassant 3 Hz
flash_events[].time_sfloatTimestamp en secondes
flash_events[].freq_hzintFréquence en flashs/seconde à ce moment
flash_events[].delta_lumafloatVariation de luminance relative déclenchante
red_flash_eventsarrayTimestamps des flashs rouges (secondes)

10. Compiler un exécutable

Linux — PyInstaller

pip install pyinstaller --break-system-packages
pyinstaller --onefile --name "E2py" e2py.py
# Résultat : dist/E2py

La machine cible doit avoir GTK4 installé : sudo apt install libgtk-4-1 libadwaita-1-0

Windows — PyInstaller via MSYS2

Dans le terminal MSYS2 :

pip install pyinstaller
pyinstaller --onefile --windowed --name "E2py" e2py.py
# Résultat : dist/E2py.exe

11. Limites et avertissements

  • Cet outil est indicatif, pas certifiĂ©. Il ne remplace pas le Harding PSE Analyser officiel.
  • La dĂ©tection repose sur la luminance moyenne de la frame entiĂšre. Les flashs localisĂ©s sur une petite zone (< 25 % de l'Ă©cran) ne sont pas signalĂ©s, conformĂ©ment Ă  WCAG 2.3.1.
  • Les vidĂ©os Ă  trĂšs bas FPS (< 10 fps) peuvent produire des rĂ©sultats moins prĂ©cis.
  • Les codecs rares ou fichiers corrompus peuvent Ă©chouer Ă  l'ouverture.
  • Pour une certification officielle (diffusion TV, plateformes, cinĂ©ma) : hardingfpa.tv

12. FAQ

QuestionRéponse
Ça marche pas, c’est normal ?Oui. C’est probablement la faute à ton PC. Ou à toi. Ou aux deux.
Pourquoi c’est lent ?Parce que ta vidĂ©o est en 4K, ou que ton CPU a 10 ans. Ou les deux.
Je peux vendre ce code ?Bien sûr ! Mais si tu deviens riche, invite-moi un café. (Ou pas.)
C’est sĂ»r Ă  100% ?Non. Rien ne l’est. MĂȘme pas la mort. (DĂ©solĂ© pour le spoil.)
Je peux l’utiliser pour pirater ?Techniquement oui, mais zeima te regarde avec dĂ©ception. (Et le FBI aussi.)
Je peux modifier le code ?DO WHAT THE FUCK YOU WANT TO. (Mais assume les conséquences.)
C’est compatible Mac ?Peut-ĂȘtre. Essaye et dis-moi. (Ou pas.)
Pourquoi ce nom, "E2py" ?Parce que "EpilepsyDetector3000" était déjà pris. (Et trop long à taper.)
Je peux en faire un chapeau ?Oui. Mais envoye une photo. (Pour la science.)


🇬🇧 English version

Table of contents

  1. About
  2. Standards applied
  3. Detection rules
  4. System requirements
  5. Installation
  6. Running the app
  7. Step-by-step usage
  8. Understanding results
  9. JSON report format
  10. Building an executable
  11. Limitations and disclaimer
  12. Q/A

1. About

E2py is a GTK4 desktop application that analyses a video frame by frame to detect sequences likely to trigger photosensitive epileptic seizures.

It detects:

  • Luminance flashes exceeding the critical frequency of 3 Hz
  • Transitions to saturated red at high contrast
  • Flashing areas covering ≄ 25 % of the image

The interface supports French and English, switchable at any time.

⚠ This tool is indicative. For official certification (broadcast TV, cinema, advertising), use the accredited Harding PSE Analyser: hardingfpa.tv


2. Standards applied

StandardDescriptionLink
WCAG 2.1 SC 2.3.1"Three Flashes or Below Threshold" criterionw3.org
ITU-R BT.1702Guidance for reduction of photosensitive epileptic seizuresitu.int
Harding PSE CriteriaIndustry standard (BBC, ITV, Ofcom) — red threshold halvedhardingfpa.tv

3. Detection rules

Rule 1 — General flash (WCAG 2.3.1 + ITU-R BT.1702)

  • A flash = dark→light or light→dark transition with relative luminance change ≄ 10 %
  • Luminance computed in linearised sRGB: L = 0.2126·R + 0.7152·G + 0.0722·B
  • > 3 flashes per second over a rolling 1-second window = RISK
  • The flashing area must cover ≄ 25 % of the image to be counted

Rule 2 — Saturated red flash (Harding)

  • Detection in HSV space: hue H ∈ [0°–10°] or [160°–180°], saturation S ≄ 100/255, value V ≄ 100/255
  • A transition to red covering ≄ 25 % of the frame = HIGH RISK
  • Red is considered twice as dangerous as other colours under the Harding standard

Rule 3 — Time window

  • Counting uses a strict rolling 1-second window, purged frame by frame
  • Fully compliant with Harding and WCAG specifications

4. System requirements

Linux (Ubuntu 22.04+ / Debian 12+ / Fedora 38+)

# Ubuntu / Debian
sudo apt install python3 python3-pip python3-gi python3-gi-cairo gir1.2-gtk-4.0 gir1.2-adw-1

# Fedora
sudo dnf install python3 python3-pip python3-gobject gtk4 libadwaita

Windows

GTK4 is not native on Windows. Install MSYS2 (msys2.org), then in the MSYS2 terminal:

pacman -S mingw-w64-x86_64-python  mingw-w64-x86_64-python-pip  mingw-w64-x86_64-python-gobject mingw-w64-x86_64-gtk4 mingw-w64-x86_64-libadwaita  mingw-w64-x86_64-opencv  mingw-w64-x86_64-python-numpy

Python dependencies (auto-installed)

The following Python packages are installed automatically on first launch if missing:

PackageMin versionRole
opencv-python4.xVideo decoding, HSV processing
numpy1.21+Matrix calculations (luminance)

5. Installation

No installation needed. Just download the single file:

e2py.py

Then run it directly (see next section).


6. Running the app

python3 e2py.py

On first launch, if opencv-python or numpy are missing, the script installs them automatically via pip. A message is shown in the terminal:

[auto-install] Missing packages: opencv-python
[auto-install] ✅  opencv-python installed.

If automatic installation fails (system-managed Python environment):

pip3 install opencv-python numpy --break-system-packages

7. Step-by-step usage

Step 1 — Select the video

Click "Browse" or the 📂 icon in the title bar to open the file picker.

Supported formats: MP4, MKV, AVI, MOV, WEBM, FLV, WMV, TS, M4V

The filename and path appear in the selection area.

Step 2 — Choose language (optional)

Use the đŸ‡«đŸ‡· FR / 🇬🇧 EN buttons in the top-right corner to switch the interface language.

Step 3 — Start the analysis

Click the "Start analysis" button (blue).

The progress bar updates in real time:

Frame 1500/3600 — 41%

To stop at any time, click "Cancel" (red).

Step 4 — Read the results

Once analysis is complete, three sections appear:

  • Coloured banner: overall result (green / orange / red)
  • Video information: duration, FPS, frames, max frequency
  • Event list: precise timestamp of each problematic sequence

Step 5 — Export the report (optional)

Click the đŸ’Ÿ icon in the title bar to save a complete JSON report.


8. Understanding results

Risk levels

ResultColourMeaning
✅ PASSGreenNo problematic flashes. Compliant with WCAG 2.3 / Harding
⚠ WARNINGOrangeFrequency near threshold (> 2.4 Hz). Manual review recommended
❌ FAILRedDangerous sequences detected. Video modification recommended

Displayed information

FieldDescription
DurationTotal video duration in seconds
FPSFrames per second
Total framesTotal number of frames analysed
Max flash frequencyHighest observed flash frequency (Hz). Shown in red if > 3 Hz

General flash list

Each row represents a sequence exceeding 3 flashes/second:

⏱  12.34 s   —   4 flashes/second
⏱  45.10 s   —   5 flashes/second

Red flash list

Each row represents a sudden appearance of saturated red covering ≄ 25 % of the frame:

⏱  8.20 s   —   Saturated red ≄ 25 % of frame

Red is handled separately because it is twice as dangerous under the Harding criterion.


9. JSON report format

The exported report contains:

{
  "risk_level": "FAIL",
  "fps": 25.0,
  "total_frames": 3750,
  "duration_s": 150.0,
  "max_flash_freq": 5.0,
  "flash_events": [
    {
      "time_s": 12.34,
      "freq_hz": 4,
      "delta_luma": 0.1842
    }
  ],
  "red_flash_events": [8.2, 34.56]
}
FieldTypeDescription
risk_levelstring"PASS", "WARNING" or "FAIL"
fpsfloatSource video FPS
total_framesintNumber of frames analysed
duration_sfloatDuration in seconds
max_flash_freqfloatMaximum observed flash frequency (Hz)
flash_eventsarrayList of sequences exceeding 3 Hz
flash_events[].time_sfloatTimestamp in seconds
flash_events[].freq_hzintFlash frequency at that moment
flash_events[].delta_lumafloatTriggering relative luminance variation
red_flash_eventsarrayRed flash timestamps (seconds)

10. Building an executable

Linux — PyInstaller

pip install pyinstaller --break-system-packages
pyinstaller --onefile --name "E2py" e2py.py
# Output: dist/E2py

Target machine must have GTK4: sudo apt install libgtk-4-1 libadwaita-1-0

Windows — PyInstaller via MSYS2

In the MSYS2 terminal:

pip install pyinstaller
pyinstaller --onefile --windowed --name "E2py" e2py.py
# Output: dist/E2py.exe

11. Limitations and disclaimer

  • This tool is indicative, not certified. It does not replace the official Harding PSE Analyser.
  • Detection is based on the average luminance of the full frame. Flashes localised to a small area (< 25 % of screen) are not flagged, in accordance with WCAG 2.3.1.
  • Videos with very low FPS (< 10 fps) may produce less accurate results.
  • Unusual codecs or corrupted files may fail to open.
  • For official certification (broadcast TV, streaming platforms, cinema): hardingfpa.tv

12.Q/A

QuestionAnswer
Is it not working? Is that normal?Yes. It’s probably your PC’s fault. Or yours. Or both.
Why is it so slow?Because your video is in 4K, or your CPU is 10 years old. Or both.
Can I sell this code?Of course! But if you get rich, buy me a coffee. (Or don’t.)
Is it 100% reliable?No. Nothing is. Not even death. (Sorry for the spoiler.)
Can I use it for hacking?Technically yes, but zeima is judging you. (And so is the FBI.)
Can I modify the code?DO WHAT THE FUCK YOU WANT TO. (But own the consequences.)
Is it Mac-compatible?Maybe. Try it and let me know. (Or don’t.)
Why the name "E2py"?Because "EpilepsyDetector3000" was already taken. (And too long to type.)
Can I turn it into a hat?Yes. But send a photo. (For science.)
What’s the answer to everything?42, but I’m not Mistral, let alone Claude.

Licence / License

Ce projet est distribué sous licence WTFPL. This project is distributed under the WTFPL licence. Read the license thank you


RĂ©fĂ©rences / References : WCAG 2.1 — https://www.w3.org/TR/WCAG21/#three-flashes-or-below-threshold ITU-R BT.1702 — https://www.itu.int/rec/R-REC-BT.1702/en Harding PSE Analyser — https://www.hardingfpa.tv