Recherche avancée

Médias (91)

Autres articles (94)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

Sur d’autres sites (6330)

  • Revision 730cdefd3e : Add SVC codec control to set frame flags and buffer indices. Add SVC codec cont

    2 septembre 2015, par Marco

    Changed Paths :
     Modify /examples/vp9_spatial_svc_encoder.c


     Modify /vp9/encoder/vp9_svc_layercontext.c


     Modify /vp9/encoder/vp9_svc_layercontext.h


     Modify /vp9/vp9_cx_iface.c


     Modify /vpx/src/svc_encodeframe.c


     Modify /vpx/vp8cx.h



    Add SVC codec control to set frame flags and buffer indices.

    Add SVC codec control to set the frame flags and buffer indices
    for each spatial layer of the current (super)frame to be encoded.
    This allows the application to set (and change on the fly) the
    reference frame configuration for spatial layers.

    Added an example layer pattern (spatial and temporal layers)
    in vp9_spatial_svc_encoder for the bypass_mode using new control.

    Change-Id : I05f941897cae13fb9275b939d11f93941cb73bee

  • Revision eb53c69ece : Add cyclic refresh parameters to svc-layer context. For 1 pass CBR spatial-SVC :

    8 septembre 2015, par Marco

    Changed Paths :
     Modify /examples/vp9_spatial_svc_encoder.c


     Modify /vp9/encoder/vp9_aq_cyclicrefresh.c


     Modify /vp9/encoder/vp9_encoder.c


     Modify /vp9/encoder/vp9_ratectrl.c


     Modify /vp9/encoder/vp9_svc_layercontext.c


     Modify /vp9/encoder/vp9_svc_layercontext.h


     Modify /vpx/svc_context.h



    Add cyclic refresh parameters to svc-layer context.

    For 1 pass CBR spatial-SVC :
    Add cyclic refresh parameters to the svc-layer context.

    This allows cyclic refresh (aq-mode=3) to be applied to
    the whole super-frame (all spatial layers).
    This gives a performance improvement for spatial layer encoding.

    Addd the aq_mode mode on/off setting as command line option.

    Change-Id : Ib9c3b5ba3cb7851bfb8c37d4f911664bef38e165

  • Get the maximum frequency of an audio spectrum

    6 avril, par milahu

    I want to detect the cutoff frequency of the AAC audio encoder used to compress an M4A audio file.

    


    This cutoff frequency (or maximum frequency) is an indicator of audio quality.
High-quality audio has a cutoff around 20KHz (fullband),
medium-quality audio has a cutoff around 14KHz (superwideband),
low-quality audio has a cutoff around 7KHz (wideband),
super-low-quality audio has a cutoff around 3KHz (narrowband).
See also : voice frequency

    


    Example spectrum of a 2 hours movie, generated with sox, with a maximum frequency around 19.6KHz :

    


    audio spectrum with maximum frequency around 19.6KHz

    


    The program should ignore noise below a certain loudness, for example -80dB.

    


    Here is a Python script generated by deepseek.com but it returns 0.2KHz instead of 19.6KHz.

    


    #!/usr/bin/env python3

# get the maximum frequency
# of an audio spectrum
# as an indicator
# of the actual audio quality

# generated by deepseek.com

# prompt
"""
create a python script
to detect the maximum frequency 
in an m4a audio file.
that maximum frequency is produced
by the lowpass filter
of the aac audio encoder.
high-quality audio
has a maximum frequency
around 20 KHz (fullband),
low-quality audio
has a maximum frequency
around 3 KHz (narrowband).
use ffmpeg to decode the audio
to pcm
in chunks of 10 seconds.
for each chunk:
detect the local maximum,
print the local maximum
and the chunk time
with the format
f"t={t}sec f={f}KHz",
update the global maximum.
to detect the local maximum,
remove the noise floor
around -110dB,
then find the maximum frequency
in the spectrum.
accept some command line options:
--ss n:
pass as "-ss n" to ffmpeg.
--to n:
pass as "-to n" to ffmpeg.
both -ss and -to args
must come before the -i arg
for ffmpeg input seeking.
print all frequencies in KHz.
add a shebang line before the script,
spaced by an empty line.
do not recode the audio with ffmpeg.
use ffprobe to get the input samplerate,
usually 48KHz or 44.1KHz.
create a python class,
so we dont have to pass all parameters to functions.
add a command line option to select the audio track id, by default zero.
"""

#!/usr/bin/env python3

import argparse
import numpy as np
import subprocess
import sys
from tempfile import NamedTemporaryFile


