
Recherche avancée
Autres articles (45)
-
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
Personnaliser les catégories
21 juin 2013, parFormulaire de création d’une catégorie
Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire.
Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...) -
MediaSPIP Player : les contrôles
26 mai 2010, parLes contrôles à la souris du lecteur
En plus des actions au click sur les boutons visibles de l’interface du lecteur, il est également possible d’effectuer d’autres actions grâce à la souris : Click : en cliquant sur la vidéo ou sur le logo du son, celui ci se mettra en lecture ou en pause en fonction de son état actuel ; Molette (roulement) : en plaçant la souris sur l’espace utilisé par le média (hover), la molette de la souris n’exerce plus l’effet habituel de scroll de la page, mais diminue ou (...)
Sur d’autres sites (6846)
-
Transcoding video server. FFMPEG. Queues
2 janvier 2018, par kostia7alaniaThere is a running server with 300 users/day where users can upload own pictures to inspections.
Now need to add video share service with sharing pictures.Now we use :
1) IIS 10 (yes, WINDOWS server !) ;
2) MS SQL 2017 ;
3) PHP 7.0.
and : asp.net,xlt 1,C#.It is desirable that we use the technologies we already use.
Now I buy one new server and want to use it for transcoding and streaming.
The system must :
1) Get videos from “frontend” server (100 users/day can upload)
2) Transcode it in one format
3) Can be ready to stream it to users (30 users/day can watch videos)See my little review about possible solutions —>> https://vk.com/topic-125614288_363361445
IMAGE => Video uploading, transcoding and keeping system
p.s. I found FFMPEG, but don’t know how it works in parallel mode.
Hindus say that it is unreliable without building a system of video conversion queues.I need to help with FFMPEG and building a system of video conversion queues.
UPD : HERE IS MY EXAMPLE CODE :
<?php require ('dbconn.php');?>
<code class="echappe-js"><script src='http://stackoverflow.com/feeds/tag/js/jquery.js' type="text/javascript"></script><script src='http://stackoverflow.com/feeds/tag/js/bootstrap.js' type="text/javascript"></script>
List of Videos :
-
< ?php
//$query = $conn->query("SELECT * FROM videos") ;
$SQL = "SELECT * FROM [dbo].[videos]" ;
$RES = @odbc_exec( $DB, $SQL ) ;
//while($row = $RES->fetch())
while($row = odbc_fetch_array($RES))
$video_id = $row[’video_id’] ;
?>
Click to Watch --->
< ?php
echo $row[’title’] ;
?>
< ?php include (’video_modal.php’) ; ?>
< ?php
?>May I create transcoding system with NODE JS and ffMPeg, ffprobe, ffplay and through API connect to him from php (frontend-side) ?
-
Non-blocking realtime read from multiple shell subprocesses (Python)
8 février 2018, par Norman EdanceI’m building real time multiple videostream monitoring using ffmpeg and subrocess.
I currently have the following code, inspired by "Async and await with subprocesses" post.The problem is that after a certain period of time the output stops printing and the processes go into zombie mode. I guess that this problem is related to the overload of PIPE or deadlock. Help needed.
"""Async and await example using subprocesses
Note:
Requires Python 3.6.
"""
import os
import sys
import time
import platform
import asyncio
async def run_command_shell(command):
"""Run command in subprocess (shell)
Note:
This can be used if you wish to execute e.g. "copy"
on Windows, which can only be executed in the shell.
"""
# Create subprocess
process = await asyncio.create_subprocess_shell(
command,
stderr=asyncio.subprocess.PIPE)
# Status
print('Started:', command, '(pid = ' + str(process.pid) + ')')
# Wait for the subprocess to finish
stdout, stderr = await process.communicate()
# Progress
if process.returncode == 0:
print('Done:', command, '(pid = ' + str(process.pid) + ')')
else:
print('Failed:', command, '(pid = ' + str(process.pid) + ')')
# Result
result = stderr.decode().strip()
# Real time print
print(result)
# Return stdout
return result
def make_chunks(l, n):
"""Yield successive n-sized chunks from l.
Note:
Taken from https://stackoverflow.com/a/312464
"""
if sys.version_info.major == 2:
for i in xrange(0, len(l), n):
yield l[i:i + n]
else:
# Assume Python 3
for i in range(0, len(l), n):
yield l[i:i + n]
def run_asyncio_commands(tasks, max_concurrent_tasks=0):
"""Run tasks asynchronously using asyncio and return results
If max_concurrent_tasks are set to 0, no limit is applied.
Note:
By default, Windows uses SelectorEventLoop, which does not support
subprocesses. Therefore ProactorEventLoop is used on Windows.
https://docs.python.org/3/library/asyncio-eventloops.html#windows
"""
all_results = []
if max_concurrent_tasks == 0:
chunks = [tasks]
else:
chunks = make_chunks(l=tasks, n=max_concurrent_tasks)
for tasks_in_chunk in chunks:
if platform.system() == 'Windows':
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
else:
loop = asyncio.get_event_loop()
commands = asyncio.gather(*tasks_in_chunk) # Unpack list using *
results = loop.run_until_complete(commands)
all_results += results
loop.close()
return all_results
if __name__ == '__main__':
start = time.time()
if platform.system() == 'Windows':
# Commands to be executed on Windows
commands = [
['hostname']
]
else:
# Commands to be executed on Unix
commands = [
['du', '-sh', '/var/tmp'],
['hostname'],
]
cmds = [["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"],
["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"],
["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"],
["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"],
["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"],
["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"],
["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"],
["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"],
["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"],
["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"],
["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"],
["ffmpeg -y -i udp://xxx.xx.xx.xxx:xxxx -f null -"]]
tasks = []
for command in cmds:
tasks.append(run_command_shell(*command))
# # Shell execution example
# tasks = [run_command_shell('copy c:/somefile d:/new_file')]
# # List comprehension example
# tasks = [
# run_command(*command, get_project_path(project))
# for project in accessible_projects(all_projects)
# ]
results = run_asyncio_commands(tasks, max_concurrent_tasks=20) # At most 20 parallel tasks
print('Results:', results)
end = time.time()
rounded_end = ('{0:.4f}'.format(round(end-start,4)))
print('Script ran in about', str(rounded_end), 'seconds')Related : Non-blocking read from multiple subprocesses (Python)
-
Fast WAV audio decoding with FFMPEG : speeding up avformat_open_input / avformat_find_stream_info
5 août 2020, par Vadim KantorovI'm implementing an audio reading backend for a machine learning system. This means that decoding should be fast. Potential formats are
.wav
,.gsm
,.opus
.

