
Recherche avancée
Médias (1)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (103)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Participer à sa traduction
10 avril 2011Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
Actuellement MediaSPIP n’est disponible qu’en français et (...) -
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)
Sur d’autres sites (8489)
-
How could I add an overlay to a video based on mouse cursor coordinates ?
5 mars 2023, par DimaI am making a web app, where the user clicks through some images while talking about them and pointing things out with the cursor. The audio, timestamps of image changes, and mouse cursor coordinates and times are sent to a php script which uses ffmpeg to make a slideshow from the images and audio.


Then it runs another ffmpeg command to overlay a moving image representing the cursor hundreds of times to mimic the user's mouse movements.


Here is an example command that inserts the mouse overlay :


ffmpeg \
 -i ../tmp/6400d9c21a62d.mp4 \
 -i ../assets/mouse-circle.png \
 -filter_complex "[0:v][1:v]overlay=enable='between=(t,0.627,0.874)':x=777.648+(t-0.627)*0.000/0.247:y=937.572+(t-0.627)*0.000/0.247[a1]; \
 [a1][1:v]overlay=enable='between=(t,0.874,0.914)':x=777.648+(t-0.874)*0.000/0.040:y=937.572+(t-0.874)*-1.223/0.040[a2]; \
 [a2][1:v]overlay=enable='between=(t,0.914,0.936)':x=777.648+(t-0.914)*0.000/0.022:y=936.349+(t-0.914)*0.000/0.022[a3]; \
 [a3][1:v]overlay=enable='between=(t,0.936,0.945)':x=777.648+(t-0.936)*0.000/0.009:y=936.349+(t-0.936)*-1.223/0.009[a4]; \
 [a4][1:v]overlay=enable='between=(t,0.945,0.966)':x=777.648+(t-0.945)*0.000/0.021:y=935.127+(t-0.945)*-1.223/0.021[a5]; \
 [a5][1:v]overlay=enable='between=(t,0.966,0.976)':x=777.648+(t-0.966)*0.000/0.010:y=933.904+(t-0.966)*-1.223/0.010[a6]; \
 [a6][1:v]overlay=enable='between=(t,0.976,0.999)':x=777.648+(t-0.976)*0.000/0.023:y=932.682+(t-0.976)*0.000/0.023[a7]; \
 [a7][1:v]overlay=enable='between=(t,0.999,1.019)':x=777.648+(t-0.999)*1.227/0.020:y=932.682+(t-0.999)*-1.223/0.020[a8]; \
 [a8][1:v]overlay=enable='between=(t,1.019,1.039)':x=778.875+(t-1.019)*0.000/0.020:y=931.459+(t-1.019)*-1.223/0.020[a9]; \
 [a9][1:v]overlay=enable='between=(t,1.039,1.091)':x=778.875+(t-1.039)*0.000/0.052:y=930.236+(t-1.039)*0.000/0.052[a10]; \
 [a10][1:v]overlay=enable='between=(t,1.091,1.142)':x=778.875+(t-1.091)*0.000/0.051:y=930.236+(t-1.091)*-1.223/0.051[a11]; \
 [a11][1:v]overlay=enable='between=(t,1.142,1.152)':x=778.875+(t-1.142)*0.000/0.010:y=929.014+(t-1.142)*-1.223/0.010[a12]; \
 [a12][1:v]overlay=enable='between=(t,1.152,1.161)':x=778.875+(t-1.152)*0.000/0.009:y=927.791+(t-1.152)*-1.223/0.009[a13]; \
 [a13][1:v]overlay=enable='between=(t,1.161,1.173)':x=778.875+(t-1.161)*2.454/0.012:y=926.569+(t-1.161)*-3.668/0.012[a14]; \
 [a14][1:v]overlay=enable='between=(t,1.173,1.184)':x=781.329+(t-1.173)*0.000/0.011:y=922.901+(t-1.173)*-8.558/0.011[a15]; \
 [a15][1:v]overlay=enable='between=(t,1.184,1.193)':x=781.329+(t-1.184)*0.000/0.009:y=914.343+(t-1.184)*-4.890/0.009[a16]; \
 [a16][1:v]overlay=enable='between=(t,1.193,1.203)':x=781.329+(t-1.193)*0.000/0.010:y=909.452+(t-1.193)*-3.668/0.010[a17]; \
 [a17][1:v]overlay=enable='between=(t,1.203,1.213)':x=781.329+(t-1.203)*0.000/0.010:y=905.784+(t-1.203)*-8.558/0.010[a18]; \
 [a18][1:v]overlay=enable='between=(t,1.213,1.223)':x=781.329+(t-1.213)*0.000/0.010:y=897.226+(t-1.213)*-4.890/0.010[a19]; \
 [a19][1:v]overlay=enable='between=(t,1.223,1.234)':x=781.329+(t-1.223)*0.000/0.011:y=892.336+(t-1.223)*-3.668/0.011[a20]; \
 [a20][1:v]overlay=enable='between=(t,1.234,1.246)':x=781.329+(t-1.234)*0.000/0.012:y=888.668+(t-1.234)*-8.558/0.012[a21]; \
 [a21][1:v]overlay=enable='between=(t,1.246,1.256)':x=781.329+(t-1.246)*0.000/0.010:y=880.110+(t-1.246)*-3.668/0.010[a22]; \
 [a22][1:v]overlay=enable='between=(t,1.256,1.265)':x=781.329+(t-1.256)*0.000/0.009:y=876.442+(t-1.256)*-4.890/0.009[a23]; \
 [a23][1:v]overlay=enable='between=(t,1.265,1.282)':x=781.329+(t-1.265)*0.000/0.017:y=871.551+(t-1.265)*-8.558/0.017[a24]; \
 [a24][1:v]overlay=enable='between=(t,1.282,1.298)':x=781.329+(t-1.282)*1.227/0.016:y=862.993+(t-1.282)*-8.558/0.016[a25]; \
 [a25][1:v]overlay=enable='between=(t,1.298,1.316)':x=782.556+(t-1.298)*0.000/0.018:y=854.435+(t-1.298)*-8.558/0.018[a26]; \
 [a26][1:v]overlay=enable='between=(t,1.316,1.331)':x=782.556+(t-1.316)*2.454/0.015:y=845.877+(t-1.316)*-8.558/0.015[a27]; \
 [a27][1:v]overlay=enable='between=(t,1.331,1.349)':x=785.010+(t-1.331)*0.000/0.018:y=837.318+(t-1.331)*-3.668/0.018[a28]; \
 [a28][1:v]overlay=enable='between=(t,1.349,1.365)':x=785.010+(t-1.349)*2.454/0.016:y=833.651+(t-1.349)*-13.449/0.016[a29]; \
 [a29][1:v]overlay=enable='between=(t,1.365,1.382)':x=787.464+(t-1.365)*3.681/0.017:y=820.202+(t-1.365)*-13.449/0.017[a30]; \
 [a30][1:v]overlay=enable='between=(t,1.382,1.399)':x=791.145+(t-1.382)*0.000/0.017:y=806.753+(t-1.382)*-8.558/0.017[a31]; \
 [a31][1:v]overlay=enable='between=(t,1.399,1.415)':x=791.145+(t-1.399)*4.908/0.016:y=798.195+(t-1.399)*-13.449/0.016[a32]; \
 [a32][1:v]overlay=enable='between=(t,1.415,1.433)':x=796.053+(t-1.415)*2.454/0.018:y=784.746+(t-1.415)*-17.116/0.018[a33]; \
 [a33][1:v]overlay=enable='between=(t,1.433,1.449)':x=798.507+(t-1.433)*3.681/0.016:y=767.630+(t-1.433)*-8.558/0.016[a34]; \
 [a34][1:v]overlay=enable='between=(t,1.449,1.466)':x=802.188+(t-1.449)*6.135/0.017:y=759.072+(t-1.449)*-18.339/0.017[a35]; \
 [a35][1:v]overlay=enable='between=(t,1.466,1.482)':x=808.323+(t-1.466)*2.454/0.016:y=740.733+(t-1.466)*-8.558/0.016[a36]; \
 [a36][1:v]overlay=enable='between=(t,1.482,1.499)':x=810.777+(t-1.482)*6.135/0.017:y=732.174+(t-1.482)*-18.339/0.017[a37]; \
 [a37][1:v]overlay=enable='between=(t,1.499,1.516)':x=816.912+(t-1.499)*8.589/0.017:y=713.835+(t-1.499)*-14.671/0.017[a38]; \
 [a38][1:v]overlay=enable='between=(t,1.516,1.532)':x=825.501+(t-1.516)*3.681/0.016:y=699.164+(t-1.516)*-8.558/0.016[a39]; \
 [a39][1:v]overlay=enable='between=(t,1.532,1.549)':x=829.181+(t-1.532)*4.908/0.017:y=690.606+(t-1.532)*-13.449/0.017[a40]; \
 [a40][1:v]overlay=enable='between=(t,1.549,1.565)':x=834.089+(t-1.549)*8.589/0.016:y=677.157+(t-1.549)*-14.671/0.016[a41]; \
 [a41][1:v]overlay=enable='between=(t,1.565,1.583)':x=842.678+(t-1.565)*2.454/0.018:y=662.486+(t-1.565)*-8.558/0.018[a42]; \
 [a42][1:v]overlay=enable='between=(t,1.583,1.599)':x=845.132+(t-1.583)*8.589/0.016:y=653.928+(t-1.583)*-14.671/0.016[a43]; \
 [a43][1:v]overlay=enable='between=(t,1.599,1.616)':x=853.721+(t-1.599)*2.454/0.017:y=639.257+(t-1.599)*-4.890/0.017[a44]; \
 [a44][1:v]overlay=enable='between=(t,1.616,1.632)':x=856.175+(t-1.616)*9.816/0.016:y=634.366+(t-1.616)*-18.339/0.016[a45]; \
 [a45][1:v]overlay=enable='between=(t,1.632,1.649)':x=865.991+(t-1.632)*8.589/0.017:y=616.027+(t-1.632)*-14.671/0.017[a46]; \
 [a46][1:v]overlay=enable='between=(t,1.649,1.666)':x=874.580+(t-1.649)*6.135/0.017:y=601.356+(t-1.649)*-9.781/0.017[a47]; \
 [a47][1:v]overlay=enable='between=(t,1.666,1.682)':x=880.715+(t-1.666)*8.589/0.016:y=591.575+(t-1.666)*-14.671/0.016[a48]; \
 [a48][1:v]overlay=enable='between=(t,1.682,1.699)':x=889.303+(t-1.682)*8.589/0.017:y=576.904+(t-1.682)*-14.671/0.017[a49]; \
 [a49][1:v]overlay=enable='between=(t,1.699,1.716)':x=897.892+(t-1.699)*6.135/0.017:y=562.232+(t-1.699)*-4.890/0.017[a50]; \
 [a50][1:v]overlay=enable='between=(t,1.716,1.732)':x=904.027+(t-1.716)*8.589/0.016:y=557.342+(t-1.716)*-14.671/0.016[a51]; \
 [a51][1:v]overlay=enable='between=(t,1.732,1.749)':x=912.616+(t-1.732)*7.362/0.017:y=542.671+(t-1.732)*-9.781/0.017[a52]; \
 [a52][1:v]overlay=enable='between=(t,1.749,1.766)':x=919.978+(t-1.749)*8.589/0.017:y=532.890+(t-1.749)*-14.671/0.017[a53]; \
 [a53][1:v]overlay=enable='between=(t,1.766,1.782)':x=928.567+(t-1.766)*4.908/0.016:y=518.219+(t-1.766)*-4.890/0.016[a54]; \
 [a54][1:v]overlay=enable='between=(t,1.782,1.799)':x=933.475+(t-1.782)*8.589/0.017:y=513.328+(t-1.782)*-11.003/0.017[a55]; \
 [a55][1:v]overlay=enable='between=(t,1.799,1.815)':x=942.063+(t-1.799)*7.362/0.016:y=502.325+(t-1.799)*-9.781/0.016[a56]; \
 [a56][1:v]overlay=enable='between=(t,1.815,1.832)':x=949.425+(t-1.815)*6.135/0.017:y=492.544+(t-1.815)*-4.890/0.017[a57]; \
 [a57][1:v]overlay=enable='between=(t,1.832,1.849)':x=955.560+(t-1.832)*6.135/0.017:y=487.654+(t-1.832)*-7.336/0.017[a58]; \
 [a58][1:v]overlay=enable='between=(t,1.849,1.866)':x=961.695+(t-1.849)*6.135/0.017:y=480.318+(t-1.849)*-3.668/0.017[a59]; \
 [a59][1:v]overlay=enable='between=(t,1.866,1.883)':x=967.830+(t-1.866)*1.227/0.017:y=476.650+(t-1.866)*-1.223/0.017[a60]; \
 [a60][1:v]overlay=enable='between=(t,1.883,1.900)':x=969.057+(t-1.883)*8.589/0.017:y=475.427+(t-1.883)*-2.445/0.017[a61]; \
 [a61][1:v]overlay=enable='between=(t,1.900,1.916)':x=977.646+(t-1.900)*6.135/0.016:y=472.982+(t-1.900)*-1.223/0.016[a62]; \
 [a62][1:v]overlay=enable='between=(t,1.916,1.933)':x=983.781+(t-1.916)*1.227/0.017:y=471.760+(t-1.916)*0.000/0.017[a63]; \
 [a63][1:v]overlay=enable='between=(t,1.933,1.949)':x=985.008+(t-1.933)*1.227/0.016:y=471.760+(t-1.933)*0.000/0.016[a64]; \
 [a64][1:v]overlay=enable='between=(t,1.949,1.966)':x=986.235+(t-1.949)*1.227/0.017:y=471.760+(t-1.949)*0.000/0.017[a65]; \
 [a65][1:v]overlay=enable='between=(t,1.966,1.983)':x=987.462+(t-1.966)*2.454/0.017:y=471.760+(t-1.966)*0.000/0.017[a66]; \
 [a66][1:v]overlay=enable='between=(t,1.983,2.000)':x=989.916+(t-1.983)*0.000/0.017:y=471.760+(t-1.983)*0.000/0.017[a67]; \
 [a67][1:v]overlay=enable='between=(t,2.000,2.016)':x=989.916+(t-2.000)*0.000/0.016:y=471.760+(t-2.000)*1.223/0.016[a68]; \
 [a68][1:v]overlay=enable='between=(t,2.016,2.033)':x=989.916+(t-2.016)*2.454/0.017:y=472.982+(t-2.016)*2.445/0.017[a69]; \
 [a69][1:v]overlay=enable='between=(t,2.033,2.050)':x=992.370+(t-2.033)*0.000/0.017:y=475.427+(t-2.033)*1.223/0.017[a70]; \
 [a70][1:v]overlay=enable='between=(t,2.050,2.066)':x=992.370+(t-2.050)*2.454/0.016:y=476.650+(t-2.050)*8.558/0.016[a71]; \
 [a71][1:v]overlay=enable='between=(t,2.066,2.082)':x=994.824+(t-2.066)*0.000/0.016:y=485.208+(t-2.066)*7.336/0.016[a72]; \
 [a72][1:v]overlay=enable='between=(t,2.082,2.100)':x=994.824+(t-2.082)*0.000/0.018:y=492.544+(t-2.082)*4.890/0.018[a73]; \
 [a73][1:v]overlay=enable='between=(t,2.100,2.116)':x=994.824+(t-2.100)*3.681/0.016:y=497.434+(t-2.100)*13.449/0.016[a74]; \
 [a74][1:v]overlay=enable='between=(t,2.116,2.134)':x=998.504+(t-2.116)*0.000/0.018:y=510.883+(t-2.116)*7.336/0.018[a75]; \
 [a75][1:v]overlay=enable='between=(t,2.134,2.150)':x=998.504+(t-2.134)*0.000/0.016:y=518.219+(t-2.134)*8.558/0.016[a76]; \
 [a76][1:v]overlay=enable='between=(t,2.150,2.167)':x=998.504+(t-2.150)*0.000/0.017:y=526.777+(t-2.150)*17.116/0.017[a77]; \
 [a77][1:v]overlay=enable='between=(t,2.167,2.183)':x=998.504+(t-2.167)*-7.362/0.016:y=543.893+(t-2.167)*24.452/0.016[a78]; \
 [a78][1:v]overlay=enable='between=(t,2.183,2.200)':x=991.143+(t-2.183)*0.000/0.017:y=568.345+(t-2.183)*8.558/0.017[a79]; \
 [a79][1:v]overlay=enable='between=(t,2.200,2.217)':x=991.143+(t-2.200)*-6.135/0.017:y=576.904+(t-2.200)*23.229/0.017[a80]; \
 [a80][1:v]overlay=enable='between=(t,2.217,2.233)':x=985.008+(t-2.217)*-3.681/0.016:y=600.133+(t-2.217)*14.671/0.016[a81]; \
 [a81][1:v]overlay=enable='between=(t,2.233,2.251)':x=981.327+(t-2.233)*-12.270/0.018:y=614.804+(t-2.233)*36.678/0.018[a82]; \
 [a82][1:v]overlay=enable='between=(t,2.251,2.267)':x=969.057+(t-2.251)*-3.681/0.016:y=651.483+(t-2.251)*14.671/0.016[a83]; \
 [a83][1:v]overlay=enable='between=(t,2.267,2.284)':x=965.376+(t-2.267)*-12.270/0.017:y=666.154+(t-2.267)*36.678/0.017[a84]; \
 [a84][1:v]overlay=enable='between=(t,2.284,2.301)':x=953.106+(t-2.284)*-15.951/0.017:y=702.832+(t-2.284)*31.788/0.017[a85]; \
 [a85][1:v]overlay=enable='between=(t,2.301,2.317)':x=937.156+(t-2.301)*-7.362/0.016:y=734.620+(t-2.301)*14.671/0.016[a86]; \
 [a86][1:v]overlay=enable='between=(t,2.317,2.334)':x=929.794+(t-2.317)*-14.724/0.017:y=749.291+(t-2.317)*25.675/0.017[a87]; \
 [a87][1:v]overlay=enable='between=(t,2.334,2.350)':x=915.070+(t-2.334)*-7.362/0.016:y=774.966+(t-2.334)*15.894/0.016[a88]; \
 [a88][1:v]overlay=enable='between=(t,2.350,2.367)':x=907.708+(t-2.350)*-14.724/0.017:y=790.859+(t-2.350)*25.675/0.017[a89]; \
 [a89][1:v]overlay=enable='between=(t,2.367,2.384)':x=892.984+(t-2.367)*-18.405/0.017:y=816.534+(t-2.367)*20.784/0.017[a90]; \
 [a90][1:v]overlay=enable='between=(t,2.384,2.400)':x=874.580+(t-2.384)*-6.135/0.016:y=837.318+(t-2.384)*11.003/0.016[a91]; \
 [a91][1:v]overlay=enable='between=(t,2.400,2.418)':x=868.445+(t-2.400)*-11.043/0.018:y=848.322+(t-2.400)*9.781/0.018[a92]; \
 [a92][1:v]overlay=enable='between=(t,2.418,2.434)':x=857.402+(t-2.418)*-9.816/0.016:y=858.103+(t-2.418)*8.558/0.016[a93]; \
 [a93][1:v]overlay=enable='between=(t,2.434,2.451)':x=847.586+(t-2.434)*-6.135/0.017:y=866.661+(t-2.434)*4.890/0.017[a94]; \
 [a94][1:v]overlay=enable='between=(t,2.451,2.467)':x=841.451+(t-2.451)*-8.589/0.016:y=871.551+(t-2.451)*4.890/0.016[a95]; \
 [a95][1:v]overlay=enable='between=(t,2.467,2.484)':x=832.862+(t-2.467)*-1.227/0.017:y=876.442+(t-2.467)*1.223/0.017[a96]; \
 [a96][1:v]overlay=enable='between=(t,2.484,2.501)':x=831.635+(t-2.484)*-6.135/0.017:y=877.664+(t-2.484)*3.668/0.017[a97]; \
 [a97][1:v]overlay=enable='between=(t,2.501,2.517)':x=825.501+(t-2.501)*-8.589/0.016:y=881.332+(t-2.501)*2.445/0.016[a98]; \
 [a98][1:v]overlay=enable='between=(t,2.517,2.535)':x=816.912+(t-2.517)*-2.454/0.018:y=883.777+(t-2.517)*1.223/0.018[a99]; \
 [a99][1:v]overlay=enable='between=(t,2.535,2.551)':x=814.458+(t-2.535)*-2.454/0.016:y=885.000+(t-2.535)*2.445/0.016[a100]; \
 [a100][1:v]overlay=enable='between=(t,2.551,2.567)':x=812.004+(t-2.551)*-1.227/0.016:y=887.445+(t-2.551)*0.000/0.016[a101]; \
 [a101][1:v]overlay=enable='between=(t,2.567,2.584)':x=810.777+(t-2.567)*-1.227/0.017:y=887.445+(t-2.567)*0.000/0.017[a102]; \
 [a102][1:v]overlay=enable='between=(t,2.584,2.600)':x=809.550+(t-2.584)*0.000/0.016:y=887.445+(t-2.584)*0.000/0.016[a103]; \
 [a103][1:v]overlay=enable='between=(t,2.600,2.617)':x=809.550+(t-2.600)*-1.227/0.017:y=887.445+(t-2.600)*0.000/0.017[a104]; \
 [a104][1:v]overlay=enable='between=(t,2.617,2.689)':x=808.323+(t-2.617)*0.000/0.072:y=887.445+(t-2.617)*0.000/0.072[a105] \
 \
 " -map "[a105]" -map 0:a:? ../tmp/vid-6400d9c21a62d.mp4 -y



