======Le Data Moshing====== ===== Le Data Moshing Qu'est-ce que c'est ? ===== C'est la déstructuration d'une vidéo en modifiant les repères temporels dans les paramètres d'encodage. En clair, quand une vidéo est compressée en divx, il y a des images clefs disons toutes les secondes, ces images clefs (keyframe) contiennent toutes les infos (ou tous les pixels) pour reconstituer l'intégralité de l'image alors que les autres images (qui ne sont pas "keyframe") ne contiennent qu'une partie de l'info (des pixels), c'est en partie comme cela qu'on "compresse" l'image, cad en ne stockant pas toutes les images intégralement dans le fichier vidéo. {{ media_12:skattak00100019.jpg?600 |Skattak00100019.jpg}} ==== Exemples de réalisations ==== **InfiniteGlitch - Ben Baker-Smith** * voir le projet (stream offline now) : http://bitsynthesis.com/infiniteglitch/ **Rosa Menkam** * artiste ayant exploré l'esthétique glitch : http://rosa-menkman.blogspot.com/ **Accouchement Sonique - Jérome Blanquet** {{ youtube>OIl_rAKJGF4 }} **Click on it - andrew benson** {{ vimeo>26698952 }} **Chairlift, "Evident Utensil"** {{ vimeo>3139412 }} **Datamosh - Yung Jake** {{ youtube>nS7QvOX8LVk }} **Jacques Perconte - Impressions / teaser n°2** {{ vimeo>33211389 }} **Yaoguai** {{ vimeo>74405144 }} **SamsaraGlithced** {{ vimeo>139955411 }} **Julian Zigerli X (LA)HORDE** {{ vimeo>161165678 }} **Pouff - Grocery Trip** {{ youtube>DgPaCWJL7XI }} ===== Tutoriel ===== ==== Ressources, tutoriels ==== * Un bon tutoriel vidéo basé sur ffmpegX et Avidemux (en 3 parties) {{youtube>tYytVzbPky8}}{{youtube>uUkEIVixcbo}}{{youtube>tYf3EWMuHH0}} * L'article de référence : http://createdigitalmotion.com/2009/03/how-to-datamosh-with-free-video-tools-datamosh-is-the-wrong-word-david-oreilly-is-also-wrong/ * Un How To sous ubuntu : http://ubuntuforums.org/showthread.php?t=1322894 * Une discussion sur flickr : http://www.flickr.com/groups/glitches/discuss/72157621117514263/ === ffmpeg === ffmpeg -i input_video.mov -g 250 -sc_threshold 1000000000 -vcodec libxvid output_video.mp4 === script Avidemux === Ben Baker-Smith dit: To clarify some of the Avidemux scripting stuff... First of all, a script for Avidemux can really just be an edited project file. The code is written in javascript. To check the frame type you must have already laid the whole video down in the timeline (or rather the virtual timeline when doing this from the CLI). Then use one of the following functions (depending on your version) to identify the frame type: app.video.frameType(x); app.video.getFrameType(x); where x is the frame number you want to check. A result of 16 means it is a keyframe. Because you can only check the frame types of frames already added to the timeline, you will have to lay down the entire clip, check each frame for its type and log the results in an array. Then clear the timeline again with app.clearSegments(); and start laying it down fresh frame by frame, checking against the array to be sure you don't add the keyframes. === Perl === Un script perl fort amusant sous linux AutodataMosh : https://github.com/grampajoe/Autodatamosh Le résultat en image : {{vimeo>22365100}} ==== Exemple pratique de datamoshing avec un script perl ==== Un script perl fort amusant AutodataMosh : https://github.com/grampajoe/Autodatamosh === Préparation de la vidéo === * export de la video de base en xvid avec un iframe toutes les 100 images (-g 100) * voir https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping pour parametres et https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/AVCodecContext_AVOptions ffmpeg -i SOURCE -f avi -vcodec xvid -b 20000k -g 100 -sc_threshold 1000000000 -an -acodec copy DESTINATION ou selon version de ffmpeg ffmpeg -i SOURCE -f avi -vcodec libxvid -b 20000k -g 100 -sc_threshold 1000000000 -an -acodec copy DESTINATION paramètre pour régler le pb "libxvid Invalid pixel aspect ratio 0/1" -aspect 16:9  ou codec audio -acodec libvorbis -ab 192k -ar 44100 -ac 2 ou provenant d'une camera HD 1440x1080 ffmpeg -deinterlace -y -r 25 -s 1440x1080 -i SOURCE.MTS -f avi -vcodec libxvid -b 50000k -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec libvorbis -ab 192k -ar 44100 -ac 2 DESTINATION.avi ffmpeg -i SOURCE.avi -vcodec libxvid -qscale 1 -g 100 -me_method epzs -bf 0 -mbd 0 -aspect 16:9 -acodec copy DESTINATION.avi compression proposée par David Olivari ffmpeg -i in.mov -vcodec libxvid -qscale 1 -g 128 -me_method epzs -bf 0 -mbd 0 -aspect 16:9 epzs_128_out.avi http://bazaar.launchpad.net/~david-olivari/datamosher/trunk/view/head:/readme extraire l'audio ffmpeg -y -i 00076.MTS -ar 44100 -vn -acodec pcm_s16le -ac 2 00076.wav mélanger audio et vidéo ffmpeg -y -i 00076.wav -i SOUIRCE.avi -vcodec copy -acodec copy DESTINATIONwithSound.avi Il existe plusieurs paramètres pour préparer la vidéo en xvid et placer les images clefs là où le script de datamoshing va ensuite les enlever Ici on met une image clef quasi toutes les 2 images, ça va faire des plans très rapprochés pour systématiser le glissement de plans ensuite ffmpeg -threads 12 -i videnentre.mp4 -vcodec libxvid -b 50000k -g 2 -sc_threshold 1000000000 videmoshed.xvid.avi; Voir plus bas pour d'autes paramétrages === Data Moshing === autodatamoshing 89 % de chance de mosher, si mosh répétition d'images P aléatoire entre 50 et 100 perl autodatamosh.pl -i SOURCE_ENCODEE -dprob 0.89 -dmin 50 -dmax 100 -o DESTINATION-MOSH -dprob 1 -dmin 0 -dmax 0 pour n'enlever que les images I et mélanger les plans sans répéter les images P === Recompression === Recompression pour rendre la video lisible par les lecteurs video habituels : ffmpeg -i SOURCE-MOSHED -r 25 -vcodec mjpeg -b 20000k -g 25 -an -acodec copy DESTINATION-MOSH-LISIBLE.avi Recompression pour rendre les videos uploadables sur les plateformes de partage (vimeo, ...) ffmpeg -i MaVideoMOSH.avi -acodec copy -ab 320k -b 2000k -vc h264 -g 25 -sameq MaVideoUploadable.mp4 option : -t 30 pour ne compresser que les 30 premières secondes, -ss 15 pour décaler le début du fichier à 15 secondes du début Recompression mpeg4 HD ffmpeg -i SOURCE.avi -s 1280x720 -acodec copy -vcodec mpeg4 -b 6000k -g 15 -f avi DESTINATION.avi Recompression Vimeo depuis HD (ffmpeg moderne) avec preset hq ffmpeg -i SOURCE.avi -vcodec libx264 -acodec libfaac -vpre hq -s hd720 -b 5000k -ab 320k DESTINATION.mp4 Recompression H264 .mp4 ffmpeg -threads 2  -y -i "/media/hd/source.avi" -s 1280x720 -crf 25.0 -vcodec libx264 -acodec libvo_aacenc -ar 48000 -ab 160k -coder 1 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -qcomp 0.6 -qmin 0 -qmax 69 -qdiff 4  -b 6000k "/media/hd/destination.mp4" 2ème essai video source 1440x1080 .mts AVCHD recompression pour vimeo 1280x720 ffmpeg -i 00028.MTS -deinterlace -s 1280x720 -pix_fmt yuv420p -vcodec mpeg4 -sameq -b 6000k -f mp4 -acodec copy MiasOuEst-ce_28.mp4 Exemple Video HD depuis Blue-ray ffmpeg -i Sam.1080p.BluRay.x264-GECKOS.mkv -f avi -vcodec libxvid -b 50000k -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -acodec libvorbis -ab 328k -ar 44100 -ac 2 /DESTINATION/Sam-Xvid-ogg.avi perl autodatamosh.pl -i /DESTINATION/Sam-Xvid-ogg.avi -dprob 1 -dmin 0 -dmax 0 -o /DESTINATION/Sam-Xvid-oggGlitech-1-0-0.avi === Un exemple de datamoshing où l'on conserve l'audio, le tout recompressé en mp4 === Au final, pour conserver l'audio, il doit falloir exporter l'audio du xvid moshé, exporter le xvid moshé en mjpeg et muxer les 2 **Compression initiale en xvid** (différentes stratégies possibles, cf plus haut) ffmpeg -threads 12 -i Unborn0x9-Marseille-2020-11-13.mp4 -f avi -vcodec libxvid -b 20000k -g 25 -sc_threshold 1000000000 -acodec libvorbis -ab 192k -ar 44100 -ac 2 Unborn0x9-Marseille-2020-11-13-25audio.xvid **Datamoshing** perl autodatamosh.pl -i Unborn0x9-Marseille-2020-11-13.xvid -dprob 1 -dmin 20 -dmax 80 -o Unborn0x9-Marseille-2020-11-13.moshed128.xvid **Compression mjpeg** ffmpeg -threads 12 -i Unborn0x9-Marseille-2020-11-13.moshed128-25audio.xvid -r 25 -vcodec mjpeg -b 20000k -g 25 -an -acodec copy Unborn0x9-Marseille-2020-11-13.moshed128-25audio.mov **Extraction audio** ffmpeg -y -i Unborn0x9-Marseille-2020-11-13.moshed128-25audio.xvid -ar 44100 -vn -acodec pcm_s16le -ac 2 Unborn0x9-Marseille-2020-11-13.moshed128-25audio.wav **On remix le tout en mp4 aac** ffmpeg -threads 12 -i Unborn0x9-Marseille-2020-11-13.moshed128-25audio.wav -i Unborn0x9-Marseille-2020-11-13.moshed128-25audio.mov -c:v libx264 -profile high -c:a aac -b:a 256k Unborn0x9-Marseille-2020-11-13.moshed128-25audio.mp4 **Si le résultat glitch au niveau temporel, on cut à 10 minutes** ffmpeg -threads 12 -to 9:59 -i Unborn0x9-Marseille-2020-11-13.moshed128-25audio.mp4 -c:v copy -c:a copy Unborn0x9-Marseille-2020-11-13.moshed128-25audio-10mn.mp4 Voir le résultat ; https://tube.futuretic.fr/videos/watch/c18d7c6a-6303-4f81-a20c-1df151cdb718 Pour ne recompresser qu'une partie de la vidéo : ffmepg -ss debutensecondes.millisecondes -i nomfich.avi .... -t dureeduboutaconserverensecondes.millisecondes nomfichrecomp.avi avec : * -ss : durée en secondes.millisecondes à partie de la quelle commencer la compression * -t : durée à partir du point d'entrée de la compression à compresser en secondes.millisecondes === DataMoshing traitement par lot - batch === #!/bin/bash for i in *.mp4; do name=`echo "${i%.*}"`; echo $name; ffmpeg -i "${i}" -vcodec libxvid -qscale 1 -g 128 -me_method epzs -bf 0 -mbd 0 -aspect 16:9 "${name}".xvid.avi; perl autodatamosh.pl -i "${name}".xvid.avi -dprob 1 -dmin 0 -dmax 0 -o "${name}".xvid.moshed.avi; ffmpeg -i "${name}".xvid.moshed.avi -c:v libx264 -profile high -c:a copy -strict experimental "${name}".moshed.mp4; done ===== Data Bending ===== * en utilisant le fuzzing ? http://caca.zoy.org/wiki/zzuf ===== Ressources complémentaires ===== ==== Data Moshing ==== * [[http://createdigitalmotion.com/2009/02/data-moshing-the-online-videos-my-god-its-full-of-glitch/|Data Moshing the Online Videos: My God, It’s Full of Glitch]] * [[http://nickbriz.com/glitchcodectutorial/|Glitch Codec Tuto : outil sur clef USB et vidéos de démo]] * Discussion sur le forum max/msp : http://www.cycling74.com/forums/topic.php?id=18580 * Data Mosh Live : http://createdigitalmotion.com/2009/03/liquidify-video-live-optical-flow-glsl-datamosh-technique/ * Shader en Max : http://www.cycling74.com/forums/topic.php?id=19283%C2%A0: le shader : http://pixlpa.com/blog/pushing-pixels * "If you export a video to sorenson with 0 keyframes you get this awesome effect" * Les codecs inter-frame, comment ça marche ? image I, B, P = GOP ? https://fr.wikipedia.org/wiki/Inter-trame * Glitch Codec tutorial http://nickbriz.com/glitchcodectutorial/https://vimeo.com/23653867 * Une autre ! http://rosa-menkman.blogspot.de/2009/02/how-to-datamoshing-create-compression.html * A voir quelques tutos sur [[http://datamoshing.com/|datamoshing.com]] ou encore [[https://mattrunks.com/fr/formations/divers/tuto-datamoshing-recreer-volontairement-des-erreurs-de-compression-video|ici]] * Un tutorial complet (en anglais) sur la théorie et l'utilisation du logiciel Avidemux pour le datamoshing : http://forum.glitchet.com/t/tutorial-make-video-glitch-art-how-to-datamosh-in-plain-english/36 {{vimeo>23653867}}\\ ==== Outils ==== * un datamosher développé par David Olivari pour le film "accouchement sonique" : http://bazaar.launchpad.net/~david-olivari/datamosher/trunk/view/head:/readme * Projet aviglitch en ruby http://ucnv.github.com/aviglitch/ * ressources sur ffmpeg en français : http://formation.mdesigner.fr/post/Encodage-avec-FFMPEG http://www.ordinoscope.net/index.php/Informatique/Softwares/FFmpeg/Recettes/Video * ffmpeg audio et video : http://howto-pages.org/ffmpeg/ * interface graphique GUI ffmpeg : http://doc.ubuntu-fr.org/hyper_video_converter * pour macos : http://www.ffmpegx.com * encodage x264 : http://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping * quelques lignes de commande type : http://lprod.org/wiki/doku.php/video:ffmpeg:usages * encoder en x264 http://doc.ubuntu-fr.org/encodage_dvd_mkv#methode_utilisant_ffmpeg * explications des paramètres du xvid http://helpful.knobs-dials.com/index.php/Notes_on_encoding_video#for%20divx/xvid * encoder avec mencoder : http://www.mplayerhq.hu/DOCS/HTML/en/encoding-guide.html * Un logiciel pour macos x GoldMosh http://jonesypop.com/goldmosh/ * Un plug-in pour quartz composer http://kriss.cx/tom/2012/10/08/datamosh.html * Un outil libre et ouvert, écrit en python, pour appliquer différentes techniques de datamoshing à un fichier vidéo : https://github.com/itsKaspar/tomato * Un outil en python très complet avec une interface graphique (payante) pour win https://github.com/Akascape/Datamosher-Pro == Datamoshing des traversées renardes == Script DataMoshing #!/bin/bash for i in /home/gedeon/Vidéos/BANDITS/*.mp4; do name=`echo "${i%.*}"`; echo $name; ffmpeg -i "${i}" -vcodec libxvid -b 50000k -g 250 -keyint_min 25 -sc_threshold 90 -i_qfactor 0.21 -b_strategy 1 "${name}".xvid.avi; # ffmpeg -i "${i}" -vcodec libxvid -qscale 1 -g 128 -me_method epzs -bf 0 -mbd 0 -aspect 16:9 "${name}".xvid.avi; perl autodatamosh.pl -i "${name}".xvid.avi -dprob 1 -dmin 30 -dmax 100 -o "${name}".xvid.moshed.avi; ffmpeg -i "${name}".xvid.moshed.avi -r 25 -vcodec mjpeg -b 20000k -g 25 -an -acodec copy "${name}".moshed10030100.mov; rm "${name}".xvid.avi; rm "${name}".xvid.moshed.avi; done Patchs Pure Data voir https://github.com/b01xy/montage_generatif-renarde Pour enregistrer le système de montage generatif issu de Pd : ffmpeg -thread_queue_size 512 -discard noref -f video4linux2 -i /dev/video0 -vcodec libx264 -profile:v high422 -preset fast -crf 18 -b-pyramid none -t 1800 /home/gedeon/Vidéos/MontagGeneCICLIC-3000_40-VIDEO$(date +%Y-%m-%d-%H:%M).mp4 Encodage H264 pour lire les vidéos sur les Pi par omxplayer ffmpeg -i 25FPSBEAUCLIBANDITS2.ogv -vcodec libx264 -preset slow -profile:v high -level 30 -maxrate 50000000 -bufsize 10000000 -b 15M -f mp4 -threads 2 25FPSBEAUCLIBANDITS02.mp4 {{ vimeo>240936109 }} {{tag>bj video art_interactif}}