Recherche avancée

Médias (0)

Mot : - Tags -/clipboard

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (74)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

Sur d’autres sites (14347)

  • swscale/vscale : Increase type strictness

    26 avril 2020, par Andreas Rheinhardt
    swscale/vscale : Increase type strictness
    

    libswscale/vscale.c makes extensive use of function pointers and in
    doing so it converts these function pointers to and from a pointer to
    void. Yet this is actually against the C standard :
    C90 only guarantees that one can convert a pointer to any incomplete
    type or object type to void* and back with the result comparing equal
    to the original which makes pointers to void generic pointers to
    incomplete or object type. Yet C90 lacks a generic function pointer
    type.
    C99 additionally guarantees that a pointer to a function of one type may
    be converted to a pointer to a function of another type with the result
    and the original comparing equal when converting back.
    This makes any function pointer type a generic function pointer type.
    Yet even this does not make pointers to void generic function pointers.

    Both GCC and Clang emit warnings for this when in pedantic mode.

    This commit fixes this by using a union that can hold one member of any
    of the required function pointer types to store the function pointer.
    This works even for C90.

    Reviewed-by : Michael Niedermayer <michael@niedermayer.cc>
    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@gmail.com>

    • [DH] libswscale/vscale.c
  • Icecast : always send a content-type

    11 novembre 2014, par Marvin Scholz
    Icecast : always send a content-type
    

    use a default (audio/mpeg for historical reason) if none. Required since Icecast 2.4.1
    Not using AVOption default because this breaks content-type warnings (needs to
    detect if no type was set by the user)

    Signed-off-by : Michael Niedermayer <michaelni@gmx.at>

    • [DH] libavformat/icecast.c
  • Using PyAV to encode mono audio to file, params match docs, but still causes Errno 22

    20 février 2023, par andrew8088

    While trying to use PyAV to encode live mono audio from a microphone to a compressed audio stream (using mp2 or flac as encoder), the program kept raising an exception ValueError: [Errno 22] Invalid argument.

    &#xA;

    To remove the live microphone source as a cause of the problem, and to make the problematic code easier for others to run/test, I have removed the mic source and now just generate a pure tone as a sequence of input buffers.

    &#xA;

    All attempts to figure out the missing or mismatched or incorrect argument have just resulted in seeing documentation and examples that are the same as my code.

    &#xA;

    I would like to know from someone who has used PyAV successfully for mono audio what the correct method and parameters are for encoding mono frames into the mono stream.

    &#xA;

    The package used is av 10.0.0 installed with&#xA;pip3 install av --no-binary av&#xA;so it uses my package-manager provided ffmpeg library, which is version 4.2.7.

    &#xA;

    The problematic python code is :

    &#xA;

    #!/usr/bin/env python3&#xA;# -*- coding: utf-8 -*-&#xA;"""&#xA;Recreating an error 22 when encoding sound with PyAV.&#xA;&#xA;Created on Sun Feb 19 08:10:29 2023&#xA;@author: andrewm&#xA;"""&#xA;import typing&#xA;import sys&#xA;import math&#xA;import fractions&#xA;&#xA;import av&#xA;from av import AudioFrame&#xA;&#xA;""" Ensure some PyAudio constants are still defined without changing &#xA;    the PyAudio recording callback function and without depending &#xA;    on PyAudio simply for reproducing the PyAV bug [Errno 22] thrown in &#xA;    File "av/filter/context.pyx", line 89, in av.filter.context.FilterContext.push&#xA;"""&#xA;class PA_Stub():&#xA;    paContinue = True&#xA;    paComplete= False&#xA;&#xA;pyaudio = PA_Stub()&#xA;&#xA;&#xA;"""Generate pure tone at given frequency with amplitude 0...1.0 at &#xA;   sampling frewuency fs and beginning at phase offset &#x27;phase&#x27;.&#xA;   Returns the new phase after the sinusoid has cycled over the &#xA;   sampling window length.&#xA;"""&#xA;def generate_tone(&#xA;        freq:int, phase:float, amp:float, fs, samp_fmt, buffer:bytearray&#xA;) -> float:&#xA;    assert samp_fmt == "s16", "Only s16 supported atm"&#xA;    samp_size_bytes = 2&#xA;    n_samples = int(len(buffer)/samp_size_bytes)&#xA;    window = [int(0) for i in range(n_samples)]&#xA;    theta = phase&#xA;    phase_inc = 2*math.pi * freq / fs&#xA;    for i in range(n_samples):&#xA;        v = amp * math.sin(theta)&#xA;        theta &#x2B;= phase_inc&#xA;        s = int((2**15-1)*v)&#xA;        window[i] = s&#xA;    for sample_i in range(len(window)):&#xA;        byte_i = sample_i * samp_size_bytes&#xA;        enc = window[sample_i].to_bytes(&#xA;                2, byteorder=sys.byteorder, signed=True&#xA;        )&#xA;        buffer[byte_i] = enc[0]&#xA;        buffer[byte_i&#x2B;1] = enc[1]&#xA;    return theta&#xA;&#xA;&#xA;channels = 1&#xA;fs = 44100  # Record at 44100 samples per second&#xA;fft_size_samps = 256&#xA;chunk_samps = fft_size_samps * 10  # Record in chunks that are multiples of fft windows.&#xA;&#xA;# print(f"fft_size_samps={fft_size_samps}\nchunk_samps={chunk_samps}")&#xA;&#xA;seconds = 3.0&#xA;out_filename = "testoutput.wav"&#xA;&#xA;# Store data in chunks for 3 seconds&#xA;sample_limit = int(fs * seconds)&#xA;sample_len = 0&#xA;frames = []  # Initialize array to store frames&#xA;&#xA;ffmpeg_codec_name = &#x27;mp2&#x27;  # flac, mp3, or libvorbis make same error.&#xA;&#xA;sample_size_bytes = 2&#xA;buffer = bytearray(int(chunk_samps*sample_size_bytes))&#xA;chunkperiod = chunk_samps / fs&#xA;total_chunks = int(math.ceil(seconds / chunkperiod))&#xA;phase = 0.0&#xA;&#xA;### uncomment if you want to see the synthetic data being used as a mic input.&#xA;# with open("test.raw","wb") as raw_out:&#xA;#     for ci in range(total_chunks):&#xA;#         phase = generate_tone(2600, phase, 0.8, fs, "s16", buffer)&#xA;#         raw_out.write(buffer)&#xA;# print("finished gen test")&#xA;# sys.exit(0)&#xA;# #---- &#xA;&#xA;# Using mp2 or mkv as the container format gets the same error.&#xA;with av.open(out_filename&#x2B;&#x27;.mp2&#x27;, "w", format="mp2") as output_con:&#xA;    output_con.metadata["title"] = "My title"&#xA;    output_con.metadata["key"] = "value"&#xA;    channel_layout = "mono"&#xA;    sample_fmt = "s16p"&#xA;&#xA;    ostream = output_con.add_stream(ffmpeg_codec_name, fs, layout=channel_layout)&#xA;    assert ostream is not None, "No stream!"&#xA;    cctx = ostream.codec_context&#xA;    cctx.sample_rate = fs&#xA;    cctx.time_base = fractions.Fraction(numerator=1,denominator=fs)&#xA;    cctx.format = sample_fmt&#xA;    cctx.channels = channels&#xA;    cctx.layout = channel_layout&#xA;    print(cctx, f"layout#{cctx.channel_layout}")&#xA;    &#xA;    # Define PyAudio-style callback for recording plus PyAV transcoding.&#xA;    def rec_callback(in_data, frame_count, time_info, status):&#xA;        global sample_len&#xA;        global ostream&#xA;        frames.append(in_data)&#xA;        nsamples = int(len(in_data) / (channels*sample_size_bytes))&#xA;        &#xA;        frame = AudioFrame(format=sample_fmt, layout=channel_layout, samples=nsamples)&#xA;        frame.sample_rate = fs&#xA;        frame.time_base = fractions.Fraction(numerator=1,denominator=fs)&#xA;        frame.pts = sample_len&#xA;        frame.planes[0].update(in_data)&#xA;        print(frame, len(in_data))&#xA;        &#xA;        for out_packet in ostream.encode(frame):&#xA;            output_con.mux(out_packet)&#xA;        for out_packet in ostream.encode(None):&#xA;            output_con.mux(out_packet)&#xA;        &#xA;        sample_len &#x2B;= nsamples&#xA;        retflag = pyaudio.paContinue if sample_lencode>

    &#xA;

    If you uncomment the RAW output part you will find the generated data can be imported as PCM s16 Mono 44100Hz into Audacity and plays the expected tone, so the generated audio data does not seem to be the problem.

    &#xA;

    The normal program console output up until the exception is :

    &#xA;

    mp2 at 0x7f8e38202cf0> layout#4&#xA;Beginning&#xA; 5120&#xA;. 5120&#xA;

    &#xA;

    The stack trace is :

    &#xA;

    Traceback (most recent call last):&#xA;&#xA;  File "Dev/multichan_recording/av_encode.py", line 147, in <module>&#xA;    ret_data, ret_flag = rec_callback(buffer, ci, {}, 1)&#xA;&#xA;  File "Dev/multichan_recording/av_encode.py", line 121, in rec_callback&#xA;    for out_packet in ostream.encode(frame):&#xA;&#xA;  File "av/stream.pyx", line 153, in av.stream.Stream.encode&#xA;&#xA;  File "av/codec/context.pyx", line 484, in av.codec.context.CodecContext.encode&#xA;&#xA;  File "av/audio/codeccontext.pyx", line 42, in av.audio.codeccontext.AudioCodecContext._prepare_frames_for_encode&#xA;&#xA;  File "av/audio/resampler.pyx", line 101, in av.audio.resampler.AudioResampler.resample&#xA;&#xA;  File "av/filter/graph.pyx", line 211, in av.filter.graph.Graph.push&#xA;&#xA;  File "av/filter/context.pyx", line 89, in av.filter.context.FilterContext.push&#xA;&#xA;  File "av/error.pyx", line 336, in av.error.err_check&#xA;&#xA;ValueError: [Errno 22] Invalid argument&#xA;&#xA;</module>

    &#xA;

    edit : It's interesting that the error happens on the 2nd AudioFrame, as apparently the first one was encoded okay, because they are given the same attribute values aside from the Presentation Time Stamp (pts), but leaving this out and letting PyAV/ffmpeg generate the PTS by itself does not fix the error, so an incorrect PTS does not seem the cause.

    &#xA;

    After a brief glance in av/filter/context.pyx the exception must come from a bad return value from res = lib.av_buffersrc_write_frame(self.ptr, frame.ptr)
    &#xA;Trying to dig into av_buffersrc_write_frame from the ffmpeg source it is not clear what could be causing this error. The only obvious one is a mismatch between channel layouts, but my code is setting the layout the same in the Stream and the Frame. That problem had been found by an old question pyav - cannot save stream as mono and their answer (that one parameter required is undocumented) is the only reason the code now has the layout='mono' argument when making the stream.

    &#xA;

    The program output shows layout #4 is being used, and from https://github.com/FFmpeg/FFmpeg/blob/release/4.2/libavutil/channel_layout.h you can see this is the value for symbol AV_CH_FRONT_CENTER which is the only channel in the MONO layout.

    &#xA;

    The mismatch is surely some other object property or an undocumented parameter requirement.

    &#xA;

    How do you encode mono audio to a compressed stream with PyAV ?

    &#xA;