And this is just from a four second video. When I tried to do thirty seconds worth of mouse movements, the command would not even run because there were too many arguments. So I need to come up with another way to add a mouse overlay.


An obvious choice would just be screen recording the user's screen to not have to add a mouse overlay because it would already be there. But then I don't think I can use full resolution pictures in the final video. It will be recordings of the images at whatever resolution the user's screen is set to. (Unless there's a way around this that I don't know about.)


So how could I take a long list of mouse coordinates and timestamps and add an overlay representing a cursor to an existing video ?


Edit : I tried putting everything from the
filter-complex
argument into a text file and calling it withfilter_complex_script
instead, as @БаярГончикжапов suggested in comments. Now it at least starts to run, but every time fails with this error :

[Parsed_overlay_1553 @ 0x55caae67f900] [framesync @ 0x55caae6802a8] Sync level 2
[auto_scale_1554 @ 0x55cab4b34b80] Failed to configure output pad on auto_scale_1554
Error reinitializing filters!
Failed to inject frame into filter network: Resource temporarily unavailable
Error while processing the decoded data for stream #1:0
[AVIOContext @ 0x55cab451c900] Statistics: 0 bytes written, 0 seeks, 0 writeouts
[aac @ 0x55cab4523b80] Qavg: 25282.062
[aac @ 0x55cab4523b80] 2 frames left in the queue on closing



