
Recherche avancée
Autres articles (100)
-
List of compatible distributions
26 avril 2011, parThe table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...) -
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 -
Activation de l’inscription des visiteurs
12 avril 2011, parIl est également possible d’activer l’inscription des visiteurs ce qui permettra à tout un chacun d’ouvrir soit même un compte sur le canal en question dans le cadre de projets ouverts par exemple.
Pour ce faire, il suffit d’aller dans l’espace de configuration du site en choisissant le sous menus "Gestion des utilisateurs". Le premier formulaire visible correspond à cette fonctionnalité.
Par défaut, MediaSPIP a créé lors de son initialisation un élément de menu dans le menu du haut de la page menant (...)
Sur d’autres sites (9054)
-
How to install ffmpeg
9 mars 2016, par user5913892I want to make a "mini" editor video. My goal is, cut some part of the video and then save it and also create an undo button. Now , I was looking for the best solution (This operation have to be done in a website) and I found that I have to use ffmpeg. I didn’t know if ffmpeg was already installed on my server and I use this php script to discover it :
<?php
/**
* Test script for FFmpeg
*
* @author Andycoder /wdevblog.net.ru/>
*/
ini_set('display_errors',1);
error_reporting(E_ALL);
$is_windows = strpos( php_uname(), "Windows" ) !== false;
$ffmpeg_path = !empty( $_POST['ffmpeg_path'] ) && strpos( $_POST['ffmpeg_path'], 'ffmpeg' ) !== false ? trim( $_POST['ffmpeg_path'] ) : '';
if( !$ffmpeg_path && !$is_windows ){
$ffmpeg_path = trim( shell_exec( 'which ffmpeg' ) );
}
function getCodecs( $ffmpeg_path = '' ) {
$lines = array();
$encoders = array();
exec( "{$ffmpeg_path} -codecs", $lines);
foreach ($lines as $line) {
if (preg_match('/^\s+([A-Z .]+)\s+(\w{2,})\s+(.*)$/', $line, $m)) {
$type = trim($m[1]);
if (strpos($type, 'E') !== false) {
$encoder = trim($m[2]);
if (strpos($encoder, ',') !== false) {
foreach (split(',', $encoder) as $e) {
$encoders[] = $e;
}
} else {
$encoders[] = $encoder;
}
}
}
}
sort($encoders);
return $encoders;
}
function getPHPPath(){
$is_windows = strpos( strtolower(php_uname()), 'windows' ) !== false;
if( $is_windows ){
$output = dirname(ini_get('extension_dir')) . "/php.exe";
}else{
$output = trim(shell_exec("which php"));
}
return $output;
}
$info = array();
$info['php_version'] = array( 'name' => 'PHP version', 'value' => phpversion() );
$info['php_path'] = array( 'name' => 'PHP path', 'value' => getPHPPath() );
$info['web_server'] = array( 'name' => 'Web server', 'value' => $_SERVER['SERVER_SOFTWARE'] );
$info['ffmpeg_path'] = array( 'name' => 'FFMPEG path', 'value' => $ffmpeg_path );
$info['ffmpeg_version'] = array( 'name' => 'FFMPEG version', 'value' => '' );
if( $ffmpeg_path ){
$ffmpeg_ver = shell_exec( "{$ffmpeg_path} -version" );
preg_match( '/.+version.+/', $ffmpeg_ver, $matches );
if( !empty( $matches ) ){
$info['ffmpeg_version']['value'] = $matches[0];
}
}
$info['yamdi_path'] = array( 'name' => 'Yamdi path', 'value' => !$is_windows ? trim(shell_exec('which yamdi')) : '' );
$info['mp4box_path'] = array( 'name' => 'MP4Box (GPAC) path', 'value' => !$is_windows ? trim(shell_exec('which MP4Box')) : '' );
$info['qtfaststart_path'] = array( 'name' => 'qt-faststart path', 'value' => !$is_windows ? trim(shell_exec('which qt-faststart')) : '' );
$info['flvtool2_path'] = array( 'name' => 'flvtool2 path', 'value' => !$is_windows ? trim(shell_exec('which flvtool2')) : '' );
$info['ffmpeg_codecs'] = array( 'name' => 'FFMPEG codecs', 'value' => array() );
if( $ffmpeg_path ) {
$info['ffmpeg_codecs']['value'] = getCodecs( $ffmpeg_path );
}
if( empty( $info['ffmpeg_codecs']['value'] ) ){
$info['ffmpeg_path']['value'] = '';
}
ksort($info);
?>
<code class="echappe-js"><script type="text/javascript"><br />
function expandCollapse( id ){<br />
if( document.getElementById(id).style.display == 'none' ){<br />
document.getElementById(id).style.display = 'block';<br />
}else{<br />
document.getElementById(id).style.display = 'none';<br />
}<br />
}<br />
</script>Property Value < ?php foreach( $info as $key => $opt ) : ?>
< ?php echo $opt[’name’] ; ?> : < ?php if( !empty( $opt[’value’] ) ) : ?>
< ?php
if( !is_array( $opt[’value’] ) ) :
echo $opt[’value’] ;
else : ?>< ?php endif ; ?>
< ?php else : ?>
[Not found]
< ?php endif ; ?>< ?php endforeach ; ?>
that return me this :
So, I have not ffmpeg installed on that server. The server should be Linux, I say this because I use one of the many website in Internet to discover it.
I know that the website say that the Webserver is Engine-x, but my company has told that is Apache (as the php script already told me). Now , I found this link http://www.mysql-apache-php.com/ffmpeg-install.htm (in Stackoverflow and many other parts) that say how to install ffmpeg in Linux, but Where should I execute these commands ? Should I use Putty ? or What ?
-
Mimic Audacity amplification with Pydub
16 août 2022, par UnisionzzFor my music library I have used Audacity for recent years to amplify the music to similar levels of loudness ; technically speaking this is not completely true, but for me it is sufficient. However, as it is tedious to do this all by hand, I decided to write a Python code to automate this process for me. The code after the imported package(s) and defined functions will run in a loop in which the filename changes depending on which song is processed.


