
Recherche avancée
Médias (1)
-
Carte de Schillerkiez
13 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
Autres articles (59)
-
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 -
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 ;
-
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" ;
Sur d’autres sites (9691)
-
How can I open a program using PYTHON with Mutliprocessing, and send it strings from the main process ?
12 février 2018, par Just AskinI have a program that sends frames as strings to FFMPEG using something similar to :
Working script that streams without using multiprocessing module currently on Ubuntu
#!/usr/bin/python
import sys, os
import subprocess as sp
import pygame
from pygame.locals import QUIT, KEYUP, K_ESCAPE
import pygame.display
pygame.init()
os.environ['SDL_VIDEODRIVER'] = 'dummy'
pygame.display.init()
Display_Surface = pygame.display.set_mode([1280,720], 0, 32)
# FFMPEG command and settings
command = ['ffmpeg', '-framerate', '25', '-s', '1280x720', '-pix_fmt', 'rgba', '-f', 'rawvideo', '-i', '-',
'-f', 'lavfi', '-i', 'anullsrc=cl=mono',
'-pix_fmt', 'yuv420p','-s', 'hd720', '-r', '25', '-g', '50',
'-f', 'flv', 'rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx']
pipe = sp.Popen(command, bufsize=0, stdin=sp.PIPE)
while True:
# Quit event handling
for event in pygame.event.get():
if event.type == QUIT or (event.type == KEYUP and event.key == K_ESCAPE):
pygame.quit()
sys.exit()
pipe.stdin.write(pygame.image.tostring(Display_Surface, "RGBA"))
pipe.stdin.close()
pygame.display.quit()
os._exit()This works fine, except for the fact that it is killing my CPU, which in turn causes my live stream to freeze often. The stupid GIL won’t let FFMPEG run on another CPU/Core while I have 3 perfectly good cores doing nothing.
I just whipped up some code to open FFMPEG in another process. (By the way, I’m familiar with threading.Thread, but not Multiprocessing).
import os
import subprocess as sp
import multiprocessing
class FFMPEG_Consumer():
def __init__(self):
proc = multiprocessing.Process(target=self.start_ffmpeg)
proc.start()
def start_ffmpeg(self):
command = ['ffmpeg','-pix_fmt', 'rgba', '-f', 'rawvideo', '-i', '-',
'-f, 'lavfi', '-i', 'anullsrc=channel_layout=stereo:sample_rate=44100',
'-pix_fmt', 'yuv420p','-s', 'hd720', '-f', 'flv', 'rtmp://example.com']
pipe = sp.Popen(command, bufsize=-1, stdin=sp.PIPE)
def send_down_the_pipe(self, frame):
pipe.stdin.write(frame)
ffmpeg = FFMPEG_Consumer()For anyone that knows how to use multiprocessing, I’m sure you will immediately see that this does not work because I can’t share variables this way across processes. But, it does open FFMPEG on another core.
Most online tutorials and resources focus creating pools of workers and queues to send those workers something to be processed until a job is finished. I am however trying to send a new string repeatedly to FFMPEG through each iteration.
How can I pipe my string to that process/instance of FFMPEG ?
Or is what I’m trying to do not possible ?
This was the working solution (with dumbed down FFMPEG settings) :
#!/usr/bin/python
import sys, os, multiprocessing
import subprocess as sp
import pygame
from pygame.locals import QUIT, KEYUP, K_ESCAPE
import pygame.display
pygame.init()
os.environ['SDL_VIDEODRIVER'] = 'dummy'
pygame.display.init()
Display_Surface = pygame.display.set_mode([1280,720], 0, 32)
class FFMPEGConsumer(object):
def __init__(self):
self._r, self._w = multiprocessing.Pipe()
self.reader = os.fdopen(self._r.fileno(), 'r')
self.writer = os.fdopen(self._w.fileno(), 'w', 0)
self.proc = None
def start_ffmpeg(self):
command = ['ffmpeg', '-framerate', '25', '-s', '1280x720', '-pix_fmt', 'rgba', '-f', 'rawvideo', '-i', '-',
'-f', 'lavfi', '-i', 'anullsrc=cl=mono',
'-pix_fmt', 'yuv420p','-s', 'hd720', '-r', '25', '-g', '50',
'-f', 'flv', 'rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx']
self.proc = sp.Popen(command, bufsize=-1, stdin=self.reader)
def send_down_the_pipe(self, frame):
self.writer.write(frame)
#print self._stdin.read()
def __del__(self):
self.reader.close()
self.writer.close()
ffmpeg = FFMPEGConsumer()
while True:
# Quit event handling
for event in pygame.event.get():
if event.type == QUIT or (event.type == KEYUP and event.key == K_ESCAPE):
pygame.quit()
sys.exit()
ffmpeg.send_down_the_pipe(pygame.image.tostring(Display_Surface, "RGBA"))
proc.join()
pipe.stdin.close()
pygame.display.quit()
os._exit()All cores are firing and no lags so far !!!
-
Install ffmpeg in to virtual environment
22 mars, par ldgI am trying to install
ffmpeg
in order to use it on OpenAI to record videos. I have installed it usingbrew install ffmpeg
but somehow when I compile my code I get the same error, it is like the package is not recognized by myvirtualenv
where I am working.


Error on Python console :



raise error.DependencyNotInstalled("""Found neither the ffmpeg nor avconv executables. On OS X, you can install ffmpeg via `brew install ffmpeg`. On most Ubuntu variants, `sudo apt-get install ffmpeg` should do it. On Ubuntu 14.04, however, you'll need to install avconv with `sudo apt-get install libav-tools`.""")




However, when I execute which
ffmpeg
I got the following path/usr/local/bin/ffmpeg
.


It seems like that Anaconda for example needs a specific command to install this package into its environment, it is the same for virtualenv ?



Thanks in advance.


-
Emscripten compiling multiple main functions
20 février 2018, par AlexVestinI’ve been trying to compile FFmpeg using Emscripten to export to WebAssembly code. I’ve been using the ffmpeg.js Makefile here, with very slight modifications. The compilation works fine without any errors, and generates a ffmpeg.bc, however if I try to compile the file along with another C file containing a
main
function I get the errorerror: Linking globals named ´main´: symbol multiply defined!
ERROR:root:Failed to run llvm optimizations:
The command I’m using is :
ffmpeg-wasm.js: (FFMPEG_MP4_BC)
emcc test.c $(FFMPEG_MP4_BC) $(MP4_SHARED_DEPS) $(EMCC_COMMON_ARGS)where
EMCC_COMMON_ARGS = \
-s TOTAL_MEMORY=67108864 \
-s OUTLINING_LIMIT=20000 \
-O3 --memory-init-file 0 \
-o $@ \
-s WASM=1 \
-I/usr/local/includeI have tried using a different snapshot of ffmpeg, which didn’t fix the problem.
If I run
llvm-nm $(find . -name *.so) > log.txt && grep -n ./log.txt -e "int main"
to test if any of the dependencies contain a main, I get nothing, however there is a global main function in the generated
ffmpeg.bc
.So, is there any way to remove the main function from the library, or some flag to set to prevent a global main function from being generated ?