Recherche avancée

Médias (91)

Autres articles (94)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (10936)

  • How do you convert multiple audio files in different folders using ffmpeg

    1er avril 2022, par ankulka

    Right now I can use the below code to change all files in a single folder, but I have over 100 folders I need to convert audios for. How do I adjust my code to run through all folders and not just one ?

    


    # files                                                                         
lst = glob.glob("*.mp3")
print(lst)
 
for file in lst:
# convert wav to mp3
    os.system(f"""ffmpeg -i {file} -acodec pcm_u8 -ar 22050 {file[:-4]}.wav""")  


    


  • Decoding HEVC file in C++ with FFmpeg missing one frame

    12 avril 2022, par Ivan

    I'm trying to decode my Hevc file in c++ with using FFmpeg. I used Hevc decoder and try to save the frames in ppm format(Almost the whole source code comes from FFmpeg example [decode_video.c] https://ffmpeg.org/doxygen/trunk/decode_video_8c-example.html, what's new is the conversion from yuv to rgb). My Hevc file has 677 frames, which i checked with ffprobe in command window. But i any got 676 frames with my project. Also i have checked with other Hevc files, the results are same, i got always one frame less.
I also tried another FFmpeg example [demuxing_decoding.c] (https://ffmpeg.org/doxygen/trunk/demuxing_decoding_8c-example.html), the result is same, one frame less...

    


    That seems to just happy with H265 and H264 files, is it a bug of FFmpeg ?

    


    Can anybody help me, i post my code here. Sorry, don't know how to attach my project and test files. Thanks a lot !

    


    Best regards,
Ivan

    


    #include <iostream>&#xA;&#xA;extern "C"&#xA;{&#xA;#include "../Headers/libavcodec/avcodec.h"&#xA;#include "../Headers/libavformat/avformat.h"&#xA;#include "../Headers/libswscale/swscale.h"&#xA;}&#xA;&#xA;#define INBUF_SIZE 4096&#xA;&#xA;//Save RGB image as PPM file format&#xA;static void ppm_save(char* filename, AVFrame* frame)&#xA;{&#xA;    FILE* file;&#xA;    int i;&#xA;&#xA;    fopen_s(&amp;file, filename, "wb");&#xA;    fprintf(file, "P6\n%d %d\n%d\n", frame->width, frame->height, 255);&#xA;    for (i = 0; i &lt; frame->height; i&#x2B;&#x2B;)&#xA;        fwrite(frame->data[0] &#x2B; i * frame->linesize[0], 1, frame->width * 3, file);&#xA;    fclose(file);&#xA;}&#xA;&#xA;void decode(AVCodecContext* dec_ctx, AVFrame* frame, AVPacket* pkt, const char* outfilePrefix)&#xA;{&#xA;    char buf[1024];&#xA;    int ret;&#xA;&#xA;    ret = avcodec_send_packet(dec_ctx, pkt);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Error sending a packet for decoding\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    int sts;&#xA;    ////////////////////////////////////////////////////////////////////////////&#xA;    //Create SWS Context for converting from decode pixel format (like YUV420) to RGB&#xA;    struct SwsContext* sws_ctx = NULL;&#xA;    sws_ctx = sws_getContext(dec_ctx->width,&#xA;        dec_ctx->height,&#xA;        dec_ctx->pix_fmt,&#xA;        dec_ctx->width,&#xA;        dec_ctx->height,&#xA;        AV_PIX_FMT_RGB24,&#xA;        SWS_BICUBIC,&#xA;        NULL,&#xA;        NULL,&#xA;        NULL);&#xA;&#xA;    if (sws_ctx == nullptr)&#xA;    {&#xA;        return;  //Error!&#xA;    }&#xA;&#xA;    //Allocate frame for storing image converted to RGB.&#xA;    AVFrame* pRGBFrame = av_frame_alloc();&#xA;&#xA;    pRGBFrame->format = AV_PIX_FMT_RGB24;&#xA;    pRGBFrame->width = dec_ctx->width;&#xA;    pRGBFrame->height = dec_ctx->height;&#xA;    sts = av_frame_get_buffer(pRGBFrame, 0);&#xA;&#xA;    if (sts &lt; 0)&#xA;    {&#xA;        goto free;&#xA;        //return;  //Error!&#xA;    }&#xA;&#xA;    while (ret >= 0)&#xA;    {&#xA;        ret = avcodec_receive_frame(dec_ctx, frame);&#xA;        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;            goto free;&#xA;        //return;&#xA;        else if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error during decoding\n");&#xA;            exit(1);&#xA;        }&#xA;&#xA;        printf("saving frame %3d\n", dec_ctx->frame_number);//&#xA;        fflush(stdout);&#xA;&#xA;        //////////////////////////////////////////////////////////////////////////&#xA;        //Convert from input format (e.g YUV420) to RGB and save to PPM:&#xA;        sts = sws_scale(sws_ctx,    //struct SwsContext* c,&#xA;            frame->data,            //const uint8_t* const srcSlice[],&#xA;            frame->linesize,        //const int srcStride[],&#xA;            0,                      //int srcSliceY, &#xA;            frame->height,          //int srcSliceH,&#xA;            pRGBFrame->data,        //uint8_t* const dst[], &#xA;            pRGBFrame->linesize);   //const int dstStride[]);&#xA;&#xA;        snprintf(buf, sizeof(buf), "%s-%d.ppm", outfilePrefix, dec_ctx->frame_number);&#xA;        ppm_save(buf, pRGBFrame);&#xA;    }&#xA;&#xA;free:&#xA;    //Free&#xA;    ////////////////////////////////////////////////////////////////////////////&#xA;    sws_freeContext(sws_ctx);&#xA;    av_frame_free(&amp;pRGBFrame);&#xA;}&#xA;&#xA;int main()&#xA;{&#xA;    const char* filename, * outfilePrefix, * seqfilename;&#xA;    const AVCodec* codec;&#xA;    AVCodecParserContext* parser;&#xA;    AVCodecContext* codecContext = NULL;&#xA;    FILE* file;&#xA;    AVFrame* frame;&#xA;    uint8_t inbuf[INBUF_SIZE &#x2B; AV_INPUT_BUFFER_PADDING_SIZE];&#xA;    uint8_t* data;&#xA;    size_t   data_size;&#xA;    int ret;&#xA;    AVPacket* pkt;&#xA;&#xA;#ifdef _DEBUG&#xA;    filename = "D:\\TestFiles\\sample_1280x720.hevc";&#xA;    outfilePrefix = "D:\\TestFiles\\sample_1280x720_output\\output";&#xA;#else&#xA;    if (argc &lt;= 2) {&#xA;        fprintf(stderr, "Usage: %s <input file="file" /> <output file="file">\n"&#xA;            "And check your input file is encoded by mpeg1video please.\n", argv[0]);&#xA;        exit(0);&#xA;    }&#xA;    filename = argv[1];&#xA;    outfilePrefix = argv[2];&#xA;#endif&#xA;&#xA;    pkt = av_packet_alloc();&#xA;    if (!pkt)&#xA;        exit(1);&#xA;&#xA;    /* set end of buffer to 0 (this ensures that no overreading happens for damaged MPEG streams) */&#xA;    memset(inbuf &#x2B; INBUF_SIZE, 0, AV_INPUT_BUFFER_PADDING_SIZE);&#xA;&#xA;    /* find the HEVC video decoder */&#xA;    codec = avcodec_find_decoder(AV_CODEC_ID_HEVC);&#xA;    if (!codec) {&#xA;        fprintf(stderr, "Codec not found\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    parser = av_parser_init(codec->id);&#xA;    if (!parser) {&#xA;        fprintf(stderr, "parser not found\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    codecContext = avcodec_alloc_context3(codec);&#xA;    if (!codecContext) {&#xA;        fprintf(stderr, "Could not allocate video codec context\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    /* For some codecs, such as msmpeg4 and mpeg4, width and height&#xA;       MUST be initialized there because this information is not&#xA;       available in the bitstream. */&#xA;&#xA;       /* open it */&#xA;    if (avcodec_open2(codecContext, codec, NULL) &lt; 0) {&#xA;        fprintf(stderr, "Could not open codec\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    fopen_s(&amp;file, filename, "rb");&#xA;    if (!file) {&#xA;        fprintf(stderr, "Could not open %s\n", filename);&#xA;        exit(1);&#xA;    }&#xA;&#xA;    frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        fprintf(stderr, "Could not allocate video frame\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    while (!feof(file)) {&#xA;        /* read raw data from the input file */&#xA;        data_size = fread(inbuf, 1, INBUF_SIZE, file);&#xA;        if (!data_size)&#xA;            break;&#xA;&#xA;        /* use the parser to split the data into frames */&#xA;        data = inbuf;&#xA;        while (data_size > 0)&#xA;        {&#xA;            ret = av_parser_parse2(parser, codecContext, &amp;pkt->data, &amp;pkt->size,&#xA;                data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);&#xA;            if (ret &lt; 0) {&#xA;                fprintf(stderr, "Error while parsing\n");&#xA;                exit(1);&#xA;            }&#xA;            data &#x2B;= ret;&#xA;            data_size -= ret;&#xA;&#xA;            if (pkt->size)&#xA;                decode(codecContext, frame, pkt, outfilePrefix);&#xA;        }&#xA;    }&#xA;&#xA;    /* flush the decoder */&#xA;    decode(codecContext, frame, NULL, outfilePrefix);&#xA;&#xA;    fclose(file);&#xA;&#xA;    av_parser_close(parser);&#xA;    avcodec_free_context(&amp;codecContext);&#xA;    av_frame_free(&amp;frame);&#xA;    av_packet_free(&amp;pkt);&#xA;}&#xA;</output></iostream>

    &#xA;

  • Increase volume of multiple mp3 files in a directory [closed]

    6 mai 2022, par kojow7

    I am looking for a way to increase the volume of a number of sound bytes in a directory without clipping. I have seen that I can use ffmpeg to pass it through a filter and set volume to a certain level such as 1.5x etc.

    &#xA;

    However, I would like each file to be moved up to its maximum volume without clipping. How do I do this ?

    &#xA;

    Some examples show how to do it in 2 passes, by taking values from first pass and manually using them in 2nd pass. But I am trying to automate this in a bash script with hundreds of sound clips.

    &#xA;

    What is the best way to do this ?

    &#xA;

    I am ultimately trying to put this into a Bash script on MacOS and preferably using ffmpeg.

    &#xA;