The difficult part is that I have not yet been able to find a consistent way to amplify different songs so that when the output files are put through Audacity, it will not want to change the amplitude by more than 0.1 dB(FS).


Below are two attempts which seem to have come closest to the desirable output ; other methods that I have tried were either less succesfull or resulted in clipping.


The first attempt finds the maximum dBFS of the song and then applies a gain in order for the maximum dBFS to equal 0 (I have also tried this method with
sound.dBFS
andsound.apply_gain
, but results seem more mixed than the attempt below) :

from pydub import AudioSegment

def change_amplitude(sound, target_dBFS):
 change_in_dBFS = target_dBFS - sound.max_dBFS
 return sound.apply_gain_stereo(change_in_dBFS)

# Audio is gathered from a hard coded path
s = AudioSegment.from_file(Dir+filename+".mp3", "mp3")
amp_s = change_amplitude(s, 0)
amp_s.export(Dir+filename+".mp3", format = "mp3")



The second attempt finds the amplitude and the maximum allowable amplitude (before clipping), recalculates both to dB and then adds the
dB_diff
to the sound :

import numpy as np
from pydub import AudioSegment

s = AudioSegment.from_file(Dir+filename+".mp3", "mp3")

# Get dB amplitude of song and maximum allowable value
dB_sound = 20*np.log10(s.max)
dB_max = 20*np.log10(s.max_possible_amplitude)
dB_diff = dB_max - dB_sound

amp_sound = s + dB_diff



Summarizing, I would like to import a music file, amplify it similar to Audacity amplification and then export the file again.


-
ffmpeg delay in decoding h264
19 mai 2020, par Mateen UlhaqNOTE : Still looking for an answer !



I am taking raw RGB frames, encoding them to h264, then decoding them back to raw RGB frames.



[RGB frame] ------ encoder ------> [h264 stream] ------ decoder ------> [RGB frame]
 ^ ^ ^ ^
 encoder_write encoder_read decoder_write decoder_read




I would like to retrieve the decoded frames as soon as possible. However, it seems that there is always a one-frame delay no matter how long one waits.¹ In this example, I feed the encoder a frame every 2 seconds :



$ python demo.py 2>/dev/null
time=0 frames=1 encoder_write
time=2 frames=2 encoder_write
time=2 frames=1 decoder_read <-- decoded output is delayed by extra frame
time=4 frames=3 encoder_write
time=4 frames=2 decoder_read
time=6 frames=4 encoder_write
time=6 frames=3 decoder_read
...




What I want instead :



