
Recherche avancée
Autres articles (111)
-
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Gestion de la ferme
2 mars 2010, parLa ferme est gérée dans son ensemble par des "super admins".
Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
Dans un premier temps il utilise le plugin "Gestion de mutualisation" -
Gestion des droits de création et d’édition des objets
8 février 2011, parPar défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;
Sur d’autres sites (10108)
-
Return Specific Values/Text in ffmpeg Result Using Python
4 mai 2020, par jamlotI am attempting to write a Python script that looks for black video and silent audio in a file, and returns only the time instances when they occur.



I have the following code working using the ffmpeg-python wrapper, but I can't figure out an efficient way to parse the stdout or stderror to return only the instances of black_start, black_end, black_duration, silence_start, silence_end, silence_duration.



import ffmpeg 

input = ffmpeg.input(source)
video = input.video.filter('blackdetect', d=0, pix_th=0.00)
audio = input.audio.filter('silencedetect', d=0.1, n='-60dB')
out = ffmpeg.output(audio, video, 'out.null', format='null')
run = out.run_async(pipe_stdout=True, pipe_stderr=True)
result = run.communicate()

print(result)




This results in the ffmpeg output, which contains the results I need. Here is the output (edited for brevity) :



(b'', b"ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
 built with Apple clang version 11.0.0 (clang-1100.0.33.17)
 configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_3 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags=-fno-stack-check --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
 libavutil 56. 31.100 / 56. 31.100
 libavcodec 58. 54.100 / 58. 54.100
 libavformat 58. 29.100 / 58. 29.100
 libavdevice 58. 8.100 / 58. 8.100
 libavfilter 7. 57.100 / 7. 57.100
 libavresample 4. 0. 0 / 4. 0. 0
 libswscale 5. 5.100 / 5. 5.100
 libswresample 3. 5.100 / 3. 5.100
 libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/otoolej/Documents/_lab/source/black-silence-detect/AUUV71900381_test.mov':
 Metadata:
 major_brand : qt 
 minor_version : 537199360
 compatible_brands: qt 
 creation_time : 2019-11-14T04:12:49.000000Z
 Duration: 00:03:50.28, start: 0.000000, bitrate: 185168 kb/s
 Stream #0:0(eng): Video: prores (HQ) (apch / 0x68637061), yuv422p10le(tv, bt709, progressive), 1920x1080, 183596 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 25 tbn, 25 tbc (default)
 Metadata:
 creation_time : 2019-11-14T04:12:49.000000Z
 handler_name : Apple Video Media Handler
 encoder : Apple ProRes 422 (HQ)
 timecode : 00:00:00:00
 Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s (default)
 Metadata:
 creation_time : 2019-11-14T04:12:49.000000Z
 handler_name : Apple Sound Media Handler
 timecode : 00:00:00:00
 Stream #0:2(eng): Data: none (tmcd / 0x64636D74) (default)
 Metadata:
 creation_time : 2019-11-14T04:12:49.000000Z
 handler_name : Time Code Media Handler
 timecode : 00:00:00:00
Only '-vf blackdetect=d=0:pix_th=0.00' read, ignoring remaining -vf options: Use ',' to separate filters
Only '-af silencedetect=d=0.1:n=-60dB' read, ignoring remaining -af options: Use ',' to separate filters
Stream mapping:
 Stream #0:0 -> #0:0 (prores (native) -> wrapped_avframe (native))
 Stream #0:1 -> #0:1 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
 Metadata:
 major_brand : qt 
 minor_version : 537199360
 compatible_brands: qt 
 encoder : Lavf58.29.100
 Stream #0:0(eng): Video: wrapped_avframe, yuv422p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
 Metadata:
 creation_time : 2019-11-14T04:12:49.000000Z
 handler_name : Apple Video Media Handler
 timecode : 00:00:00:00
 encoder : Lavc58.54.100 wrapped_avframe
 Stream #0:1(eng): Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s (default)
 Metadata:
 creation_time : 2019-11-14T04:12:49.000000Z
 handler_name : Apple Sound Media Handler
 timecode : 00:00:00:00
 encoder : Lavc58.54.100 pcm_s16le
[silencedetect @ 0x7fdd82d011c0] silence_start: 0
frame= 112 fps=0.0 q=-0.0 size=N/A time=00:00:05.00 bitrate=N/A speed=9.96x 
[blackdetect @ 0x7fdd82e06580] black_start:0 black_end:5 black_duration:5
[silencedetect @ 0x7fdd82d011c0] silence_end: 5.06285 | silence_duration: 5.06285
frame= 211 fps=210 q=-0.0 size=N/A time=00:00:09.00 bitrate=N/A speed=8.97x 
frame= 319 fps=212 q=-0.0 size=N/A time=00:00:13.00 bitrate=N/A speed=8.63x 
frame= 427 fps=213 q=-0.0 size=N/A time=00:00:17.08 bitrate=N/A speed=8.51x 
frame= 537 fps=214 q=-0.0 size=N/A time=00:00:22.00 bitrate=N/A speed=8.77x 
frame= 650 fps=216 q=-0.0 size=N/A time=00:00:26.00 bitrate=N/A speed=8.63x 
frame= 761 fps=217 q=-0.0 size=N/A time=00:00:31.00 bitrate=N/A speed=8.82x 
frame= 874 fps=218 q=-0.0 size=N/A time=00:00:35.00 bitrate=N/A speed=8.71x 
frame= 980 fps=217 q=-0.0 size=N/A time=00:00:39.20 bitrate=N/A speed=8.67x 
... 
frame= 5680 fps=213 q=-0.0 size=N/A time=00:03:47.20 bitrate=N/A speed=8.53x 
[silencedetect @ 0x7fdd82d011c0] silence_start: 227.733
[silencedetect @ 0x7fdd82d011c0] silence_end: 229.051 | silence_duration: 1.3184
[silencedetect @ 0x7fdd82d011c0] silence_start: 229.051
[blackdetect @ 0x7fdd82e06580] black_start:229.28 black_end:230.24 black_duration:0.96
frame= 5757 fps=214 q=-0.0 Lsize=N/A time=00:03:50.28 bitrate=N/A speed=8.54x 
video:3013kB audio:43178kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[silencedetect @ 0x7fdd82d011c0] silence_end: 230.28 | silence_duration: 1.22856
\n")




What is the most efficient way to parse the output data to find/return only those result values so I can build further logic from them in my code ? In this case, I would want only the following values returned :



silence_start : 0

silence_end : 5.06285

silence_duration : 5.06285


black_start:0

black_end:5

black_duration:5


silence_start : 227.733

silence_end : 229.051

silence_duration : 1.3184


black_start:229.28

black_end:230.24

black_duration:0.96


silence_start : 229.051

silence_end : 230.28

silence_duration : 1.22856


I think there is a way to get only those values using ffprobe, but I couldn't get that to work within the wrapper method. Possible I would have to run ffprobe as a subprocess and parse that result somehow. That would be a total re-do though.


-
Return Only Specific Values With Python Script
6 mai 2020, par jamlotI am a total Python beginner and attempting to write a script that looks for black video and silent audio in a file, and returns only the time instances when they occur.



I have the following code working using the ffmpeg-python wrapper to get the values in stdout, but I can't figure out an efficient way to parse the stdout or stderror to return only the instances of black_start, black_end, black_duration, silence_start, silence_end, silence_duration.



Putting ffmpeg aside for those who are not experts, how can I use re.findall or similar to define the regex to return only the above values ?



import ffmpeg 

input = ffmpeg.input(source)
video = input.video.filter('blackdetect', d=0, pix_th=0.00)
audio = input.audio.filter('silencedetect', d=0.1, n='-60dB')
out = ffmpeg.output(audio, video, 'out.null', format='null')
run = out.run_async(pipe_stdout=True, pipe_stderr=True)
result = run.communicate()

print(result)




This results in the ffmpeg output, which contains the results I need. Here is the output (edited for brevity) :



(b'', b"ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
 built with Apple clang version 11.0.0 (clang-1100.0.33.17)
 configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_3 --enable-shared --enable-pthreads --...
[silencedetect @ 0x7fdd82d011c0] silence_start: 0
frame= 112 fps=0.0 q=-0.0 size=N/A time=00:00:05.00 bitrate=N/A speed=9.96x 
[blackdetect @ 0x7fdd82e06580] black_start:0 black_end:5 black_duration:5
[silencedetect @ 0x7fdd82d011c0] silence_end: 5.06285 | silence_duration: 5.06285
frame= 211 fps=210 q=-0.0 size=N/A time=00:00:09.00 bitrate=N/A speed=8.97x 
frame= 319 fps=212 q=-0.0 size=N/A time=00:00:13.00 bitrate=N/A speed=8.63x 
frame= 427 fps=213 q=-0.0 size=N/A time=00:00:17.08 bitrate=N/A speed=8.51x 
frame= 537 fps=214 q=-0.0 size=N/A time=00:00:22.00 bitrate=N/A speed=8.77x 
frame= 650 fps=216 q=-0.0 size=N/A time=00:00:26.00 bitrate=N/A speed=8.63x 
frame= 761 fps=217 q=-0.0 size=N/A time=00:00:31.00 bitrate=N/A speed=8.82x 
frame= 874 fps=218 q=-0.0 size=N/A time=00:00:35.00 bitrate=N/A speed=8.71x 
frame= 980 fps=217 q=-0.0 size=N/A time=00:00:39.20 bitrate=N/A speed=8.67x 
... 
frame= 5680 fps=213 q=-0.0 size=N/A time=00:03:47.20 bitrate=N/A speed=8.53x 
[silencedetect @ 0x7fdd82d011c0] silence_start: 227.733
[silencedetect @ 0x7fdd82d011c0] silence_end: 229.051 | silence_duration: 1.3184
[silencedetect @ 0x7fdd82d011c0] silence_start: 229.051
[blackdetect @ 0x7fdd82e06580] black_start:229.28 black_end:230.24 black_duration:0.96
frame= 5757 fps=214 q=-0.0 Lsize=N/A time=00:03:50.28 bitrate=N/A speed=8.54x 
video:3013kB audio:43178kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[silencedetect @ 0x7fdd82d011c0] silence_end: 230.28 | silence_duration: 1.22856
\n")




What is the most efficient way to parse the output data to find/return only those result values so I can build further logic from them in my code ? In this case, I would want only the following values returned :



silence_start : 0

silence_end : 5.06285

silence_duration : 5.06285


black_start:0

black_end:5

black_duration:5


silence_start : 227.733

silence_end : 229.051

silence_duration : 1.3184


black_start:229.28

black_end:230.24

black_duration:0.96


silence_start : 229.051

silence_end : 230.28

silence_duration : 1.22856


I've tried a bunch of different re.findall() options with regex, but the closest I've gotten is returning just the names of the values. For example, if I add this to the above :



found = re.findall('\\b' + 'silence_end' + '\\b', str(result))

print(found)




All I get are the names :



['silence_end', 'silence_end', 'silence_end']


-
With ffmpeg print onto clipped video hh:mm:ss time *from original* and hh:mm:ss total duration from original
25 mai 2023, par KesI am using arch linux and bash and ffmpeg, all are up to date and the latest versions.


I am clipping a video that is 30 seconds long and wish to clip from 5 secs to 10 seconds to a new file, from the original.


In the bottom right hand corner of the clip I wish to show timestamps from the original video as follows


- 

- in the 5th second "00:00:05/ 00:00:30"
- in the 6th second "00:00:06/ 00:00:30"

etc - in the 10th second "00:00:10/ 00:00:30"








This is an apparentley simple question(?) but the syntax of the command is not at all obvious and I am hoping an expert may shed some light on this.


All I have so far for the drawtext part, which does not do what I want as it only counts the elapsed time from t=0 of the new clip, whereas I want it to show the timestamp and total duration of the original clip


drawtext
I started with

"drawtext=text='%{pts\:gmtime\:0\:%M\\\\\:%S}':fontsize=24:fontcolor=black:x=(w-text_w-10):y=(h-text_h-10)"



ffmpeg line with drawtext I have started with


ffmpeg -ss 00:00:05 -i "$in_file" -filter_complex "drawtext=fontfile=font.ttf:text='sample text':x=10:y=10:fontsize=12:fontcolor=white:box=1:boxcolor=black@0.5:boxborderw=5,drawtext=text='%{duration\:hms}':fontsize=12:fontcolor=black:x=(w-text_w-10):y=(h-text_h-10)" -t 5 -c:a copy -c:v libx264 out_file.mp4