It only happens if there are more than 1553 arguments, and changing the arguments for 1553 and surrounding ones doesn't stop the error.


-
How to make an automated video of changing webpage
21 mars 2023, par jonas woutersI'm currently working on a project where I need to make a recording of a webpage without opening this browser. (headless browser)
The file I'm working on is stored locally on my machine and is generated with a Python script. It's generated because it will be different for every user and will be deleted after the recording is made.


I'm currently stuck with trying to make a recording of a webpage.
Does somebody know how I can record a webpage.


Currently I'm doing this


# Make a video
def create_video(duration, name):
 # Path of the HTML file you want to record
 html_file_path = os.path.join(py_dir_path, 'templates/video/', f'{name}.html')
 width = 1080
 height = 1920
 framerate = 30
 
 options = Options()
 options.headless = True
 options.add_experimental_option('mobileEmulation', {'deviceName': 'iPhone SE'})
 driver = webdriver.Chrome(options=options)
 driver.get(f'file://{html_file_path}')
 print(driver)
 outputName = f'{name}.mp4'

 cmd= f'ffmpeg -y -f xcbgrab -s {width}x{height} -framerate {framerate} -i :0.0+0,0 -f alsa -i default -vcodec libx264 -pix_fmt yuv420p -preset ultrafast {outputName}'
 p = subprocess.Popen(cmd, shell=True)

 import time
 time.sleep(duration)

 p.kill()



