Recherche avancée

Médias (1)

Mot : - Tags -/framasoft

Autres articles (47)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire 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 (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

Sur d’autres sites (14491)

  • Setting UseShellExecute = false doesn't work in Process.Start

    5 décembre 2015, par Alex Jolig

    There’s a good Q&A about hiding shell execute when running a process which led me to write my own code using ffmpeg :

    Process proc = new Process();
    proc.StartInfo.FileName = "ffmpeg";
    proc.StartInfo.Arguments = string.Format("-ss {0} -i \"{1}\" -t {2}{3} DB\\Media\\{4}{5} -y",
        TimeSpan.Parse(row.Cells["StartdgvList"].Value.ToString()),
        openFileDialog.FileName, _durationTime, quality, newTmpSound,
        GetExtension(openFileDialog.FileName));
    proc.StartInfo.RedirectStandardError = true;
    proc.StartInfo.UseShellExecute = false;
    proc.StartInfo.CreateNoWindow = true;
    if (!proc.Start()) return;
    StreamReader reader = proc.StandardError;
    string line;
    while ((line = reader.ReadLine()) != null && !_cancel)
    {
     //Doing something with process line
    }
    proc.Close();

    This works fine, But when I run it in a few user machines, it just stops working with no error.

    I tried removing lines which hides shell window and turned it to this :

    Process proc = new Process();
    proc.StartInfo.FileName = "ffmpeg";
    proc.StartInfo.Arguments = string.Format("-ss {0} -i \"{1}\" -t {2}{3} DB\\Media\\{4}{5} -y",
        TimeSpan.Parse(row.Cells["StartdgvList"].Value.ToString()),
        openFileDialog.FileName, _durationTime, quality, newTmpSound,
        GetExtension(openFileDialog.FileName));
    if (!proc.Start()) return;
    proc.Close();

    and it start working in all the machines.

    I’m wondering if there’s some sort of service or components missing in some machines which makes the process fails when console is hiding.

    I appreciate if anyone has any idea.

    P.S : I installed Visual Studio 2012 on a machine which has problem hiding shell window and it suddenly start working. Maybe VS2012 installed somwthing on the machine which solved the problem.

  • Batch splitting large audio files into small fixed-length audio files in moments of silence

    26 juillet 2023, par Haldjärvi

    to train the SO-VITS-SVC neural network, we need 10-14 second voice files. As a material, let's say I use phrases from some game. I have already made a batch script for decoding different files into one working format, another batch script for removing silence, as well as a batch script for combining small audio files into files of 13-14 seconds (I used Python, pydub and FFmpeg). To successfully automatically create a training dataset, it remains only to make one batch script - Cutting audio files lasting more than 14 seconds into separate files lasting 10-14 seconds, cutting in places of silence or close to silence is highly preferable.

    


    So, it is necessary to batch cut large audio files (20 seconds, 70 seconds, possibly several hundred seconds) into segments of approximately 10-14 seconds, however, the main task is to look for the quietest place in the cut areas so as not to cut phrases in the middle of a word (this is not very good for model training). So, is it really possible to do this in a very optimal way, so that the processing of a 30-second file does not take 15 seconds, but is fast ? Quiet zone detection is required only in the area of cuts, that is, 10-14 seconds, if counted from the very beginning of the file.

    


    I would be very grateful for any help.

    


    I tried to write a script together with ChatGPT, but all options gave completely unpredictable results and were not even close to what I needed... I had to stop at the option with a sharp cut of files for exactly 14000 milliseconds. However, I hope there is a chance to make a variant with cutting exactly in quiet areas.

    


    import os
from pydub import AudioSegment

input_directory = ".../RemSilence/"
output_directory = ".../Split/"
max_duration = 14000

def split_audio_by_duration(input_file, duration):
    audio = AudioSegment.from_file(input_file)
    segments = []
    for i in range(0, len(audio), duration):
        segment = audio[i:i + duration]
        segments.append(segment)
    return segments

if __name__ == "__main__":
    os.makedirs(output_directory, exist_ok=True)
    audio_files = [os.path.join(input_directory, file) for file in os.listdir(input_directory) if file.endswith(".wav")]
    audio_files.sort(key=lambda file: len(AudioSegment.from_file(file)))
    for file in audio_files:
        audio = AudioSegment.from_file(file)
        if len(audio) > max_duration:
            segments = split_audio_by_duration(file, max_duration)
            for i, segment in enumerate(segments):
                output_filename = f"output_{len(os.listdir(output_directory))+1}.wav"
                output_file_path = os.path.join(output_directory, output_filename)
                segment.export(output_file_path, format="wav")
        else:
            output_filename = f"output_{len(os.listdir(output_directory))+1}.wav"
            output_file_path = os.path.join(output_directory, output_filename)
            audio.export(output_file_path, format="wav")


    


  • Segmentation fault caused by FFMPEG / SFML on Macos

    12 avril 2024, par Med ali Damergi ReTr0

    I'm trying to code a basic video player function to use it in a game it's supposed to get a sfml window and a video link as inputs and run the video :

    


    extern "C" {&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;}&#xA;&#xA;#include <sfml></sfml>Graphics.hpp>&#xA;#include <iostream>&#xA;&#xA;const AVCodec* pCodec = nullptr;&#xA;&#xA;&#xA;void lecteurVideo(const std::string&amp; videoPath, sf::RenderWindow&amp; window) {&#xA;    // Open the video file&#xA;    AVFormatContext* pFormatCtx = avformat_alloc_context();&#xA;    if (avformat_open_input(&amp;pFormatCtx, videoPath.c_str(), nullptr, nullptr) != 0) {&#xA;        std::cerr &lt;&lt; "Failed to open video file" &lt;&lt; std::endl;&#xA;        return;&#xA;    }&#xA;&#xA;    // Retrieve stream information&#xA;    if (avformat_find_stream_info(pFormatCtx, nullptr) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Failed to retrieve stream information" &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Find the first video stream&#xA;    int videoStreamIndex = -1;&#xA;    for (unsigned int i = 0; i &lt; pFormatCtx->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {&#xA;            videoStreamIndex = i;&#xA;            break;&#xA;        }&#xA;    }&#xA;    if (videoStreamIndex == -1) {&#xA;        std::cerr &lt;&lt; "Failed to find video stream" &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Get the codec parameters for the video stream&#xA;    AVCodecParameters* pCodecParams = pFormatCtx->streams[videoStreamIndex]->codecpar;&#xA;&#xA;    // Find the decoder for the video stream&#xA;    const AVCodec* pCodec = avcodec_find_decoder(pCodecParams->codec_id);&#xA;    if (pCodec == nullptr) {&#xA;        std::cerr &lt;&lt; "Failed to find video decoder" &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Allocate a codec context for the decoder&#xA;    AVCodecContext* pCodecCtx = avcodec_alloc_context3(pCodec);&#xA;    if (pCodecCtx == nullptr) {&#xA;        std::cerr &lt;&lt; "Failed to allocate codec context" &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Initialize the codec context with the codec parameters&#xA;    if (avcodec_parameters_to_context(pCodecCtx, pCodecParams) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Failed to initialize codec context" &lt;&lt; std::endl;&#xA;        avcodec_free_context(&amp;pCodecCtx);&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Open the codec&#xA;    if (avcodec_open2(pCodecCtx, pCodec, nullptr) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Failed to open codec" &lt;&lt; std::endl;&#xA;        avcodec_free_context(&amp;pCodecCtx);&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Create a frame to hold the decoded video data&#xA;    AVFrame* pFrame = av_frame_alloc();&#xA;    if (pFrame == nullptr) {&#xA;        std::cerr &lt;&lt; "Failed to allocate frame" &lt;&lt; std::endl;&#xA;        avcodec_close(pCodecCtx);&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Create a packet for reading compressed video data&#xA;    AVPacket* pPacket = av_packet_alloc();&#xA;    if (pPacket == nullptr) {&#xA;        std::cerr &lt;&lt; "Failed to allocate packet" &lt;&lt; std::endl;&#xA;        av_frame_free(&amp;pFrame);&#xA;        avcodec_close(pCodecCtx);&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Create a software scaler context for converting the video frame format&#xA;    SwsContext* pSwsCtx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt,&#xA;                                         pCodecCtx->width, pCodecCtx->height, AV_PIX_FMT_RGB24,&#xA;                                         SWS_BILINEAR, nullptr, nullptr, nullptr);&#xA;    if (pSwsCtx == nullptr) {&#xA;        std::cerr &lt;&lt; "Failed to create software scaler context" &lt;&lt; std::endl;&#xA;        av_packet_free(&amp;pPacket);&#xA;        av_frame_free(&amp;pFrame);&#xA;        avcodec_close(pCodecCtx);&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Create an SFML texture and sprite for displaying the video frames&#xA;    sf::Texture texture;&#xA;    sf::Sprite sprite;&#xA;&#xA;    // Read frames from the video file and display them in the SFML window&#xA;    while (av_read_frame(pFormatCtx, pPacket) >= 0) {&#xA;        if (pPacket->stream_index == videoStreamIndex) {&#xA;            // Decode the video packet into a frame&#xA;            if (avcodec_send_packet(pCodecCtx, pPacket) &lt; 0) {&#xA;                std::cerr &lt;&lt; "Failed to send packet to decoder" &lt;&lt; std::endl;&#xA;                break;&#xA;            }&#xA;            if (avcodec_receive_frame(pCodecCtx, pFrame) &lt; 0) {&#xA;                std::cerr &lt;&lt; "Failed to receive frame from decoder" &lt;&lt; std::endl;&#xA;                break;&#xA;            }&#xA;&#xA;            // Convert the frame format to RGB24&#xA;            uint8_t* rgbBuffer = new uint8_t[pCodecCtx->width * pCodecCtx->height * 3];&#xA;            uint8_t* rgbPlanes[1] = { rgbBuffer };&#xA;            int rgbStrides[1] = { pCodecCtx->width * 3 };&#xA;            sws_scale(pSwsCtx, pFrame->data, pFrame->linesize, 0, pCodecCtx->height,&#xA;                      rgbPlanes, rgbStrides);&#xA;&#xA;            // Update the SFML texture with the RGB24 data&#xA;            texture.create(pCodecCtx->width, pCodecCtx->height);&#xA;            texture.update(rgbBuffer);&#xA;&#xA;            // Display the texture in the SFML window&#xA;            sprite.setTexture(texture);&#xA;            window.clear();&#xA;            window.draw(sprite);&#xA;            window.display();&#xA;&#xA;            delete[] rgbBuffer;&#xA;        }&#xA;&#xA;        av_packet_unref(pPacket);&#xA;    }&#xA;&#xA;    // Clean up resources&#xA;    av_packet_free(&amp;pPacket);&#xA;    av_frame_free(&amp;pFrame);&#xA;    avcodec_close(pCodecCtx);&#xA;    avformat_close_input(&amp;pFormatCtx);&#xA;    sws_freeContext(pSwsCtx);&#xA;}&#xA;&#xA;int main() {&#xA;    sf::RenderWindow window(sf::VideoMode(800, 600), "Lecteur Video SFML");&#xA;    lecteurVideo("/Users/mac/cours/spaceRevolution/Videos/58e62585-c143-483a-9149-b401ebc01d02.mp4", window);&#xA;    return 0;&#xA;}&#xA;</iostream>

    &#xA;

    It works on my other computer running on ubuntu but not on my main laptop on macOS : It dosent open any window and instantly cause a segmentation fault.

    &#xA;

    I've tried tu run valgrind on it but valgrind dosent run well on macOS.

    &#xA;

    Could anybody help me with this ?

    &#xA;