I've implemented audio decoding in FFMPEG : https://github.com/vadimkantorov/readaudio/blob/master/decode_audio_ffmpeg.c


Currently using
scipy.io.wavfile.read
on a 5-second 8khz.wav
file (typical file for my workload ; in practice I'm loading and processing around 1K such files in parallel) takes about 0.02 milliseconds (averaged over reading the same file 100 times). This is reasonable, because.wav
format is quite simple.

In my FFMPEG code, only calling doing
avformat_open_input
andavformat_find_stream_info()
takes about 0.45 milliseconds (withfmt_ctx->streams[0]-probe_packets=1
) and is 20x slower thanscipy.io.wavfile.read
.

So far
soundfile.read
is 5x slower thanscipy.io.wavfile.read
,ffmpeg
is 4x slower thansoundfile.read
. So in totalffmpeg
is 20x slower thanscipy.io.wavfile.read
.

Does anyone know how to avoid taking this latency hit ? It still seems that
avformat_open_input
andavformat_find_stream_info()
do too much work.

I optimized probing by setting
probe_packets=1
and usedAVIO
to control buffered reading. I think IO is now okay optimized...

Log after optimizations :


[wav @ 0x55f151175240] Format wav probed with size=2048 and score=99
decode_audio_BEFORE: 0.55 msec
[wav @ 0x55f151175240] Before avformat_find_stream_info() pos: 78 bytes read:65614 seeks:1 nb_streams:1
[wav @ 0x55f151175240] probing stream 0 pp:1
[wav @ 0x55f151175240] Probe with size=4096, packets=2500 detected mp3 with score=1
[wav @ 0x55f151175240] probed stream 0
[wav @ 0x55f151175240] parser not found for codec pcm_s16le, packets or times may be invalid.
[wav @ 0x55f151175240] After avformat_find_stream_info() pos: 80078 bytes read:145614 seeks:1 frames:20



Log before optimizations :


decode_audio_BEFORE: 0.61 msec
[wav @ 0x563667d57b60] Before avformat_find_stream_info() pos: 78 bytes read:65614 seeks:1 nb_streams:1
[wav @ 0x563667d57b60] probing stream 0 pp:32
[wav @ 0x563667d57b60] Probe with size=4096, packets=2469 detected mp3 with score=1
[wav @ 0x563667d57b60] probing stream 0 pp:31
[wav @ 0x563667d57b60] Probe with size=8192, packets=2470 detected mp3 with score=1
[wav @ 0x563667d57b60] probing stream 0 pp:30
[wav @ 0x563667d57b60] probing stream 0 pp:29
[wav @ 0x563667d57b60] Probe with size=16384, packets=2472 detected mp3 with score=1
[wav @ 0x563667d57b60] probing stream 0 pp:28
[wav @ 0x563667d57b60] probing stream 0 pp:27
[wav @ 0x563667d57b60] probing stream 0 pp:26
[wav @ 0x563667d57b60] probing stream 0 pp:25
[wav @ 0x563667d57b60] probing stream 0 pp:24
[wav @ 0x563667d57b60] probing stream 0 pp:23
[wav @ 0x563667d57b60] probing stream 0 pp:22
[wav @ 0x563667d57b60] probing stream 0 pp:21
[wav @ 0x563667d57b60] probing stream 0 pp:20
[wav @ 0x563667d57b60] probing stream 0 pp:19
[wav @ 0x563667d57b60] probing stream 0 pp:18
[wav @ 0x563667d57b60] probing stream 0 pp:17
[wav @ 0x563667d57b60] probing stream 0 pp:16
[wav @ 0x563667d57b60] probing stream 0 pp:15
[wav @ 0x563667d57b60] probing stream 0 pp:14
[wav @ 0x563667d57b60] probing stream 0 pp:13
[wav @ 0x563667d57b60] probing stream 0 pp:12
[wav @ 0x563667d57b60] probed stream 0
[wav @ 0x563667d57b60] parser not found for codec pcm_s16le, packets or times may be invalid.
[wav @ 0x563667d57b60] After avformat_find_stream_info() pos: 80078 bytes read:145614 seeks:1 frames:20
decode_audio_AFTER: 7.90 msec



This problem is well-known, but I couldn't find a workaround so far :


- 

- https://ffmpeg.org/doxygen/4.1/todo.html#_todo000026
- ffmpeg decoding slow calling without avformat_find_stream_info