This code makes a headless browser and plays the website, but the recording process is not working for me


I've already have had working code, but this was based on making screenshots of the webpage and then pasting these screenshots after each other, this code was difficult to read and worst of all very slow.


Working bad code


# Make a video
def create_video(duration, name, timesFaster):
 # Path of the HTML file you want to record
 html_file_path = os.path.join(py_dir_path, 'templates/video/', f'{name}.html')
 # Use function create_driver to create a driver and use this driver
 try:
 # Make a chrome window with size --> width: 390px, height: 850px
 options = webdriver.ChromeOptions()
 options.add_argument("--headless")
 options.add_experimental_option('mobileEmulation', {'deviceName': 'iPhone SE'})
 driver = webdriver.Chrome(options=options)
 driver.get(f'file://{html_file_path}')
 
 # Use function capture_screenshots to take screenshots for 
 capture_screenshots(driver, int(duration), name, timesFaster)
 finally:
 driver.quit

# Make as many screens as possible in ... amount of time (... = animation_duration)
def capture_screenshots(driver, animation_duration, name, timesFaster):
 screenshots = []
 # Calculate the ending time
 end_time = time.time() + animation_duration
 # Keeps track of amount of screenshots
 index = 1

 try:
 # Take as many screenshots as possible until the current time exceeds the end_time
 while time.time() < end_time:
 # Each time a new filename (so it does not overwrite)
 screenshot_file_name = f'capture{index}.png'
 # Save the screenshot on device
 driver.save_screenshot(screenshot_file_name)
 # Append the screenshot in screenshots ([])
 screenshots.append(screenshot_file_name)
 index += 1
 
 
 # Calculate the FPS
 fps = (len(screenshots)/animation_duration) * timesFaster
 print("sec: ", animation_duration/timesFaster)
 print("fps: ", fps)
 # Make the video with the FPS calculated above
 clip = ImageSequenceClip(screenshots, fps=fps)
 # File name of the result (video)
 output_file_path = os.path.join(mp4_dir_path, f"part/{name}.mp4")
 # Write the videoFile to the system
 clip.write_videofile(output_file_path, codec='libx264', bitrate="2M")
 finally:
 # Delete all screenshots
 for screenshot in screenshots:
 try:
 os.remove(screenshot)
 except:
 pass



