Recherche avancée

Médias (91)

Autres articles (40)

  • Use, discuss, criticize

    13 avril 2011, par

    Talk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
    The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
    A discussion list is available for all exchanges between users.

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

Sur d’autres sites (6349)

  • How can I get duration of a video in java program using ffmpeg ?

    4 mars 2019, par J Jain

    I want to get duration of video and save it to database. I am running a java program to convert video into mp4 format, after conversion I want to get the duration of video.

    [How to extract duration time from ffmpeg output ?

    I have gone threw this link, that command is running well in cmd, but it is giving ’exit code = 1’ with java program.

    Here is code :-

    String videoDuration = "" ;
    List args1 = new ArrayList() ;

       args1.add("ffmpeg");
       args1.add("-i");
       args1.add(videoFilePath.getAbsolutePath());
       args1.add("2>&1");
       args1.add("|");
       args1.add("grep");
       args1.add("Duration");
       args1.add("|");
       // args.add("awk");
       // args.add("'" + "{print $2}" + "'");
       // args.add("|");
       args1.add("tr");
       args1.add("-d");
       args1.add(",");

       String argsString = String.join(" ", args1);

       try
       {
           Process process1 = Runtime.getRuntime().exec(argsString);
           logger.debug(strMethod + " Process started and in wait mode");
           process1.waitFor();
           logger.debug(strMethod + " Process completed wait mode");
           // FIXME: Add a logger increment to get the progress to 100%.
           int exitCode = process1.exitValue();
           if (exitCode != 0)
           {
               throw new RuntimeException("FFmpeg exec failed - exit code:" + exitCode);
           }
           else
           {
               videoDuration = process1.getOutputStream().toString();
           }
       }
       catch (IOException e)
       {
           e.printStackTrace();
           new RuntimeException("Unable to start FFmpeg executable.");
       }
       catch (InterruptedException e)
       {
           e.printStackTrace();
           new RuntimeException("FFmpeg run interrupted.");
       }
       catch (Exception ex)
       {
           ex.printStackTrace();
       }

       return videoDuration;

    Updated Code :-

      List<string> args1 = new ArrayList<string>();

       args1.add("ffprobe");
       args1.add("-i");
       args1.add(videoFilePath.getAbsolutePath());
       args1.add("-show_entries");
       args1.add("format=duration");
       args1.add("-v");
       args1.add("quiet");
       args1.add("-of");
       args1.add("csv=\"p=0\"");
       args1.add("-sexagesimal");

       String argsString = String.join(" ", args1);

       try
       {
           Process process1 = Runtime.getRuntime().exec(argsString);
       }
       catch (InterruptedException e)
       {
               e.printStackTrace();
           }
    </string></string>
  • Concatenation and Transcoding of MPEG-TS files FFMPEG

    20 décembre 2020, par SquawkBirdies

    I have a DVR which records over-the-air TV and saves the recordings in the MPEG-TS format, splitting each episode across multiple files, each 500 MB in size.

    &#xA;&#xA;

    To simplify archiving, I have been trying to write a shell script to automate the process of concatenating the files together and transcoding them into a more common video format, like h.264.

    &#xA;&#xA;

    Here are the steps I have performed so far :

    &#xA;&#xA;

      &#xA;
    • I wanted to make sure that the files I was getting were valid in the first place. To test this, each section was transcoded in Handbrake before being merged using ffmpeg's concat command. This worked, but was manual and added an annoying black frame between each section.
    • &#xA;

    • I wrote a shell script to find all the sections of an episode in a folder and put the file names into a text file that the concat demuxer could parse.
    • &#xA;

    • Tested this command :
    • &#xA;

    &#xA;&#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    ffmpeg -hide_banner -f concat -i video_files_tmp.txt -c:v libx264 -pix_fmt yuv420p -c:a aac $2$OUTPUT_FILE_NAME

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;&#xA;

    During the transcode, this would throw many warnings and errors, such as "PES packet size mismatch". At some point, it would warn that more than 1,000 frame were skipped. When the output was played, it would skip frames and result in a file where the video froze partway through but the audio continued playing. I tried adding -vsync 0 to the output as well.

    &#xA;&#xA;

      &#xA;
    • Then, tried splitting the concatenation and transcode into two steps :
    • &#xA;

    &#xA;&#xA;

    &#xD;&#xA;
    &#xD;&#xA;
    ffmpeg -hide_banner -f concat -i video_files_tmp.txt -c copy output_tmp.ts&#xD;&#xA;ffmpeg -hide_banner -i output_tmp.ts -c:v libx265 -pix_fmt yuv420p -c:a aac $2$OUTPUT_FILE_NAME

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;&#xA;

    This did basically the same thing as before.

    &#xA;&#xA;

      &#xA;
    • Tried using the libx265 encoder instead. Same result.
    • &#xA;

    • Then, I tried just playing the concatenated MPEG-TS file directly, which also would freeze at some point during the playback.
    • &#xA;

    &#xA;&#xA;

    I was wondering about what ffmpeg flags or options to set to get this working, or other options I could try ? Thanks !

    &#xA;

  • Command failed ffmpeg in Lambda function (Node js)

    14 février 2019, par Arun

    I am trying to convert a video file to an audio file inside the lambda function. But I keep getting FFmpeg command failed error. I put FFmpeg binary exe file inside the project directory. but still, I am getting the same error. I tried this ( Lambda not connecting to ffmpeg ) but my issue is not solving yet. Any helps ?? thanks,

    Here is my lambda function code

    process.env.PATH = process.env.PATH + ':/tmp/';
    process.env['FFMPEG_PATH'] = '/tmp/ffmpeg';
    const BIN_PATH = process.env['LAMBDA_TASK_ROOT'];
    process.env['PATH'] = process.env['PATH'] + ':' + BIN_PATH;

    const fs = require('fs');
    const AWS = require('aws-sdk');

    AWS.config.update({
       region : 'us-east-2'
    });
    const s3 = new AWS.S3({apiVersion: '2006-03-01'});


    exports.handler = (event, context, callback) => {
       require('child_process').exec(
           'cp /var/task/ffmpeg /tmp/.; chmod 755 /tmp/ffmpeg;',
           function (error, stdout, stderr) {
               if (error) {
                   console.log('Erro occured',error);
               } else {
                   var ffmpeg = require('ffmpeg');
                   var params = {
                       Bucket: "bucket_name",
                       Key: event.Records[0].s3.object.key
                   };
                   s3.getObject(params, function(err, data) {
                       if (err) {
                           console.log("Error", err);
                       }
                       fs.writeFile("/tmp/vid.mp4", data.Body, function (err) {
                           if (err) console.log(err.code, "-", err.message);
                           return callback(err);
                       }, function() {
                           try {
                               var stats = fs.statSync("/tmp/vid.mp4");
                               console.log("size of the file1 ", stats["size"]);
                               try {
                                   console.log("Yeah");
                                   var process = new ffmpeg('/tmp/vid.mp4');
                                   process.then(function (video) {
                                       // Callback mode
                                       console.log("video function ", video);
                                       video.fnExtractSoundToMP3('/tmp/video.mp3', function (error, file) {
                                           if (!error)
                                               console.log('Audio file: ' + file);
                                           else console.log('error video ', error);
                                       });
                                   }, function (err) {
                                       console.log('Error: ' + err);
                                   });
                               } catch (e) {
                                   console.log(e.code);
                                   console.log(e.msg);
                               }
                           } catch (e) {
                               console.log("file is not complete", e);
                           }
                       });
                       return callback(err);
                   });
               }
           }
       )
    }

    Error message

    { Error: Command failed: ffmpeg -i /tmp/vid.mp4 -vn -ar 44100 -ac 2 -ab 192 -f mp3 /tmp/video.mp3

       at ChildProcess.exithandler (child_process.js:275:12)
       at emitTwo (events.js:126:13)
       at ChildProcess.emit (events.js:214:7)
       at maybeClose (internal/child_process.js:925:16)
       at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
       killed: false,
           code: null,
       signal: 'SIGSEGV',
       cmd: 'ffmpeg -i /tmp/vid.mp4 -vn -ar 44100 -ac 2 -ab 192 -f mp3 /tmp/video.mp3' }