Recherche avancée

Médias (1)

Mot : - Tags -/illustrator

Autres articles (46)

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

Sur d’autres sites (8302)

  • Create a video from images using libav

    24 février 2015, par Pierrexn

    I’m trying to create a mp4 file using libav, but the result is unreadable.

    Here is the code that i use :

    #include <libavformat></libavformat>avformat.h>
    #include <libavutil></libavutil>avutil.h>
    #include <libavutil></libavutil>imgutils.h>

    #define WIDTH 480
    #define HEIGHT 360
    #define TARGET_FPS 30

    int main() {

    av_register_all();

    AVOutputFormat *oformat = av_guess_format(NULL, "test.mp4", NULL);
    if (oformat == NULL)
    {
       printf("Set default\n");
       oformat = av_guess_format("mpeg", NULL, NULL);
    }
    //oformat->video_codec = AV_CODEC_ID_H264;
    AVCodec *codec = avcodec_find_encoder(oformat->video_codec);

    AVCodecContext* codec_context;
    codec_context = avcodec_alloc_context3(codec);
    codec_context->codec_id = oformat->video_codec;
    codec_context->codec_type = AVMEDIA_TYPE_VIDEO;
    codec_context->gop_size = 30;
    codec_context->bit_rate = WIDTH * HEIGHT * 4;
    codec_context->width = WIDTH;
    codec_context->height = HEIGHT;
    codec_context->time_base = (AVRational){1,TARGET_FPS};
    codec_context->max_b_frames = 1;
    codec_context->pix_fmt = AV_PIX_FMT_YUV420P;

    AVFormatContext* format_context;
    format_context = avformat_alloc_context();
    format_context->oformat = oformat;
    format_context->video_codec_id = oformat->video_codec;

    //

    AVStream *video_stream = avformat_new_stream(format_context, codec);
    if (! video_stream)
    {
      printf("Could not allocate stream\n");
    }
    video_stream->codec = codec_context;

    if (format_context->oformat->flags &amp; AVFMT_GLOBALHEADER)
    {
      codec_context->flags |= CODEC_FLAG_GLOBAL_HEADER;
    }

    //

    if (avcodec_open2(codec_context, codec, NULL) &lt; 0) {
       fprintf(stderr, "could not open codec\n");
       exit(1);
    }

    if (avio_open(&amp;format_context->pb, "test.mp4", AVIO_FLAG_WRITE) &lt; 0) {
     fprintf(stderr, "avio_open failed\n");
     exit(1);
    }

    avformat_write_header(format_context, NULL);

    Encoding some frames

    int i, x, y, got_output, write_ret;
    AVPacket pkt;
    AVFrame *frame;
    frame = av_frame_alloc();
    int ret = av_image_alloc(frame->data, frame->linesize, codec_context->width, codec_context->height, codec_context->pix_fmt, 32);
    if (ret &lt; 0) {
       fprintf(stderr, "could not alloc raw picture buffer\n");
       exit(1);
    }
    frame->format = codec_context->pix_fmt;
    frame->width = codec_context->width;
    frame->height = codec_context->height;
    for(i=0;i&lt;25;i++) {
       av_init_packet(&amp;pkt);
       pkt.data = NULL; // packet data will be allocated by the encoder
       pkt.size = 0;

       fflush(stdout);
       /* prepare a dummy image */
       /* Y */
       for(y=0;yheight;y++) {
           for(x=0;xwidth;x++) {
               frame->data[0][y * frame->linesize[0] + x] = x + y + i * 3;
           }
       }
       /* Cb and Cr */
       for(y=0;yheight/2;y++) {
           for(x=0;xwidth/2;x++) {
               frame->data[1][y * frame->linesize[1] + x] = 128 + y + i * 2;
               frame->data[2][y * frame->linesize[2] + x] = 64 + x + i * 5;
           }
       }
       frame->pts = i;

       /* encode the image */
       ret = avcodec_encode_video2(codec_context, &amp;pkt, frame, &amp;got_output);
       if (ret &lt; 0) {
           fprintf(stderr, "error encoding frame\n");
           exit(1);
       }
       if (got_output) {
           printf("encoding frame %3d (size=%5d)\n", i, pkt.size);
           //av_interleaved_write_frame(format_context, &amp;pkt);
           write_ret = av_write_frame(format_context, &amp;pkt);
           if (write_ret &lt; 0) {
               fprintf(stderr, "Error writing frame\n");
               exit(1);
           }
           av_free_packet(&amp;pkt);
       }
    }
    for (got_output = 1; got_output; i++) {
       fflush(stdout);
       ret = avcodec_encode_video2(codec_context, &amp;pkt, NULL, &amp;got_output);
       if (ret &lt; 0) {
           fprintf(stderr, "error encoding frame\n");
           exit(1);
       }
       if (got_output) {
           printf("encoding frame %3d (size=%5d)\n", i, pkt.size);
           //av_interleaved_write_frame(format_context, &amp;pkt);
           write_ret = av_write_frame(format_context, &amp;pkt);
           if (write_ret &lt; 0) {
               fprintf(stderr, "Error writing frame\n");
               exit(1);
           }
           av_free_packet(&amp;pkt);
       }
    }

    Cleaning

    avcodec_close(codec_context);
    av_free(codec_context);
    av_freep(&amp;frame->data[0]);
    avcodec_free_frame(&amp;frame);

    for (i = 0; i &lt; format_context->nb_streams; i++) {
       avcodec_close(format_context->streams[i]->codec);
    }

    avio_close(format_context->pb);

    av_free(format_context);
    }

    The result file has 149361 bytes, but can’t be readed.
    where i’m wrong ??

  • Improper use of system() call ?

    28 mai 2013, par Dima1982

    I have a particle system program that generates a .dat file with particle coordinates in every iteration. The end goal is to run the program multiple times via a script with different parameters. So, I am trying to setup my program in a way that, for every run, all relevant data are going to be stored in a folder.

    What I do is to generate PNGs from the .dat files with Gnuplot, call ffmpeg to create a video out of the PNGs, use WinRAR to compress the .dat files and finally clean up, by deleting all the intermediate files. This works, when I do it in the working directory.

    Now I try to create a new directory and do the same stuff in there. My code :

    // Load the proper library to use chdir() function
    #ifdef _WIN32
    #include
    #elif defined __linux__ || defined __APPLE__&amp;&amp;__MACH__
    #include
    #endif

    // Make output directory and change working directory to new directory
       ostringstream dirCommand;
       dirCommand &lt;&lt; "mkdir " &lt;&lt; folderName_str;
       system(dirCommand.str().c_str());
       const char* test  = folderName_str.c_str();
       #ifdef _WIN32
           if(_chdir(test))
           {
               printf( "Unable to locate the directory: %s\n",test);
               return;
           }
       #elif defined __linux__ || defined __APPLE__&amp;&amp;__MACH__
           if(chdir(test))
           {
               printf( "Unable to locate the directory: %s\n",test);
               return;
           }
       #endif
           else
               printf("Created output directory...\n");

    Already for this part, I know that there are going to be objections. I have looked extensively on SO and many people favor SetCurrentDirectory() for Windows, or they are skeptical about using system(). In my defense, I am a novice programmer and my knowledge is really limited...

    Now, when I try to make the video with FFMpeg and then rar/tar my files :

    // Make video
           std::cout &lt;&lt; "Generating Video..." &lt;&lt; endl;
           ostringstream command;
           command &lt;&lt; "ffmpeg -f image2 -r 1/0.1 -i output_%01d.png -vcodec mpeg4 " &lt;&lt; videoName_str &lt;&lt; ".avi -loglevel quiet";
           std::system(command.str().c_str());

           // Clean Up!
           std::cout &lt;&lt; "Cleaning up!" &lt;&lt; endl;
           ostringstream command2;
           #ifdef _WIN32
               command2 &lt;&lt; "rar -inul a " &lt;&lt; videoName_str &lt;&lt; ".rar *.dat settings.gp loadfile.gp";
           #elif defined __linux__ || defined __APPLE__&amp;&amp;__MACH__
               command2 &lt;&lt; "tar cf " &lt;&lt; videoName_str &lt;&lt; ".tar *.dat settings.gp loadfile.gp";
           #endif
           std::system(command2.str().c_str());

    I get very different behaviors in Win/ Linux.

    Win 7 x64, Visual Studio 2010/12

    In windows, the folder is created. The .dat files are generated correctly and gnuplot plots the PNGs as well. When ffmpeg is called, nothing happens. No error message from FFMpeg or anything. The same goes for WinRAR. Maybe, for the last thing, I can use the command line utility of 7z which is free !

    Linux Mint 14 x64, Qt 4.8.1

    Strangely enough, the behavior is inverted from that of Windows. As soon as the dir is changed, only the first .dat file is generated. It is as if every subsequent call I make to fprintf() for my file generation does not work, or gets lost somewhere. Gnuplot works, as do ffmpeg and tar !!

    I am really perplexed. Any help, would be really appreciated.

  • ffmpeg exit code 429496724 when opening file with {} in name

    16 février, par Holly Wilson

    I'm trying to write a program that will read the names of files in a directory, and parse them for info which it will then write into that file's metadata (seems pointless, I know, but it's more of a trial run for a larger project. If I can figure this out, then I'll be ready to move on to what I actually want to do).&#xA;All of my filenames are formatted :

    &#xA;

    Title, Article* - Subtitle* Cut* [Year]&#xA;*if present

    &#xA;

    The four test videos I'm using are titled :

    &#xA;

    Test Video 1 [2000]

    &#xA;

    Test Video 2, A [2000]

    &#xA;

    Test Video 3 Test Cut [2000]

    &#xA;

    Test Video 4 - The Testening [2000]

    &#xA;

    The code seems to be working fine on videos 1, 2, & 4 ; but video 3 is causing me a lot of headache.

    &#xA;

    //node C:\Users\User\Documents\Coding\Tools\testMDG.js&#xA;const fs = require(&#x27;fs&#x27;);&#xA;const path = require(&#x27;path&#x27;);&#xA;const ffmpeg = require(&#x27;fluent-ffmpeg&#x27;);&#xA;const async = require(&#x27;async&#x27;);&#xA;const directory = path.normalize(&#x27;F:\\Movies &amp; TV\\Movies\\testDir&#x27;);&#xA;let x = 0;&#xA;const fileArray = [];&#xA;const succArray = [];&#xA;const failArray = [];&#xA;// Set the path to the ffmpeg executable&#xA;ffmpeg.setFfmpegPath(path.normalize(&#x27;C:\\ffmpeg\\bin\\ffmpeg.exe&#x27;));&#xA;&#xA;// Add this near the start of your script&#xA;const tempDir = path.join(directory, &#x27;temp&#x27;);&#xA;if (!fs.existsSync(tempDir)) {&#xA;    fs.mkdirSync(tempDir, { recursive: true });&#xA;}&#xA;&#xA;const progresscsv = path.normalize(&#x27;C:\\Users\\User\\Documents\\Coding\\Tools\\progress.csv&#x27;);&#xA;if (fs.existsSync(progresscsv)) {&#xA;    fs.unlinkSync(progresscsv);&#xA;};&#xA;&#xA;const csvStream = fs.createWriteStream(progresscsv);&#xA;csvStream.write(&#x27;File Name,Status\n&#x27;);&#xA;&#xA;const CONCURRENCY_LIMIT = 3; // Adjust based on your system capabilities&#xA;&#xA;// Add at the start of your script&#xA;const processedFiles = new Set();&#xA;&#xA;function sanitizeFilePath(filePath) {&#xA;    return filePath.replace(/([{}])/g, &#x27;\\$1&#x27;);&#xA;}&#xA;&#xA;// Create a queue&#xA;const queue = async.queue(async (task, callback) => {&#xA;    const { file, filePath, tempFilePath, movieMetadata } = task;&#xA;    try {&#xA;        await new Promise((resolve, reject) => {&#xA;            console.log(`ffmpeg reading: ${sanitizeFilePath(filePath)}`);&#xA;            ffmpeg(sanitizeFilePath(filePath))&#xA;                .outputOptions([&#xA;                    &#x27;-y&#x27;,&#xA;                    &#x27;-c&#x27;, &#x27;copy&#x27;,&#xA;                    &#x27;-map&#x27;, &#x27;0&#x27;,&#xA;                    &#x27;-metadata&#x27;, `title=${movieMetadata.title}`,&#xA;                    &#x27;-metadata&#x27;, `subtitle=${movieMetadata.subtitle || &#x27;&#x27;}`,&#xA;                    &#x27;-metadata&#x27;, `comment=${movieMetadata.cut || &#x27;&#x27;}`,&#xA;                    &#x27;-metadata&#x27;, `year=${movieMetadata.year}`&#xA;                ])&#xA;                .on(&#x27;error&#x27;, (err) => reject(err))&#xA;                .on(&#x27;end&#x27;, () => resolve())&#xA;                .saveToFile(tempFilePath);&#xA;        });&#xA;        &#xA;        // Handle success&#xA;        console.log(`Successfully processed: ${file}`);&#xA;        succArray.push(file);&#xA;        // Only call callback once&#xA;        if (callback &amp;&amp; typeof callback === &#x27;function&#x27;) {&#xA;            callback();&#xA;        }&#xA;    } catch (err) {&#xA;        // Handle error&#xA;        console.error(`Error processing ${file}: ${err.message}`);&#xA;        failArray.push(file);&#xA;        // Only call callback once with error&#xA;        if (callback &amp;&amp; typeof callback === &#x27;function&#x27;) {&#xA;            callback(err);&#xA;        }&#xA;    }&#xA;}, CONCURRENCY_LIMIT);&#xA;&#xA;fs.readdir(directory, (err, files) => {&#xA;    if (err) {&#xA;        console.error(`Error reading directory: ${err.message}`);&#xA;        return;&#xA;    }&#xA;    console.log(directory);&#xA;&#xA;    // Filter for files only&#xA;    files = files.filter(file => fs.statSync(path.join(directory, file)).isFile());&#xA;    console.log(files);&#xA;&#xA;    for (const file of files) {&#xA;        x&#x2B;&#x2B;;&#xA;        const filePath = path.join(directory, file);&#xA;        let desort = file.replace(/(.*),\s(the\s|an\s|a\s)/i, &#x27;$2&#x27;&#x2B;&#x27;$1 &#x27;) || file;&#xA;        &#xA;        // Create task object for queue&#xA;        const task = {&#xA;            file,&#xA;            filePath: filePath,&#xA;            tempFilePath: path.join(directory, &#x27;temp&#x27;, `temp_${x}_${path.parse(file).name&#xA;                .replace(/[^a-zA-Z0-9]/g, &#x27;_&#x27;)}${path.extname(file)}`),&#xA;            movieMetadata: {&#xA;                title: desort.replace(/(\s[\-\{\[].*)/gi, ``),&#xA;                subtitle: desort.includes(&#x27;-&#x27;) ? desort.replace(/(.*)\-\s(.*?)[\{\[].*/gi, &#x27;$2&#x27;) : null,&#xA;                cut: desort.includes(&#x27;{&#x27;) ? desort.replace(/.*\{(.*)\}.*/gi, &#x27;$1&#x27;) : null,&#xA;                year: desort.replace(/.*\[(.*)\].*/gi, &#x27;$1&#x27;)&#xA;            }&#xA;        };&#xA;        &#xA;        // Add to processing queue&#xA;        queue.push(task, (err) => {&#xA;            if (!processedFiles.has(task.file)) {&#xA;                processedFiles.add(task.file);&#xA;                if (err) {&#xA;                    csvStream.write(`${task.file},Failed\n`);&#xA;                } else {&#xA;                    csvStream.write(`${task.file},Processed\n`);&#xA;                }&#xA;            }&#xA;        });&#xA;    }&#xA;});&#xA;&#xA;// Add queue completion handler&#xA;queue.drain(() => {&#xA;    console.log(&#x27;All files have been processed&#x27;);&#xA;    console.log(`Success: ${succArray.length} files: ${succArray}`);&#xA;    console.log(`Failed: ${failArray.length} files: ${failArray}`);&#xA;});&#xA;&#xA;//node C:\Users\User\Documents\Coding\Tools\testMDG.js&#xA;

    &#xA;

    And the console is logging :

    &#xA;

    PS C:\Users\User> node C:\Users\User\Documents\Coding\Tools\testMDG.js&#xA;F:\Movies &amp; TV\Movies\testDir&#xA;[&#xA;  &#x27;Test Video 1 [2020].mp4&#x27;,&#xA;  &#x27;Test Video 2, A [2020].mp4&#x27;,&#xA;  &#x27;Test Video 3 {Test Cut} [2020].mp4&#x27;,&#xA;  &#x27;Test Video 4 - The Testening [2020].mp4&#x27;&#xA;]&#xA;ffmpeg reading: F:\Movies &amp; TV\Movies\testDir\Test Video 1 [2020].mp4&#xA;ffmpeg reading: F:\Movies &amp; TV\Movies\testDir\Test Video 2, A [2020].mp4&#xA;ffmpeg reading: F:\Movies &amp; TV\Movies\testDir\Test Video 3 \{Test Cut\} [2020].mp4&#xA;Error processing Test Video 3 {Test Cut} [2020].mp4: ffmpeg exited with code 4294967294: Error opening input file F:\Movies &amp; TV\Movies\testDir\Test Video 3 \{Test Cut\} [2020].mp4.&#xA;Error opening input files: No such file or directory&#xA;&#xA;ffmpeg reading: F:\Movies &amp; TV\Movies\testDir\Test Video 4 - The Testening [2020].mp4&#xA;Successfully processed: Test Video 1 [2020].mp4&#xA;Successfully processed: Test Video 2, A [2020].mp4&#xA;Successfully processed: Test Video 4 - The Testening [2020].mp4&#xA;All files have been processed&#xA;Success: 3 files: Test Video 1 [2020].mp4,Test Video 2, A [2020].mp4,Test Video 4 - The Testening [2020].mp4&#xA;Failed: 1 files: Test Video 3 {Test Cut} [2020].mp4&#xA;

    &#xA;

    I've tried so many different solutions in the sanitizeFilePath function. Escaping the {} characters (as included below), escaping all non-alphanumeric characters, putting the filepath in quotes, etc. VSCode's CoPilot is just pulling me round in circles, suggesting solutions I've already tried.

    &#xA;