
Recherche avancée
Médias (1)
-
The Great Big Beautiful Tomorrow
28 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Texte
Autres articles (36)
-
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...) -
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
HTML5 audio and video support
13 avril 2011, parMediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
For older browsers the Flowplayer flash fallback is used.
MediaSPIP allows for media playback on major mobile platforms with the above (...)
Sur d’autres sites (4860)
-
ffmpeg with Popen (python) on Windows
21 août 2018, par GabrielleI am trying to use ffmpeg with Popen. The ffmpeg command I am trying works on cmd but gives me error with Popen.
I am using the standalone ffmpeg .exe :
ffmpeg -f gdigrab -offset_x 10 -offset_y 20 -show_region 1 -i desktop -video_size 1536x864 -b:v 2M -maxrate 1M -bufsize 1M -tune fastdecode -crf 15 -preset ultrafast -pix_fmt yuv420p -r 25 <path>/video.mov -qp 1 -y -an
</path>This gives me
Invalid argument
, but if I remove the last parameters in order to make the output the last thing on the string, I get a different error :Output file #0 does not contain any stream
I tried to use
-f dshow -i video="UScreenCapture"
instead of the gdigrab, but both give me the same error with and without the parameters in the end.Both commands work on command line.
On command line this
ffmpeg -list_devices true -f dshow -i dummy
returns this :[dshow @ 000001b24fa6a300] DirectShow video devices (some may be both video and audio devices)
[dshow @ 000001b24fa6a300] "Integrated Webcam"
[dshow @ 000001b24fa6a300] Alternative name "@device_pnp_\\?\usb#vid_1bcf&pid_2b8a&mi_00#6&2c03619a&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
[dshow @ 000001b24fa6a300] "UScreenCapture"
[dshow @ 000001b24fa6a300] Alternative name "@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\UScreenCapture"
[dshow @ 000001b24fa6a300] DirectShow audio devices
[dshow @ 000001b24fa6a300] "Microphone (Realtek Audio)"
[dshow @ 000001b24fa6a300] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{35EBFC89-7B09-4557-8032-85AA0B688FE9}"But on popen I can’t check it :
-list_devices true -f dshow -i dummy: Invalid argument
For the python part of the code I am using this :
p = subprocess.Popen([getPathForFile("windows/ffmpeg").replace('\\','/'), " -f gdigrab -offset_x 10 -offset_y 20 -show_region 1 -i desktop -video_size 1536x864 -b:v 2M -maxrate 1M -bufsize 1M -tune fastdecode -crf 15 -preset ultrafast -pix_fmt yuv420p -r 25 -qp 1 -y -an "+ path.replace('\\\\','/').replace('\\','/')+"video.mov"], shell=True)
The
getPathForFile
is a custom function that returns the path. this is correct, mainly because the errors I am getting are from the ffmpeg, so...I am on a Windows 10. FFmpeg 4.0. Python 3.5.
Any ideas why am I getting these errors on Popen but not on command line and how to fix them ? (mainly the second error)
-
How to queue ffmpeg jobs for transcoding ?
25 juillet 2019, par sujit patelThis scripts below check
ftp
fro any media file and starts transcoding usingffmpeg
. Problem is it starts so manyffmpeg
process simultaneously. since so manyffmpeg
process running servers becomes too slow and takes heavy amount of time to transcodes videos. Sometimes server stops working.How to put jobs in a queue ?
#!/usr/bin/env python3
import os, sys, time, threading, subprocess
import logging
from config import MEDIA_SERVER, MEDIA_SERVER_USERNAME, MEDIA_DIRS, LOCAL_MEDIA_DIR_ROOT, TRANSCODING_SERVER, TRANSCODING_SERVER_USERNAME, RSYNC_SERVER, RSYNC_USERNAME, RSYNC_DIR, PROCESSING_DIR, PROCESSING_GPU_SCRIPT, PROCESSING_CPU_SCRIPT, EMAIL_SEND_TO, EMAIL_SEND_FROM
from send_email import sendEmail
import sqlite3
logger = logging.getLogger(__name__)
class FuncThread(threading.Thread):
def __init__(self, target, *args):
self._targett = target
self._argst = args
threading.Thread.__init__(self)
def run(self):
self._targett(*self._argst)
class Automator(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.sleepTime=60
self.lastSMILFileCheckTime = 0
self.newlastSMILFileCheckTime = 0
self.lastMediaFileCheckTime = 0
self.newLastMediaFileCheckTime = 0
self.db = None
self.fluid_threads = []
self.scriptRoot = os.path.dirname(os.path.realpath(__file__))
def fluid_thread_add(self, thd):
self.fluid_threads.append(thd)
thd.start()
def processFluidThreads(self):
fluid_cond = [x.is_alive() for x in self.fluid_threads]
finished_threads = [x for x, y in zip(self.fluid_threads, fluid_cond) if not y]
self.fluid_threads = [x for x, y in zip(self.fluid_threads, fluid_cond) if y]
if len(finished_threads) > 0:
logger.info('Fluid threads finished: %s (joining on them now...)' % str(len(finished_threads)))
[thd.join() for thd in finished_threads]
logger.info('Joined finished threads successfully')
if len(self.fluid_threads) > 0:
logger.info('Fluid threads remaining: %s' % str(len(self.fluid_threads)))
def run(self):
self.setupDB()
self.fetchlastCheckTime()
while True:
self.process()
time.sleep(self.sleepTime)
def process(self):
logger.debug("process")
try:
self.handleNewSMILFiles()
self.rsyncFromRemote()
self.handleNewSourceFiles()
# fluid_thread_add(FuncThread(start_single_task, user, task_name, task_path, selected_region))
self.processFluidThreads()
self.updatelastCheckTimes()
except Exception as e:
print(e)
logger.error("Something went wrong while running this")
def handleNewSourceFiles(self):
logger.info("Looking for medial files since " + str(self.lastMediaFileCheckTime))
for root, dirs, filenames in os.walk(PROCESSING_DIR):
for subdir in dirs:
pass
for f in filenames:
if (f.lower().endswith("complete")):
file_path = os.path.join(root, f)
mod_time = self.modification_date(file_path)
if (mod_time > self.lastMediaFileCheckTime):
logger.info("Found a new media File " + file_path)
relDir = os.path.relpath(root, PROCESSING_DIR)
f_name = root.split("/")[-1]
new_output_localdir = os.path.join(LOCAL_MEDIA_DIR_ROOT, relDir)
new_output_localdir = os.path.abspath(os.path.join(new_output_localdir, os.pardir))
new_output_remotedir = new_output_localdir
if new_output_remotedir.startswith(LOCAL_MEDIA_DIR_ROOT):
new_output_remotedir = new_output_remotedir[len(LOCAL_MEDIA_DIR_ROOT):]
if(self.startATranscodingThread(root, new_output_localdir, new_output_remotedir, f_name+".mp4")):
if(mod_time > self.newLastMediaFileCheckTime):
self.newLastMediaFileCheckTime = mod_time
def startATranscodingThread(self, inputFile, outputLocalDIR, outputRemoteDIR, fileName):
self.fluid_thread_add(FuncThread(self.runTranscoder, inputFile, outputLocalDIR, outputRemoteDIR, fileName, MEDIA_SERVER))
return True
def handleNewSMILFiles(self):
if (MEDIA_SERVER != TRANSCODING_SERVER):
logger.info("Media server is separate, fetching last 24 hours SMIL files from " + MEDIA_SERVER)
self.rsyncSMILFiles()
logger.info("Looking for SMIL files since " + str(self.lastSMILFileCheckTime) + " in " + LOCAL_MEDIA_DIR_ROOT)
for root, dirs, filenames in os.walk(LOCAL_MEDIA_DIR_ROOT):
for subdir in dirs:
pass
for f in filenames:
file_path = os.path.join(root, f)
if (f.lower().endswith("stream.smil")):
file_path = os.path.join(root, f)
mod_time = self.modification_date(file_path)
if(mod_time > self.lastSMILFileCheckTime):
logger.info("Found a new SMIL File " + file_path)
relDir = os.path.relpath(root, LOCAL_MEDIA_DIR_ROOT)
f = f.split(".")[0]
new_dir_name = os.path.splitext(os.path.basename(f))[0]
new_dir_name = os.path.join(relDir, new_dir_name)
if(self.createARemoteDirectory(new_dir_name)):
if(mod_time > self.newlastSMILFileCheckTime):
self.newlastSMILFileCheckTime = mod_time
def modification_date(self, filename):
t = os.path.getmtime(filename)
return t
def createARemoteDirectory(self, dirName):
HOST = RSYNC_SERVER
DIR_NAME=RSYNC_DIR + "/" + dirName
COMMAND = "ssh {}@{} mkdir -p {}".format(RSYNC_USERNAME, RSYNC_SERVER, DIR_NAME)
logger.info("Going to execute :-- " + COMMAND)
rv = subprocess.check_call(COMMAND, shell=True)
return True
def rsyncSMILFiles(self):
HOST = RSYNC_SERVER
for MEDIA_DIR in MEDIA_DIRS:
epoch_time = int(time.time())
TEMP_FILE="/tmp/rsync_files.{}".format(epoch_time)
COMMAND = "ssh -o ConnectTimeout=10 {}@{} \"cd {} && find . -mtime -3 -name *.stream.smil > {} && rsync -azP --files-from={} . {}@{}:{}/{}\"".format(MEDIA_SERVER_USERNAME, MEDIA_SERVER, MEDIA_DIR, TEMP_FILE, TEMP_FILE, TRANSCODING_SERVER_USERNAME, TRANSCODING_SERVER, LOCAL_MEDIA_DIR_ROOT, MEDIA_DIR)
logger.info("Going to execute :-- " + COMMAND)
try:
rv = subprocess.check_call(COMMAND, shell=True)
except Exception as e:
logger.error("Unable to connect to media server")
return True
def rsyncFromRemote(self):
HOST = RSYNC_SERVER
COMMAND="rsync -azP --delete {}@{}:{} {} ".format(RSYNC_USERNAME, RSYNC_SERVER, RSYNC_DIR+"/", PROCESSING_DIR)
logger.info("Going to execute :-- " + COMMAND)
rv = subprocess.check_call(COMMAND, shell=True)
return True
def runTranscoder(self, inputDIR, outputLocalDIR, outputRemoteDIR, fileName, media_server):
HOST = RSYNC_SERVER
COMMAND="bash {} {} {} {} {} {}".format(PROCESSING_CPU_SCRIPT, inputDIR, outputLocalDIR, outputRemoteDIR, fileName, media_server)
# if (len(self.fluid_threads)>2):
# COMMAND="bash {} {} {} {} {} {}".format(PROCESSING_CPU_SCRIPT, inputDIR, outputLocalDIR, outputRemoteDIR, fileName, media_server)
logger.info("Going to execute :-- " + COMMAND)
#sendEmail(EMAIL_SEND_TO, EMAIL_SEND_FROM, "Transcoding started for file" + fileName.replace('_','-').replace('/','-'), outputRemoteDIR+fileName)
# sendEmail(EMAIL_SEND_TO, EMAIL_SEND_FROM, "Transcoding started for file" , outputRemoteDIR+fileName)
try:enter code here
rv = subprocess.check_call(COMMAND, shell=True)
# if (rv !=0):
# sendEmail(EMAIL_SEND_TO, EMAIL_SEND_FROM, "Transcoding Failed for a file", outputRemoteDIR+fileName)
except Exception as e:
logger.error("Transcoding Failed for a file :- " + outputRemoteDIR+fileName);
# sendEmail(EMAIL_SEND_TO, EMAIL_SEND_FROM, "Transcoding Failed for a file", outputRemoteDIR+fileName+"\n contact dev@example.com")
return True
def setupDB(self):
self.db = sqlite3.connect('automator.db', detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES)
sql = "create table if not exists last_smil_check (last_check_time int)"
self.db.execute(sql)
self.db.commit()
sql = "create table if not exists last_mediafile_check(last_check_time int)"
self.db.execute(sql)
self.db.commit()
def fetchlastCheckTime(self):
cursor = self.db.execute("select * from last_smil_check")
count = 0
for row in cursor:
logger.info(row)
count = count+1
self.lastSMILFileCheckTime = row[0]
self.newlastSMILFileCheckTime = self.lastSMILFileCheckTime
cursor = self.db.execute("select * from last_mediafile_check")
count = 0
for row in cursor:
logger.info(row)
count = count+1
self.lastMediaFileCheckTime = row[0]
self.newLastMediaFileCheckTime = self.lastMediaFileCheckTime
def updatelastCheckTimes(self):
self.lastSMILFileCheckTime = self.newlastSMILFileCheckTime
self.lastMediaFileCheckTime = self.newLastMediaFileCheckTime
cursor = self.db.execute("select * from last_smil_check")
count = 0
for row in cursor:
count = count +1
if(count == 0):
sql_query = "insert into last_smil_check values ({})".format(self.lastSMILFileCheckTime)
logger.info("Executing " + sql_query)
self.db.execute(sql_query)
else:
self.db.execute("update last_smil_check set last_check_time ={}".format(self.lastSMILFileCheckTime))
self.db.commit()
cursor = self.db.execute("select * from last_mediafile_check")
logger.info(cursor)
count = 0
for row in cursor:
count = count +1
if(count == 0):
sql_query = "insert into last_mediafile_check values ({})".format(self.lastMediaFileCheckTime)
logger.info("Executing " + sql_query)
self.db.execute(sql_query)
else:
sql_query = "update last_mediafile_check set last_check_time ={}".format(self.lastMediaFileCheckTime)
logger.info("Executing " + sql_query)
self.db.execute(sql_query)
self.db.commit()
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
automator = Automator()
automator.start()
enter code here -
ffmpeg.exe not detecting UScreenCapture
14 janvier 2021, par TenGI have two version of ffmpeg on the Windows 7 PC.


The first came installed with an application, which uses ffmpeg to capture video/audio of the desktop. This works.


It uses an older version of ffmpeg, so I downloaded the latest version and tried the same command and it reports that the devices are not detected.


Commands run :


Old FFMPEG :


ffmpeg.exe -list_devices true -f dshow -i dummy


ffmpeg version N-70358-g047fd98 Copyright (c) 2000-2015 the FFmpeg developers
 built with gcc 4.9.2 (GCC)
 configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-f
rei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --ena
ble-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-
amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-li
btheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --e
nable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklin
k --enable-zlib
 libavutil 54. 19.100 / 54. 19.100
 libavcodec 56. 26.100 / 56. 26.100
 libavformat 56. 23.106 / 56. 23.106
 libavdevice 56. 4.100 / 56. 4.100
 libavfilter 5. 11.102 / 5. 11.102
 libswscale 3. 1.101 / 3. 1.101
 libswresample 1. 1.100 / 1. 1.100
 libpostproc 53. 3.100 / 53. 3.100
[dshow @ 04a8a500] DirectShow video devices (some may be both video and audio devices)
[dshow @ 04a8a500] "VF0700 Live! Cam Chat HD"
[dshow @ 04a8a500] Alternative name "@device_pnp_\\?\usb#vid_041e&pid_4088&mi_00#7&b015b04&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c
9223196}\global"
[dshow @ 04a8a500] "UScreenCapture"
[dshow @ 04a8a500] Alternative name "@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\UScreenCapture"
[dshow @ 04a8a500] "screen-capture-recorder"
[dshow @ 04a8a500] Alternative name "@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\{4EA6930A-2C8A-4AE6-A561-56E4B5044439}"
[dshow @ 04a8a500] DirectShow audio devices
[dshow @ 04a8a500] "Microphone (VF0700 Live! Cam Ch"
[dshow @ 04a8a500] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\Microphone (VF0700 Live! Cam Ch"
[dshow @ 04a8a500] "virtual-audio-capturer"
[dshow @ 04a8a500] Alternative name "@device_sw_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\{8E14549B-DB61-4309-AFA1-3578E927E935}"
dummy: Immediate exit requested



New FFMPEG :


ffmpeg version N-100616-gca21cb1e36 Copyright (c) 2000-2021 the FFmpeg developers
 built with gcc 9.3-win32 (GCC) 20200320
 configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --a
rch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv
--enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-open
cl --enable-libvmaf --disable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-li
bdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --enable-libass --enable-libbluray --enable-libmp3lame --enable-li
bopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --en
able-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-
libsvtav1 --enable-libtwolame --enable-libuavs3d --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-li
bxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
 libavutil 56. 63.100 / 56. 63.100
 libavcodec 58.116.100 / 58.116.100
 libavformat 58. 65.101 / 58. 65.101
 libavdevice 58. 11.103 / 58. 11.103
 libavfilter 7. 95.100 / 7. 95.100
 libswscale 5. 8.100 / 5. 8.100
 libswresample 3. 8.100 / 3. 8.100
 libpostproc 55. 8.100 / 55. 8.100
[dshow @ 000000000052cc00] DirectShow video devices (some may be both video and audio devices)
[dshow @ 000000000052cc00] "VF0700 Live! Cam Chat HD"
[dshow @ 000000000052cc00] Alternative name "@device_pnp_\\?\usb#vid_041e&pid_4088&mi_00#7&b015b04&0&0000#{65e8773d-8f56-11d0-a3
b9-00a0c9223196}\global"
[dshow @ 000000000052cc00] DirectShow audio devices
[dshow @ 000000000052cc00] "Microphone (VF0700 Live! Cam Ch"
[dshow @ 000000000052cc00] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\Microphone (VF0700 Live! Cam Ch"
dummy: Immediate exit requested



The new version is not detecting the following :


[dshow @ 04a8a500] "UScreenCapture"
[dshow @ 04a8a500] Alternative name "@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\UScreenCapture"
[dshow @ 04a8a500] "screen-capture-recorder"
[dshow @ 04a8a500] Alternative name "@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\{4EA6930A-2C8A-4AE6-A561-56E4B5044439}"
[dshow @ 04a8a500] "virtual-audio-capturer"
[dshow @ 04a8a500] Alternative name "@device_sw_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\{8E14549B-DB61-4309-AFA1-3578E927E935}"



Why is this ?