
Recherche avancée
Autres articles (78)
-
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 ;
-
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 ) (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir
Sur d’autres sites (12402)
-
How to build list of tasks for asyncio.gather in Python 3.8
22 juillet 2020, par mcgregor94086Below I have attached a test program to demonstrate a problem I am having with asyncio.gather throwing a TypeError.


My objective : To make multiple concurrent asynchronous calls to capture camera images to files from an array of USB cameras attached to my computer. When all cameras have completed their async captures, I want then resume processing.


The async coroutine take_image() shown here makes a system call to the "ffmpeg" application that captures an image from the specified camera to a specified file.


import asyncio
import os
import subprocess
import time

async def take_image(camera_id, camera_name, image_file_path, image_counter):
 image_capture_tic = time.perf_counter()
 try:
 run_cmd = subprocess.run( ["ffmpeg", '-y', '-hide_banner', '-f', 'avfoundation', '-i', camera_id,
 '-frames:v', '1', '-f', 'image2', image_file_path], universal_newlines=True,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Note, ffmpeg writes to stderr, not stdout!
 except Exception as e:
 print("Error: Unable to capture image for", image_file_path)
 return "NO IMAGE!"

 image_capture_toc = time.perf_counter()
 print(f"{image_counter}: Captured {camera_name} image in: {image_capture_toc - image_capture_tic:0.0f} seconds")
 return camera_name



The main() routine shown below takes a list of multiple cameras, and iterating over each camera in the list, main() makes creates an asyncio task for each camera using asyncio.create_task(). Each task is added to a list of tasks.


Once all image capture tasks have been started, I await their completion using await asyncio.gather(tasks).


async def main():
 tic = time.perf_counter()
 camera_list = [('0', 'FHD Camera #1'), ('1', 'FHD Camera #2'), ('2', 'FHD Camera #3'), ]
 image_counter = 1
 tasks = []
 for camera_pair in camera_list:
 camera_id, camera_name = camera_pair
 image_file_name = 'img' + str(image_counter) + "-cam" + str(camera_id) + "-" + camera_name + '.jpg'
 image_file_path = os.path.join("/tmp/test1/img", image_file_name)

 # schedule all image captures calls *concurrently*:
 tasks.append(asyncio.create_task(take_image(camera_id, camera_name, image_file_path, image_counter),
 name=image_file_name))
 image_counter = image_counter + 1

 await asyncio.gather(tasks) # <-- This line throws a TypeError!
 toc = time.perf_counter()
 print(f"Captured list of {image_counter - 1} cameras in: {toc - tic:0.0f} seconds")

asyncio.run(main())



Unfortunately, when I attempt to run this program, I am getting this error :


TypeError : unhashable type : 'list'


and the following Traceback :


Traceback (most recent call last):
 File "scratch_10.py", line 41, in <module>
 asyncio.run(main())
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/runners.py", line 43, in run
 return loop.run_until_complete(main)
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
 return future.result()
 File "scratch_10.py", line 36, in main
 await asyncio.gather(tasks)
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/tasks.py", line 805, in gather
 if arg not in arg_to_fut:
TypeError: unhashable type: 'list'
</module>


I have been trying to puzzle through the 3.8 documentation on asyncio, but I don't understand what is wrong.


How can I have each take_image request run asynchronously, and then resume processing in my calling routine once each task is complete ?


-
Getting List of default argument values if not used in FFMPEG command execution
12 juillet 2020, par Pradeep PrabhuWhen I use FFMPEG to capture a live IPTV stream on my MAC, I generally end up with an interrupted video. When I send these four arguments, the capture is successful.


-reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 2


I don't want to specify these arguments everytime, So I decided to update the default values in the source code. Unsure if I have done it right - I updated http.c which contains these arguments. I re-compiled FFMPEG successfully.


I want to know if my changes are applied. Is there a way I can list out all the default values of the arguments. I can use this compiled version of FFMPEG for a week, and determine if the fix is applied or not, I was wondering, if there is a quicker and easier way to do it.


If this is successful, I can use this version of FFMPEG for Emby & TellyTV.


-
av_hwdevice_iterate_types returns an empty list
9 juillet 2020, par Ruslan AblyazovI used an example https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/hw_decode.c


The av_hwdevice_iterate_types function returns an empty list. What could be the reason ?


And
avcodec_find_decoder_by_name("h264_cuvid")
returns NULL.

FFmpeg version :


ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Debian 8.3.0-6)
configuration: --enable-gpl --enable-ladspa --enable-libpulse --enable-libsoxr --enable-libspeex --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-nonfree --disable-ffplay --enable-libxvid --enable-cuda --enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100



The command
ffmpeg -c:v h264_cuvid -i 7.mp4 71.mp4
outputs :

...
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> h264 (libx264))
....



And it works.


The command
ffmpeg-hwaccel cuda-i 7.mp4 71.mp4
outputs :

...
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
....



The command
ffmpeg -codecs
outputs :

...
 DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m h264_cuvid ) (encoders: libx264 libx264rgb h264_nvenc h264_v4l2m2m nvenc nvenc_h264 )
 D.VIL. hap Vidvox Hap
 DEV.L. hevc H.265 / HEVC (High Efficiency Video Coding) (decoders: hevc hevc_v4l2m2m hevc_cuvid ) (encoders: libx265 nvenc_hevc hevc_nvenc hevc_v4l2m2m )
 ...