At the moment it's not that important for me that it's a local file, if I would be able to record a webpage (for example https://jonaswouters.sinners.be/3d-animatie/) this will be equally helpfull


Thanks in advance
Jonas


-
C# Process in loop reading error output, causes "No async read operation is in progress on the stream" error
29 mai 2023, par TSLeeI am trying to read the format of multiple video files using ffmpeg in an asynchronous operation of Process and facing an error, "No async read operation is in progress on the stream". According to https://social.msdn.microsoft.com/Forums/vstudio/en-US/c961f461-7afb-4a92-b0ae-f78c2003b5de/help-an-asynchronous-read-operation-is-already-in-progress-on-the-standardoutput-stream?forum=csharpgeneral, I think I have to use CancelErrorRead(), as BeginErrorReadLine() can't be launched more than once. I also wonder if I use this function in the wrong place, because the read operation has ended in process1.exited() ? But the operation can't proceed to the second index with this error.


How could I use CancelErrorRead()/CancelOutputRead() properly and where should I place them on the code ? I also did an experiment in that I commented these two CancelRead(), and a different error "async read operation has been started on the stream" will appear.


Process process1 = new Process();
 process1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
 process1.StartInfo.CreateNoWindow = true;
 process1.StartInfo.UseShellExecute = false;
 process1.StartInfo.FileName = ".\\ffmpeg.exe";
 process1.StartInfo.WorkingDirectory = ".\\";
 process1.EnableRaisingEvents = true;
 process1.StartInfo.RedirectStandardOutput = true; //if this is true, UseShellExecute must be false. true if output should be written to StandardOutput
 process1.StartInfo.RedirectStandardError = true;
 //indicates that the associated Process has written a line that's terminated with a newline
 process1.ErrorDataReceived += new DataReceivedEventHandler(inputHandler);
 process1.Exited += (ending, p) =>
 {
 flag = true;
 process1.CancelOutputRead();
 process1.CancelErrorRead();//
 };
 foreach (String file in inputList)
 {
 if (flag == true)
 {
 flag = false;
 process1.StartInfo.Arguments = "-i " + " \"" + file + "\"";
 Console.WriteLine(process1.StartInfo.Arguments);
 process1.Start();
 process1.BeginOutputReadLine();//
 process1.BeginErrorReadLine();
 process1.WaitForExit(); //for asynchronous output
 }


 }
 }
 private void inputHandler(object sender, DataReceivedEventArgs l)
 {
 cba.Append(l.Data + "\n");
 videoInput = l.Data;
 //Console.WriteLine(cba);
 //Process p = sender as Process;
 Console.WriteLine(videoInput);

 this.BeginInvoke(new MethodInvoker(() =>
 {

 if (!String.IsNullOrEmpty(videoInput))
 {
 if (videoInput.Contains("Stream #0:0"))
 {
 String subvideoInput1 = 
 videoInput.Substring(videoInput.IndexOf("Stream #0:0"));
 String video_inputType = subvideoInput1;
 textBox1.Text += video_inputType + System.Environment.NewLine;
 Console.WriteLine(video_inputType);
 }
 if (videoInput.Contains("Stream #0:1"))
 {
 String subvideoInput2 = 
 videoInput.Substring(videoInput.IndexOf("Stream #0:1"));
 Console.WriteLine(subvideoInput2.IndexOf("\n"));
 Console.WriteLine(subvideoInput2);
 String audio_inputType = subvideoInput2;
 textBox1.AppendText(audio_inputType + System.Environment.NewLine);
 Console.WriteLine(audio_inputType);
 }
 if (videoInput.Contains("Duration:"))
 {
 String videoinputDuration = 
 videoInput.Substring(videoInput.IndexOf("Duration:"));
 String subvideo_inputDuration = videoinputDuration.Substring(9);
 String inputvideoDuration = 
 subvideo_inputDuration.Remove(subvideo_inputDuration.IndexOf("."));
 Console.WriteLine(inputvideoDuration);
 double totalseconds = 
 TimeSpan.Parse(inputvideoDuration).TotalSeconds;
 
 

 }
 }

 }));


 }