class AudioAnalyzer:
    def __init__(self, input_file, audio_track=0, start_time=None, end_time=None):
        self.input_file = input_file
        self.audio_track = audio_track
        self.start_time = start_time
        self.end_time = end_time
        self.sample_rate = self._get_sample_rate()
        self.global_max_freq = 0
        self.global_max_time = 0

    def _get_sample_rate(self):
        cmd = [
            'ffprobe',
            '-v', 'error',
            '-select_streams', f'a:{self.audio_track}',
            '-show_entries', 'stream=sample_rate',
            '-of', 'default=noprint_wrappers=1:nokey=1',
            self.input_file
        ]
        result = subprocess.run(cmd, capture_output=True, text=True)
        return float(result.stdout.strip())

    def _get_ffmpeg_command(self):
        cmd = [
            'ffmpeg',
            '-hide_banner',
            '-loglevel', 'error',
        ]
        
        if self.start_time is not None:
            cmd.extend(['-ss', str(self.start_time)])
        if self.end_time is not None:
            cmd.extend(['-to', str(self.end_time)])
            
        cmd.extend([
            '-i', self.input_file,
            '-map', f'0:a:{self.audio_track}',
            '-ac', '1',  # convert to mono
            '-f', 'f32le',  # 32-bit float PCM
            '-'
        ])
        
        return cmd

    def analyze(self, chunk_size=10):
        ffmpeg_cmd = self._get_ffmpeg_command()
        
        with subprocess.Popen(ffmpeg_cmd, stdout=subprocess.PIPE) as process:
            chunk_samples = int(chunk_size * self.sample_rate)
            bytes_per_sample = 4  # 32-bit float
            chunk_bytes = chunk_samples * bytes_per_sample
            
            current_time = self.start_time if self.start_time is not None else 0
            
            while True:
                raw_data = process.stdout.read(chunk_bytes)
                if not raw_data:
                    break
                
                samples = np.frombuffer(raw_data, dtype=np.float32)
                if len(samples) == 0:
                    continue
                
                local_max_freq = self._analyze_chunk(samples)
                
                print(f"t={current_time:.1f}sec f={local_max_freq:.1f}KHz")
                
                if local_max_freq > self.global_max_freq:
                    self.global_max_freq = local_max_freq
                    self.global_max_time = current_time
                
                current_time += chunk_size

    def _analyze_chunk(self, samples):
        # Apply Hanning window
        window = np.hanning(len(samples))
        windowed_samples = samples * window
        
        # Compute FFT
        fft = np.fft.rfft(windowed_samples)
        magnitudes = np.abs(fft)
        
        # Convert to dB
        eps = 1e-10  # avoid log(0)
        magnitudes_db = 20 * np.log10(magnitudes + eps)
        
        # Frequency bins
        freqs = np.fft.rfftfreq(len(samples), 1.0 / self.sample_rate) / 1000  # in KHz
        
        # Remove noise floor (-110dB)
        threshold = -110
        valid_indices = magnitudes_db > threshold
        valid_freqs = freqs[valid_indices]
        valid_magnitudes = magnitudes_db[valid_indices]
        
        if len(valid_freqs) == 0:
            return 0
        
        # Find frequency with maximum magnitude
        max_idx = np.argmax(valid_magnitudes)
        max_freq = valid_freqs[max_idx]
        
        return max_freq


def main():
    parser = argparse.ArgumentParser(description='Detect maximum frequency in audio file')
    parser.add_argument('input_file', help='Input audio file (m4a)')
    parser.add_argument('--ss', type=float, help='Start time in seconds')
    parser.add_argument('--to', type=float, help='End time in seconds')
    parser.add_argument('--track', type=int, default=0, help='Audio track ID (default: 0)')
    args = parser.parse_args()

    analyzer = AudioAnalyzer(
        input_file=args.input_file,
        audio_track=args.track,
        start_time=args.ss,
        end_time=args.to
    )
    
    print(f"Analyzing audio file: {args.input_file}")
    print(f"Sample rate: {analyzer.sample_rate/1000:.1f} KHz")
    print(f"Audio track: {args.track}")
    if args.ss is not None:
        print(f"Start time: {args.ss} sec")
    if args.to is not None:
        print(f"End time: {args.to} sec")
    print("---")
    
    analyzer.analyze()
    
    print("---")
    print(f"Global maximum: t={analyzer.global_max_time:.1f}sec f={analyzer.global_max_freq:.1f}KHz")
    
    if analyzer.global_max_freq > 15:
        print("Quality: Fullband (high quality)")
    elif analyzer.global_max_freq > 5:
        print("Quality: Wideband (medium quality)")
    else:
        print("Quality: Narrowband (low quality)")


if __name__ == '__main__':
    main()


    


    Similar question :
How to find the max frequency at a certain db in a fft signal

    



    


    edited by kesh

    


    Here is an example psd indicating the fullband quality with a psd dropoff around 20 kHz.

    


    psd plot