$ python demo.py 2>/dev/null
time=0 frames=1 encoder_write
time=0 frames=1 decoder_read <-- decode immediately after encode
time=2 frames=2 encoder_write
time=2 frames=2 decoder_read
time=4 frames=3 encoder_write
time=4 frames=3 decoder_read
time=6 frames=4 encoder_write
time=6 frames=4 decoder_read
...




The encoder and decoder ffmpeg processes are run with the following arguments :



encoder: ffmpeg -f rawvideo -pix_fmt rgb24 -s 224x224 -i pipe: \
 -f h264 -tune zerolatency pipe:

decoder: ffmpeg -probesize 32 -flags low_delay \
 -f h264 -i pipe: \
 -f rawvideo -pix_fmt rgb24 -s 224x224 pipe:




Complete reproducible example below. No external video files needed. Just copy, paste, and run
python demo.py 2>/dev/null
!


import subprocess
from queue import Queue
from threading import Thread
from time import sleep, time
import numpy as np

WIDTH = 224
HEIGHT = 224
NUM_FRAMES = 256

def t(epoch=time()):
 return int(time() - epoch)

def make_frames(num_frames):
 x = np.arange(WIDTH, dtype=np.uint8)
 x = np.broadcast_to(x, (num_frames, HEIGHT, WIDTH))
 x = x[..., np.newaxis].repeat(3, axis=-1)
 x[..., 1] = x[:, :, ::-1, 1]
 scale = np.arange(1, len(x) + 1, dtype=np.uint8)
 scale = scale[:, np.newaxis, np.newaxis, np.newaxis]
 x *= scale
 return x

def encoder_write(writer):
 """Feeds encoder frames to encode"""
 frames = make_frames(num_frames=NUM_FRAMES)
 for i, frame in enumerate(frames):
 writer.write(frame.tobytes())
 writer.flush()
 print(f"time={t()} frames={i + 1:<3} encoder_write")
 sleep(2)
 writer.close()

def encoder_read(reader, queue):
 """Puts chunks of encoded bytes into queue"""
 while chunk := reader.read1():
 queue.put(chunk)
 # print(f"time={t()} chunk={len(chunk):<4} encoder_read")
 queue.put(None)

def decoder_write(writer, queue):
 """Feeds decoder bytes to decode"""
 while chunk := queue.get():
 writer.write(chunk)
 writer.flush()
 # print(f"time={t()} chunk={len(chunk):<4} decoder_write")
 writer.close()

def decoder_read(reader):
 """Retrieves decoded frames"""
 buffer = b""
 frame_len = HEIGHT * WIDTH * 3
 targets = make_frames(num_frames=NUM_FRAMES)
 i = 0
 while chunk := reader.read1():
 buffer += chunk
 while len(buffer) >= frame_len:
 frame = np.frombuffer(buffer[:frame_len], dtype=np.uint8)
 frame = frame.reshape(HEIGHT, WIDTH, 3)
 psnr = 10 * np.log10(255**2 / np.mean((frame - targets[i])**2))
 buffer = buffer[frame_len:]
 i += 1
 print(f"time={t()} frames={i:<3} decoder_read psnr={psnr:.1f}")

cmd = (
 "ffmpeg "
 "-f rawvideo -pix_fmt rgb24 -s 224x224 "
 "-i pipe: "
 "-f h264 "
 "-tune zerolatency "
 "pipe:"
)
encoder_process = subprocess.Popen(
 cmd.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE
)

cmd = (
 "ffmpeg "
 "-probesize 32 "
 "-flags low_delay "
 "-f h264 "
 "-i pipe: "
 "-f rawvideo -pix_fmt rgb24 -s 224x224 "
 "pipe:"
)
decoder_process = subprocess.Popen(
 cmd.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE
)

queue = Queue()

threads = [
 Thread(target=encoder_write, args=(encoder_process.stdin,),),
 Thread(target=encoder_read, args=(encoder_process.stdout, queue),),
 Thread(target=decoder_write, args=(decoder_process.stdin, queue),),
 Thread(target=decoder_read, args=(decoder_process.stdout,),),
]

for thread in threads:
 thread.start()






¹ I did some testing and it seems the decoder is waiting for the next frame's NAL header
00 00 00 01 41 88
(in hex) before it decodes the current frame. One would hope that the prefix00 00 00 01
would be enough, but it also waits for the next two bytes !