Recherche avancée

Médias (0)

Mot : - Tags -/xmlrpc

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

Autres articles (23)

  • Récupération d’informations sur le site maître à l’installation d’une instance

    26 novembre 2010, par

    Utilité
    Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
    Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer 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

  • MediaSPIP Player : problèmes potentiels

    22 février 2011, par

    Le lecteur ne fonctionne pas sur Internet Explorer
    Sur Internet Explorer (8 et 7 au moins), le plugin utilise le lecteur Flash flowplayer pour lire vidéos et son. Si le lecteur ne semble pas fonctionner, cela peut venir de la configuration du mod_deflate d’Apache.
    Si dans la configuration de ce module Apache vous avez une ligne qui ressemble à la suivante, essayez de la supprimer ou de la commenter pour voir si le lecteur fonctionne correctement : /** * GeSHi (C) 2004 - 2007 Nigel McNie, (...)

Sur d’autres sites (5290)

  • Batch generating spectrograms with ffmpeg or SoX : how to customize their appearance, and is my code so far correct ?

    4 mai 2024, par Mark I

    I have a .flac music library, and for organizational and quality assessment reasons I want to have spectrograms of every song in it. After finding out that the program I usually use to view them, Spek, doesn't offer a batch export option, I have found ways to batch generate spectrograms with both SoX and fmpeg. Below you can find the two scripts I've got, which take as an input a folder which contains flac files or subfolders containing flac files, and output their spectrograms (with the same names as their corresponding flacs) to an output folder with the same structure as the input folder :

    


    SoX :

    


    @echo off
setlocal enabledelayedexpansion

REM Root folder containing flac files
set "root_folder=%~1"

REM Output folder for spectrogram images
set "output_folder=0. Spectrograms"

REM Create the output folder if it doesn't exist
mkdir "%output_folder%" 2>nul

REM Loop through all flac files recursively
for /r "%root_folder%" %%F in (*.flac) do (
    REM Get the directory of the flac file
    set "directory=%%~dpF"

    REM Get the relative path of the directory from the root folder
    set "relative_path=!directory:%root_folder%\=!"

    REM Create the corresponding subfolder in the output folder
    mkdir "%output_folder%\!relative_path!" 2>nul

    REM Get the filename without extension
    set "filename=%%~nF"

    REM Get the filename with full path
    set "filename_with_path=%%F"

    REM Generate spectrogram image using sox
    sox "%%F" -n spectrogram -x 640 -y 360 -t "!filename_with_path!" -o "%output_folder%\!relative_path!\!filename!.png"
)



    


    It's slow but it works as intended, this is what the output looks like :

    


    ffmpeg :

    


    @echo off
SETLOCAL ENABLEDELAYEDEXPANSION

:: The root directory of the input files
SET "rootdir=%~1"

:: The output directory where the spectrograms will be saved
SET "outputdir=%rootdir%\0. Spectrograms"

:: Function to create spectrograms recursively
CALL :processFolder "%rootdir%"

GOTO :EOF

:processFolder
FOR /D %%D IN ("%~1\*") DO (
    SET "subdir=%%D"
    SET "spectrodir=!subdir:%rootdir%=%outputdir%!"
    IF NOT EXIST "!spectrodir!" MKDIR "!spectrodir!"
    CALL :processFolder "%%D"
)

FOR %%F IN ("%~1\*.flac") DO (
    SET "filename=%%~nxF"
    SET "spectroname=!filename:.flac=.png!"
    SET "spectropath=!spectrodir!\!spectroname!"
    ffmpeg -i "%%F" -lavfi showspectrumpic=s=1280x720 "!spectropath!"
)
GOTO :EOF


    


    It's much faster, and this is what it outputs :

    


    I added them to the Windows Send To folder, and use both by right clicking the folder containing the subfolders with the flacs, then Send To and then the script I want to use.

    


    I have 3 questions :

    


      

    1. Is my code as optimized as it could be ? Is everything correct ? And is it "folder structure agnostic" ? When outputting the spectrograms will the scripts mimic the structure of the input folder in all cases, or are there flaws in the code that would prevent them from being able to do it in some cases (i.e. if the .flac files are 3 layers under the input folder or something like that) ?
    2. 


    3. How do I modify the function calls at each of these scripts (whichever approach I stick with, I'm leaning towards ffmpeg cause it's much faster and appears to be better supported) to have the spectrogram image include some info about the file, customize its font, x axis time format, and other things ? I want it look like what Spek outputs as much as possible. Can't find much in the documentation of SoX and ffmpeg, but Spek uses ffmpeg as its backend right ?
    4. 


    5. Is it recommended to show both channels on the spectrograms, like the SoX script does, or is one sufficient for my purposes ?
    6. 


    


  • How to write a video file using FFmpeg

    15 janvier 2024, par Summit

    I am trying to write a video file using FFMPEG but i get the following errors

    


    [libx264 @ 000002bdf90c3c00] broken ffmpeg default settings detected&#xA;[libx264 @ 000002bdf90c3c00] use an encoding preset (e.g. -vpre medium)&#xA;[libx264 @ 000002bdf90c3c00] preset usage: -vpre <speed> -vpre <profile>&#xA;[libx264 @ 000002bdf90c3c00] speed presets are listed in x264 --help&#xA;[libx264 @ 000002bdf90c3c00] profile is optional; x264 defaults to high&#xA;</profile></speed>

    &#xA;

    This is my code

    &#xA;

    #pragma warning(disable : 4996)&#xA;&#xA;extern "C" {&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libavutil></libavutil>mathematics.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;}&#xA;&#xA;int main() {&#xA;    av_register_all();&#xA;    AVFormatContext* formatContext = nullptr;&#xA;    AVOutputFormat* outputFormat = nullptr;&#xA;    AVStream* videoStream = nullptr;&#xA;&#xA;    const char* filename = "output.mp4";&#xA;&#xA;    // Open the output file&#xA;    if (avformat_alloc_output_context2(&amp;formatContext, nullptr, nullptr, filename) &lt; 0) {&#xA;        fprintf(stderr, "Error allocating output format context\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    outputFormat = formatContext->oformat;&#xA;&#xA;    // Add a video stream&#xA;    videoStream = avformat_new_stream(formatContext, nullptr);&#xA;    if (!videoStream) {&#xA;        fprintf(stderr, "Error creating video stream\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    // Set codec parameters, you may need to adjust these based on your needs&#xA;    AVCodecContext* codecContext = avcodec_alloc_context3(nullptr);&#xA;    codecContext->codec_id = outputFormat->video_codec;&#xA;    codecContext->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    codecContext->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;    codecContext->width = 640;&#xA;    codecContext->height = 480;&#xA;    codecContext->time_base = { 1, 25 };&#xA;&#xA;    // Open the video codec&#xA;    AVCodec* videoCodec = avcodec_find_encoder(codecContext->codec_id);&#xA;    if (!videoCodec) {&#xA;        fprintf(stderr, "Error finding video codec\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    if (avcodec_open2(codecContext, videoCodec, nullptr) &lt; 0) {&#xA;        fprintf(stderr, "Error opening video codec\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    videoStream->codecpar->codec_id = codecContext->codec_id;&#xA;    videoStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    videoStream->codecpar->format = codecContext->pix_fmt;&#xA;    videoStream->codecpar->width = codecContext->width;&#xA;    videoStream->codecpar->height = codecContext->height;&#xA;&#xA;    if (avformat_write_header(formatContext, nullptr) &lt; 0) {&#xA;        fprintf(stderr, "Error writing header\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    // Create a frame&#xA;    AVFrame* frame = av_frame_alloc();&#xA;    frame->format = codecContext->pix_fmt;&#xA;    frame->width = codecContext->width;&#xA;    frame->height = codecContext->height;&#xA;    av_frame_get_buffer(frame, 32);&#xA;&#xA;    // Fill the frame with red color&#xA;    for (int y = 0; y &lt; codecContext->height; &#x2B;&#x2B;y) {&#xA;        for (int x = 0; x &lt; codecContext->width; &#x2B;&#x2B;x) {&#xA;            frame->data[0][y * frame->linesize[0] &#x2B; x * 3] = 255;     // Red component&#xA;            frame->data[0][y * frame->linesize[0] &#x2B; x * 3 &#x2B; 1] = 0;   // Green component&#xA;            frame->data[0][y * frame->linesize[0] &#x2B; x * 3 &#x2B; 2] = 0;   // Blue component&#xA;        }&#xA;    }&#xA;&#xA;    // Write video frames&#xA;    AVPacket packet;&#xA;    for (int i = 0; i &lt; 100; &#x2B;&#x2B;i) {&#xA;        // Send the frame for encoding&#xA;        if (avcodec_send_frame(codecContext, frame) &lt; 0) {&#xA;            fprintf(stderr, "Error sending a frame for encoding\n");&#xA;            return -1;&#xA;        }&#xA;&#xA;        // Receive the encoded packet&#xA;        while (avcodec_receive_packet(codecContext, &amp;packet) == 0) {&#xA;            // Write the packet to the output file&#xA;            if (av_write_frame(formatContext, &amp;packet) != 0) {&#xA;                fprintf(stderr, "Error writing video frame\n");&#xA;                return -1;&#xA;            }&#xA;            av_packet_unref(&amp;packet);&#xA;        }&#xA;    }&#xA;&#xA;    // Write the trailer&#xA;    if (av_write_trailer(formatContext) != 0) {&#xA;        fprintf(stderr, "Error writing trailer\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    // Clean up resources&#xA;    av_frame_free(&amp;frame);&#xA;    avcodec_free_context(&amp;codecContext);&#xA;    avformat_free_context(formatContext);&#xA;&#xA;    return 0;&#xA;}&#xA;

    &#xA;

  • How to write a video file using FFmpeg

    15 janvier 2024, par Summit

    I am trying to write a video file using FFMPEG but i get the following errors

    &#xA;

    [libx264 @ 000002bdf90c3c00] broken ffmpeg default settings detected&#xA;[libx264 @ 000002bdf90c3c00] use an encoding preset (e.g. -vpre medium)&#xA;[libx264 @ 000002bdf90c3c00] preset usage: -vpre <speed> -vpre <profile>&#xA;[libx264 @ 000002bdf90c3c00] speed presets are listed in x264 --help&#xA;[libx264 @ 000002bdf90c3c00] profile is optional; x264 defaults to high&#xA;</profile></speed>

    &#xA;

    This is my code

    &#xA;

    #pragma warning(disable : 4996)&#xA;&#xA;extern "C" {&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libavutil></libavutil>mathematics.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;}&#xA;&#xA;int main() {&#xA;    av_register_all();&#xA;    AVFormatContext* formatContext = nullptr;&#xA;    AVOutputFormat* outputFormat = nullptr;&#xA;    AVStream* videoStream = nullptr;&#xA;&#xA;    const char* filename = "output.mp4";&#xA;&#xA;    // Open the output file&#xA;    if (avformat_alloc_output_context2(&amp;formatContext, nullptr, nullptr, filename) &lt; 0) {&#xA;        fprintf(stderr, "Error allocating output format context\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    outputFormat = formatContext->oformat;&#xA;&#xA;    // Add a video stream&#xA;    videoStream = avformat_new_stream(formatContext, nullptr);&#xA;    if (!videoStream) {&#xA;        fprintf(stderr, "Error creating video stream\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    // Set codec parameters, you may need to adjust these based on your needs&#xA;    AVCodecContext* codecContext = avcodec_alloc_context3(nullptr);&#xA;    codecContext->codec_id = outputFormat->video_codec;&#xA;    codecContext->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    codecContext->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;    codecContext->width = 640;&#xA;    codecContext->height = 480;&#xA;    codecContext->time_base = { 1, 25 };&#xA;&#xA;    // Open the video codec&#xA;    AVCodec* videoCodec = avcodec_find_encoder(codecContext->codec_id);&#xA;    if (!videoCodec) {&#xA;        fprintf(stderr, "Error finding video codec\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    if (avcodec_open2(codecContext, videoCodec, nullptr) &lt; 0) {&#xA;        fprintf(stderr, "Error opening video codec\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    videoStream->codecpar->codec_id = codecContext->codec_id;&#xA;    videoStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    videoStream->codecpar->format = codecContext->pix_fmt;&#xA;    videoStream->codecpar->width = codecContext->width;&#xA;    videoStream->codecpar->height = codecContext->height;&#xA;&#xA;    if (avformat_write_header(formatContext, nullptr) &lt; 0) {&#xA;        fprintf(stderr, "Error writing header\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    // Create a frame&#xA;    AVFrame* frame = av_frame_alloc();&#xA;    frame->format = codecContext->pix_fmt;&#xA;    frame->width = codecContext->width;&#xA;    frame->height = codecContext->height;&#xA;    av_frame_get_buffer(frame, 32);&#xA;&#xA;    // Fill the frame with red color&#xA;    for (int y = 0; y &lt; codecContext->height; &#x2B;&#x2B;y) {&#xA;        for (int x = 0; x &lt; codecContext->width; &#x2B;&#x2B;x) {&#xA;            frame->data[0][y * frame->linesize[0] &#x2B; x * 3] = 255;     // Red component&#xA;            frame->data[0][y * frame->linesize[0] &#x2B; x * 3 &#x2B; 1] = 0;   // Green component&#xA;            frame->data[0][y * frame->linesize[0] &#x2B; x * 3 &#x2B; 2] = 0;   // Blue component&#xA;        }&#xA;    }&#xA;&#xA;    // Write video frames&#xA;    AVPacket packet;&#xA;    for (int i = 0; i &lt; 100; &#x2B;&#x2B;i) {&#xA;        // Send the frame for encoding&#xA;        if (avcodec_send_frame(codecContext, frame) &lt; 0) {&#xA;            fprintf(stderr, "Error sending a frame for encoding\n");&#xA;            return -1;&#xA;        }&#xA;&#xA;        // Receive the encoded packet&#xA;        while (avcodec_receive_packet(codecContext, &amp;packet) == 0) {&#xA;            // Write the packet to the output file&#xA;            if (av_write_frame(formatContext, &amp;packet) != 0) {&#xA;                fprintf(stderr, "Error writing video frame\n");&#xA;                return -1;&#xA;            }&#xA;            av_packet_unref(&amp;packet);&#xA;        }&#xA;    }&#xA;&#xA;    // Write the trailer&#xA;    if (av_write_trailer(formatContext) != 0) {&#xA;        fprintf(stderr, "Error writing trailer\n");&#xA;        return -1;&#xA;    }&#xA;&#xA;    // Clean up resources&#xA;    av_frame_free(&amp;frame);&#xA;    avcodec_free_context(&amp;codecContext);&#xA;    avformat_free_context(formatContext);&#xA;&#xA;    return 0;&#xA;}&#xA;

    &#xA;