Recherche avancée

Médias (0)

Mot : - Tags -/auteurs

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

Autres articles (80)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

  • Les sons

    15 mai 2013, par

Sur d’autres sites (4435)

  • (C_UDP Socket Programming) How can I convert binary file to video format ?

    30 avril 2024, par user24723398

    I am practicing UDP socket programming. My code's functions are below.

    


      

    1. Connect Server-Client and send "hello" message each other (it is working).
    2. 


    3. Then Server is sending video file to client (problem).
    4. 


    


    Transfer video file to client is working. But it is written in binary so I can't open the video.

    


    So I try to use ffmpeg to convert the video, but it doesn't work.

    


    Is there something wrong in my code ? How can I transfer a received file to a video file ?

    


    My environment is MacOs.

    


    Server.c (Server Code) :

    


    #include &#xA;#include &#xA;#include &#xA;#include <arpa></arpa>inet.h>&#xA;#include &#xA;#include <sys></sys>socket.h>&#xA;&#xA;#define PORT 8888&#xA;#define BUF_SIZE 256&#xA;&#xA;int main(){&#xA;    int serv_sock;&#xA;    char message[BUF_SIZE];&#xA;    char buf[BUF_SIZE];&#xA;    int str_len;&#xA;    socklen_t clnt_adr_sz;&#xA;&#xA;    struct sockaddr_in serv_adr, clnt_adr;&#xA;    &#xA;    //create socket&#xA;    serv_sock=socket(PF_INET, SOCK_DGRAM, 0);&#xA;    if(serv_sock == -1){&#xA;        perror("socket() error");&#xA;        exit(1);&#xA;    }&#xA;    &#xA;    //socket address&#xA;    memset(&amp;serv_adr, 0, sizeof(serv_adr));&#xA;    serv_adr.sin_family=AF_INET;&#xA;    serv_adr.sin_addr.s_addr=htonl(INADDR_ANY);&#xA;    serv_adr.sin_port=htons(PORT);&#xA;    //binding socket&#xA;    if(bind(serv_sock, (struct sockaddr*)&amp;serv_adr, sizeof(serv_adr)) == -1){&#xA;        perror("bind() error");&#xA;        exit(1);&#xA;    }&#xA;    &#xA;    while(1){&#xA;        clnt_adr_sz=sizeof(clnt_adr);&#xA;        str_len=recvfrom(serv_sock, message, BUF_SIZE, 0, (struct sockaddr *)&amp;clnt_adr, &amp;clnt_adr_sz);&#xA;         if (str_len &lt; 0) {&#xA;            perror("recvfrom error");&#xA;            exit(1);&#xA;        }&#xA;    &#xA;        char hello_message[] = "hello i am server";&#xA;        if (sendto(serv_sock, hello_message, strlen(hello_message), 0, (struct sockaddr *)&amp;clnt_adr, clnt_adr_sz) &lt; 0) {&#xA;            perror("sendto error");&#xA;            exit(1);&#xA;        }&#xA;        &#xA;        //print message&#xA;        message[str_len] = &#x27;\0&#x27;;&#xA;        printf("client say: %s\n", message);&#xA;        &#xA;        char buf[BUF_SIZE];&#xA;        ssize_t bytes_read;&#xA;        // sending viedo file&#xA;        printf("sending video file...\n");&#xA;        size_t fsize;&#xA;    &#xA;        //video file&#xA;        FILE *file;&#xA;        char *filename = "video.mp4";&#xA;        // open video file&#xA;        file = fopen(filename, "rb");&#xA;        if (file == NULL) {&#xA;            perror("File opening failed");&#xA;            exit(EXIT_FAILURE);&#xA;        }&#xA;        //calculate video file memory&#xA;        fseek(file, 0, SEEK_END);&#xA;        fsize = ftell(file);&#xA;        fseek(file,0,SEEK_SET);&#xA;    &#xA;        size_t size = htonl(fsize);&#xA;        int nsize =0;&#xA;        &#xA;        while(nsize!=fsize){&#xA;            int fpsize = fread(buf,1, BUF_SIZE, file);&#xA;            nsize &#x2B;= fpsize;&#xA;            if (sendto(serv_sock, &amp;size, sizeof(size), 0, (struct sockaddr *)&amp;clnt_adr, clnt_adr_sz) &lt; 0) {&#xA;                perror("sendto");&#xA;                exit(EXIT_FAILURE);    &#xA;            }&#xA;            fclose(file);&#xA;            /*&#xA;            while ((bytes_read = fread(buf, 1, BUF_SIZE, file)) > 0) {&#xA;                if (sendto(serv_sock, buf, bytes_read, 0,&#xA;                       (struct sockaddr *)&amp;clnt_adr, clnt_adr_sz) &lt; 0) {&#xA;                    perror("sendto");&#xA;                    exit(EXIT_FAILURE);&#xA;                }       &#xA;            }&#xA;            */&#xA;        }        &#xA;    }&#xA;    close(serv_sock);&#xA;    return 0;&#xA;}&#xA;

    &#xA;

    Client.c (Client code)

    &#xA;

    #include &#xA;#include &#xA;#include &#xA;#include <arpa></arpa>inet.h>&#xA;#include &#xA;#include <sys></sys>socket.h>&#xA;&#xA;#define BUFSIZE 256&#xA;#define PORT 8888&#xA;&#xA;int main(){&#xA;    int sock;&#xA;    char message[BUFSIZE];&#xA;    int str_len;&#xA;    socklen_t adr_sz;&#xA;&#xA;    struct sockaddr_in serv_addr, client_addr;   &#xA;    &#xA;    sock = socket(PF_INET, SOCK_DGRAM, 0);&#xA;    if(sock == -1){&#xA;        printf("socket() error\n");&#xA;        exit(1);&#xA;    }&#xA;&#xA;    memset(&amp;serv_addr, 0, sizeof(serv_addr));&#xA;    serv_addr.sin_family = AF_INET;&#xA;    serv_addr.sin_addr.s_addr = inet_addr("127.0.0.1");&#xA;    serv_addr.sin_port = htons(PORT);&#xA;&#xA;    char hello_message[] = "hello i am client";&#xA;    sendto(sock, hello_message, strlen(hello_message), 0, (struct sockaddr*)&amp;serv_addr, sizeof(serv_addr));&#xA;    adr_sz = sizeof(client_addr);&#xA;    str_len=recvfrom(sock,message,BUFSIZE,0,(struct sockaddr*)&amp;client_addr,&amp;adr_sz);&#xA;   &#xA;    message[str_len] = &#x27;\0&#x27;;&#xA;    printf("client say: %s\n", message);&#xA;    &#xA;    /*&#xA;    char buf[BUFSIZE];&#xA;    ssize_t bytes_received;&#xA;    socklen_t serv_len = sizeof(serv_addr);&#xA;    while ((bytes_received = recvfrom(sock, buf, BUFSIZE, 0,&#xA;                                      (struct sockaddr *)&amp;serv_addr, &amp;serv_len)) > 0) {&#xA;        fwrite(buf, 1, bytes_received, file);&#xA;    }&#xA;    */&#xA;     &#xA;    FILE *file = fopen("received_test.mp4", "wb");&#xA;&#xA;    int nbyte = BUFSIZE;&#xA;    while(nbyte>= BUFSIZE){&#xA;        nbyte = recvfrom(sock, message, BUFSIZE, 0, (struct sockaddr*)&amp;serv_addr, &amp;adr_sz);&#xA;        fwrite(message, sizeof(char), nbyte, file);&#xA;    }&#xA;&#xA;    if (file == NULL) {&#xA;        perror("File opening failed");&#xA;        exit(EXIT_FAILURE);&#xA;    }&#xA;&#xA;    fclose(file);&#xA;    close(sock);&#xA;    printf("File received successfully\n");&#xA;    &#xA;    return 0;&#xA;}&#xA;

    &#xA;

    I try to convert the binary file to an .mp4 file using ffmpeg&#xA;but it doesn't work :

    &#xA;

    ffmpeg -i received_test.mp4 output.mp4&#xA;ffmpeg version 7.0 Copyright (c) 2000-2024 the FFmpeg developers&#xA;  built with Apple clang version 15.0.0 (clang-1500.3.9.4)&#xA;  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/7.0 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags=&#x27;-Wl,-ld_classic&#x27; --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenvino --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon&#xA;  libavutil      59.  8.100 / 59.  8.100&#xA;  libavcodec     61.  3.100 / 61.  3.100&#xA;  libavformat    61.  1.100 / 61.  1.100&#xA;  libavdevice    61.  1.100 / 61.  1.100&#xA;  libavfilter    10.  1.100 / 10.  1.100&#xA;  libswscale      8.  1.100 /  8.  1.100&#xA;  libswresample   5.  1.100 /  5.  1.100&#xA;  libpostproc    58.  1.100 / 58.  1.100&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x12a62bdb0] Format mov,mp4,m4a,3gp,3g2,mj2 detected only with low score of 1, misdetection possible!&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 0x12a62bdb0] moov atom not found&#xA;[in#0 @ 0x12b0043c0] Error opening input: Invalid data found when processing input&#xA;Error opening input file received_test.mp4.&#xA;Error opening input files: Invalid data found when processing input&#xA;

    &#xA;

  • ffmpeg not available on Oracle Linux 9 update 3 [closed]

    19 janvier 2024, par Red Cricket

    I cannot figure out how to install ffmpeg on a Oracle Linux 9 update 3 (RHCK).

    &#xA;

    [root@snc-ol93-rhck ~]# dnf install ffmpeg-free&#xA;Last metadata expiration check: 0:14:16 ago on Wed 17 Jan 2024 04:48:34 PM UTC.&#xA;Error:&#xA; Problem: package ffmpeg-free-5.1.4-2.el9.x86_64 from ol9_developer_EPEL requires libavfilter.so.8()(64bit), but none of the providers can be installed&#xA;  - package ffmpeg-free-5.1.4-2.el9.x86_64 from ol9_developer_EPEL requires libavfilter.so.8(LIBAVFILTER_8)(64bit), but none of the providers can be installed&#xA;  - package libavfilter-free-5.1.3-1.el9.x86_64 from ol9_developer_EPEL requires librubberband.so.2()(64bit), but none of the providers can be installed&#xA;  - package libavfilter-free-5.1.4-1.el9.x86_64 from ol9_developer_EPEL requires librubberband.so.2()(64bit), but none of the providers can be installed&#xA;  - package libavfilter-free-5.1.4-2.el9.x86_64 from ol9_developer_EPEL requires librubberband.so.2()(64bit), but none of the providers can be installed&#xA;  - cannot install the best candidate for the job&#xA;  - nothing provides ladspa needed by rubberband-2.0.1-1.el9.x86_64 from ol9_developer_EPEL&#xA;  - nothing provides ladspa needed by rubberband-3.1.0-2.el9.x86_64 from ol9_developer_EPEL&#xA;  - nothing provides ladspa needed by rubberband-3.1.3-1.el9.x86_64 from ol9_developer_EPEL&#xA;(try to add &#x27;--skip-broken&#x27; to skip uninstallable packages or &#x27;--nobest&#x27; to use not only best candidate packages)&#xA;

    &#xA;

    Turns out I needed to install the repo like so in my ansible playbook

    &#xA;

    dnf install https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-9.noarch.rpm&#xA;

    &#xA;

  • ffmpeg chains parameters and options while being used in a loop

    10 janvier 2024, par Simon Nazarenko

    I got a code that generates videos from scratch (got gifs, captions and audio). It works amazing when done once, however, when put in a loop and it should create more than 1 video it freezes being caused by memory leak. Upon investigation I realized that ffmpeg (v1.1.0) chains the loop iterations carrying the parameters and options from the first iteration to the second. It then breaks (overwrites) the first video and infinitely writes the second.

    &#xA;

    This is my dependency

    &#xA;

    const ffmpeg = require("fluent-ffmpeg")()&#xA;  .setFfprobePath(ffprobe.path)&#xA;  .setFfmpegPath(ffmpegInstaller.path)&#xA;

    &#xA;

    It looks like this

    &#xA;

    async function convertGifToVideo(&#xA;  gifFile,&#xA;  audioFile,&#xA;  subtitlesFile,&#xA;  tempDirectory&#xA;) {&#xA;  return new Promise((resolve, reject) => {&#xA;    const outputFile = `${tempDirectory}/video_${Date.now()}.mp4`&#xA;    &#xA;    ffmpeg&#xA;      .input(gifFile)&#xA;      .inputFormat("gif")&#xA;      .inputOptions("-stream_loop -1")&#xA;      .input(audioFile)&#xA;      .outputOptions("-shortest")&#xA;      .outputOptions(`-vf subtitles=${subtitlesFile}`)&#xA;      .outputOptions("-report")&#xA;      .output(outputFile)&#xA;      .on("end", () => {&#xA;        console.log(`Combined ${gifFile} and ${audioFile} into ${outputFile}`)&#xA;        resolve(outputFile)&#xA;      })&#xA;      .on("error", (err, stdout, stderr) => {&#xA;        console.error("Error combining GIF and audio:", err)&#xA;        console.error("ffmpeg stdout:", stdout)&#xA;        console.error("ffmpeg stderr:", stderr)&#xA;        reject(err)&#xA;      })&#xA;      .run()&#xA;  })&#xA;}&#xA;

    &#xA;

    And it's called in a loop

    &#xA;

    for (const key in script) {&#xA;    if (script.hasOwnProperty(key)) {&#xA;      ...stuff&#xA;&#xA;      const videoFileName = await convertGifToVideo(&#xA;        gifFileName,&#xA;        audioFileName,&#xA;        subtitlesFileName,&#xA;        tempDirectory&#xA;      )&#xA;    }&#xA;  }&#xA;

    &#xA;

    Here is a piece of log from the first video generation

    &#xA;

    &#xA;

    ffmpeg started on 2024-01-10 at 02:58:52&#xA;Report written to "ffmpeg-20240110-025852.log"&#xA;Command line :&#xA;/home/simon/Documents/AFYTUBE/node_modules/@ffmpeg-installer/linux-x64/ffmpeg -f gif -stream_loop -1 -i ./temp/gif_funny_frogs.gif -i ./temp/funny_frogs.mp3 -y -shortest -vf "subtitles=./temp/funny_frogs.srt" -report ./temp/video_1704880732780.mp4

    &#xA;

    &#xA;

    Here is a piece of log from the second one

    &#xA;

    &#xA;

    /home/simon/Documents/AFYTUBE/node_modules/@ffmpeg-installer/linux-x64/ffmpeg -f gif -stream_loop -1 -i ./temp/gif_funny_frogs.gif -i ./temp/funny_frogs.mp3 -f gif -stream_loop -1 -i ./temp/gif_leg_exercises.gif -i ./temp/leg_exercises.mp3 -y -shortest -vf "subtitles=./temp/funny_frogs.srt" -report -shortest -vf "subtitles=./temp/leg_exercises.srt" -report ./temp/video_1704880732780.mp4 ./temp/video_1704880750879.mp4

    &#xA;

    &#xA;

    Any ideas what I am doing wrong ?

    &#xA;