Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • minimum delay for mpeg-dash stream using ffmpeg

    9 février 2017, par evan

    I am trying to stream my video files using MP4Box and ffmpeg and using mpeg-dash, I transcoded my video using this command for video:

    ffmpeg -i main720.MTS -movflags faststart -vcodec libx264 -r 24 -tune zerolatency -tune fastdecode -bf 0 -slices 0 -x264opts intra_refresh=1 -g 96 -b:v 700k -maxrate 700k -bufsize 400k -an -s 640*360 -ss 00:00:00 -t 00:02:00 main720_700_video.mp4
    

    and this for audio:

    ffmpeg -i main720.MTS -movflags faststart -acodec libmp3lame -b:a 128k -vn -ss 00:00:00 -t 00:02:00 main720_700_audio.mp4
    

    and this to make the mpeg-dash file:

    MP4Box -dash 4000 -frag 4000 -profile onDamand -rap -segment-name %s_ -out manifest.mpd main720_300_video.mp4 main720_700_video.mp4 main720_300_audio.mp4
    

    but I am NOT getting a fast stream and it has got some delay, any suggestions on how to make this delay lower??

  • Download,modify and upload video with S3

    9 février 2017, par Gold Fish

    I'm trying to write a Lambda function in nodejs that will download a file from S3 bucket, modify it, and then upload it back to another S3 bucket. For some reason, the algorithm prints the 'Modify Video' log and then finishes and exit without error. What am I doing wrong?

    var AWS = require('aws-sdk');
    var util = require('util');
    var ffmpeg = require('fluent-ffmpeg');
    var s3 = require('s3');
    
    // get reference to S3 client
    
    var awsS3Client = new AWS.S3();
    var options = {
      s3Client: awsS3Client,
    };
    var client = s3.createClient(options);
    
    exports.handler = function(event, context, callback) {
        // Read options from the event.
        console.log("Reading options from event:\n", util.inspect(event, {depth: 5}));
        var srcBucket = event.Records[0].s3.bucket.name;
        // Object key may have spaces or unicode non-ASCII characters.
        var srcKey    =
        decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, " "));
        var dstBucket = srcBucket + "-dst";
        var dstKey    = "mod_" + srcKey;
    
        var dwnld_file_name = '/tmp/vid.mp4';
        var mdfy_file_name = '/tmp/mod_vid.mp4';
    
        // Sanity check: validate that source and destination are different buckets.
        if (srcBucket == dstBucket) {
            callback("Source and destination buckets are the same.");
            return;
        }
    
        // Infer the video type.
        var typeMatch = srcKey.match(/\.([^.]*)$/);
        if (!typeMatch) {
            callback("Could not determine the video type.");
            return;
        }
        var videoType = typeMatch[1];
        if (videoType != "mp4") {
            callback('Unsupported video type: ${videoType}');
            return;
        }
        console.log("Source bucket: ", srcBucket);
        console.log("srcKey: ", srcKey);
        console.log("Dest bucket: ", dstBucket);
        console.log("dstKey: ", dstKey);
    
        var params = {
          localFile: dwnld_file_name,
    
          s3Params: {
            Bucket: srcBucket,
            Key: srcKey,
          },
        };
        console.log("params for download: ", params);
        var downloader = client.downloadFile(params);
        downloader.on('error', function(err) {
          console.error("unable to download:", err.stack);
          callback("unable to download");
        });
        downloader.on('end', function() {
          console.log("done downloading");
          console.log("modify video");
          ffmpeg(dwnld_file_name)
              .setStartTime('00:00:01')
              .setDuration('1').output(mdfy_file_name).on('end', function() {
                console.log('Finished processing');
                params = {
                  localFile: mdfy_file_name,
                  //localFile: dwnld_file_name,
                  s3Params: {
                    Bucket: dstBucket,
                    Key: dstKey,
                  },
                };
                console.log("params for upload: ", params);
                var uploader = client.uploadFile(params);
                uploader.on('error', function(err) {
                  console.error("unable to upload:", err.stack);
                  callback("unable to upload");
                });
                uploader.on('end', function() {
                  console.log("done uploading");
                  callback('done');
                  return;
                });
            });  //
        });
    };
    
  • how to fix error Requested output format 'concat' is not a suitable output format

    8 février 2017, par Wayne

    This is my command

    ffmpeg -f concat safe 0 -i C:\_source\mergethis.txt -c copy C:\_combined\combined.mp4
    

    I get this error

    [NULL @ 00000000022a5060] Requested output format 'concat' is not a suitable output format
    safe: Invalid argument
    

    mergethis.txt contains this

    file C:\\_source\\01.mp4
    file C:\\_source\\02.mp4
    file C:\\_source\\03.mp4
    file C:\\_source\\04.mp4
    file C:\\_source\\05.mp4
    file C:\\_source\\06.mp4
    
  • How to escape characters in Windows batch file

    8 février 2017, par Tirafesi

    I'm trying to create a script to run a program that receives as an argument the name of a file. The problem I'm having is that the program doesn't work if the filename has special characters in it.

    I found this post which helped me a bit. With a few modifications on that script I'm able to use the program with filenames containing [ and ].

    However, there are still some other special characters that cause the program to not run. Is it possible to create a batch for all special characters? If not, I would at least need to be able to parse not only [ and ], but ' as well.

    This is what I have working at the moment. How can I at least add ' to this?

    if not exist "mp4\" mkdir mp4
    setlocal disableDelayedExpansion
    for %%f in (*.mkv) do (
      set _a=%%~nf
      set _c=%%f
      setlocal enableDelayedExpansion
      set _b=!_a:[=\[!
      set _name=!_b:]=\]!
      set _d=!_c:[=\[!
      set _fullname=!_d:]=\]!
      "SOMEPATH\ffmpeg\bin\ffmpeg.exe" -i "%%f" -vf subtitles="!_name!.mkv:si=1" -c:v h264_qsv -c:a copy -map 0:v:0 -map 0:a:1 -q:v 6 -look_ahead 0 "mp4/%%~nf.mp4"
      endlocal
    )
    endlocal
    pause
    

    If you could explain the reasoning behind stuff that would be cool as well. I don't understand much about scripting, but I would like to understand what's going on in this batch...

    Oh, and here is the documentation for escaping characters in this program.

  • FFMPEG batch for loop with multiple inputs

    8 février 2017, par Jack Brown

    What we have:

    test.mp3 test.mp4

    We want to merge this using ffmpeg

    ffmpeg -i "test.mp3" -i "test.mp4" -c copy D:\test_final.mp4
    

    The thing is we just need this to do for tons of videos.

    What we currently have:

    for %%a in ("merge\*.*") do ffmpeg -i "%%a" -i "%%a" -c copy D:\%%~na
    

    So, what's the correct form? I have no idea :/

    In merge there are always mp3 and mp4 files with the same name.