Bash: Comment réparer gratuitement un fichier vidéo corrompu « moov atom not found », « MOV: missing header », « Invalid data found when processing input »

Publié par Dr sc Olivier Dufour le

Bash: Comment réparer gratuitement un fichier vidéo corrompu « moov atom not found », « MOV: missing header », « Invalid data found when processing input »

Ubuntu 20.04.5 LTS.
output.mp4 : vidéo corrompue à réparer.
VID_20220831_154011.mp4 : vidéo bonne, enregistrée avec le même appareil que output.mp4.

Date de l’opération: 19 12 2022

Vidéo script bash concaténation rushs mp4:
https://youtu.be/ESoB0iS9kC8

1)
Solution rapide:

https://unix.stackexchange.com/questions/493897/how-to-recover-a-broken-mp4-file-moov-atom-not-found

sudo apt install docker
sudo apt install git
cd DossierQuiContientLaVidéoCorrompue
git clone https://github.com/ponchio/untrunc
cd untrunc
sudo apt install docker.io
sudo docker build -t untrunc .
pas mal de messages rouges, assez long mais terminé

docker run -v /path/to/files/:/files untrunc /files/working_video /files/broken_video

cp output.mp4 /tmp/
cp VID_20220831_154011.mp4 /tmp/

sudo docker run -v /tmp:/tmp untrunc /tmp/VID_20220831_154011.mp4 /tmp/output.mp4

Réponse du terminal:
Reading: /tmp/VID_20220831_154011.mp4
Repair: /tmp/output.mp4
Mdat not found!
Processed: 1%
[…]
Processed: 15%
Backtracked enough!
Found 52747 packets.
Found 20501 chunks for avc1
Found 32246 chunks for mp4a
Saving to: /tmp/output_fixed.mp4

Commande utile:
docker ps

2 vidéos de cocadmin qui m’ont (beaucoup aidées) pour débuter:
https://youtu.be/SXB6KJ4u5vg
https://youtu.be/cWkmqZPWwiw

2)
Autres pistes de solutions à tester:

chercher une version gratuite du logiciel qui a essayé de te faire payer
https://florent.poinsaut.fr/2017/12/19/impossible-de-lire-une-video-moov-atom-not-found/

3)
Autres pistes de solutions que j’ai testées, en vain:

ffprobe: j’ai pas pu tester.

https://www.rescuedigitalmedia.com/video-repair
Réussi à le faire fonctionner avec wine.
Le logiciel mouline, te donne l’aperçu du résultat de la vidéo réparée.
Mais essaye de te rançonner au passage.
Faut acheter 50€ la clé licence produit pour obtenir le résultat du calcul.

tester plutôt avec une autre vidéo d’exemple sain, qui soit une concaténation elle aussi, de plusieurs rush mp4:
Non, résultat pire. Le fichier réparé est bon mais encore plus court qu’avec VID_20220831_154011.mp4

sudo apt install mencoder
https://forum.ubuntu-fr.org/viewtopic.php?id=107732
mencoder -ovc copy -oac copy -forceidx output.mp4 -o output2.mp4

Réponse du terminal:
moov atom not found
MOV: missing header (moov/cmov) chunk! Maybe broken file…

mencoder -ovc copy -oac pcm -forceidx output.mp4 -o output2.mp4
ça marche mais résultat inintéressant

https://doc.ubuntu-fr.org/mencoder
mencoder -ovc copy -oac copy -o destination.mp4 source1.mp4 source2.mp4

mencoder -ovc copy -oac copy -o output2.mp4 output.mp4
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f666f27d600]moov atom not found
MOV: missing header (moov/cmov) chunk! Maybe broken file…
Exiting…

mencoder -ovc copy -oac pcm -o output2.mp4 output.mp4
ça marche mais résultat médiocre

mencoder -ovc copy -oac copy -fafmttag -o output2.mp4 output.mp4
non

ffmpeg -i output.mp4 -c copy output2.mp4
moov atom not found
output.mp4: Invalid data found when processing input

ffmpeg -i output.mp4 -movflags faststart -c copy output2.mp4

Réponse du terminal:
moov atom not found
output.mp4: Invalid data found when processing input

sudo add-apt-repository ppa:xtradeb/apps
sudo apt update
sudo apt install avidemux-qt
échec de avidemux

Extraire le son stéro de A.webm mais en mono:
ffmpeg -i output.mp4 -ac 1 output2.wav

Réponse du terminal:
moov atom not found
output.mp4: Invalid data found when processing input

Prendre que le flux vidéo, sans bande son
ffmpeg -i output.mp4 -c copy -an output2.mp4
Réponse du terminal:
moov atom not found
output.mp4: Invalid data found when processing input

https://eu.restore.media/task/details/b91b371c-087f-ed11-a14d-50ebf6250027
Camera: Hubsan H501SS
Sample: output.mp4
Method: Lav/ffmpeg based H.264 software encoder (DJI Spark (old), DJI Mavic Air)
Detected video format: AVC video 3840×2160, High Profile, Level 5.1
Detected audio format: AAC audio, 48000 Hz, 2 ch, profile 2 (codec data 0x11 0x90)
Recovery streams: Video and audio
Total extracting ratio: 99.862% (Video: 97.147%; Audio: 2.715%)
Original size: 4.446 GB, Repaired size: 4.445 GB
Framerate: 29.81
Find missing data at the end of the file (useful if the file cuts off unexpectedly)
Duration of the repaired file: 01:23:50
Me réclame 40€
Pas envie de payer.

Tous les épisodes précédents sur les « Scripts bash, terminal Linux, ligne de commande »: https://www.youtube.com/playlist?list=PLR4Gh8rMNno028RWVamu9XShxrSnDfk-8

S’il vous plaît, si vous pouvez, faites un don pour soutenir ma démarche de partage de solutions: https://www.paypal.com/donate/?hosted_button_id=GEDDUR8FKNZQ8

F A C E B O O K https://www.facebook.com/Ubuntu-en-fran%C3%A7ais-107097925105073

T W I T T E R https://twitter.com/UbuntuFrancais

Olivier (Montpellier)