Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • NodeJs : Parsing POST request file upload as stream to ffmpeg

    29 mai 2017, par Christian Abdelmassih

    I'm trying to upload a file by sending a POST request to my NodeJs-server where the server will upon receiving the request (but not necessarily whole file) create a readStream on the incoming file and pass it to fluent-ffmpeg for video-compression and then saving it on the server. The idea is to pass the stream to ffmpeg without waiting for the whole file to be uploaded instead of waiting for the upload to complete and then pass the file since it would take more time and require to store the file temporarily on the server before the compression.

    With the current code ffmpeg gives the error pipe:0: Invalid data found when processing input which I translate to some error with the stream creation. The code is as follows

    module.exports = function(req, res) {
      let formidable = require('formidable');
      let form = new formidable.IncomingForm();
      form.parse(req, (err, fields, files) => {
        let readStream = fs.createReadStream(files.uploadedfile.path);
        let ffmpeg = require('fluent-ffmpeg')
        let ffmpegCmd = ffmpeg(readStream)
        ...
      });
    });
    

    Am I making some wrong assumption here?

  • FFmpeg video alpha merged freezes

    29 mai 2017, par cdapalc

    I am using ffmpeg 4 Android to overlay a video with alpha channnel in a normal video. I use the following command:

    String[] mergeVideosCommand = new String[]{
                "-y",
                "-i",
                videoAlphaPath.mov,
                "-i",
                videoNormalPath.mp4,
                "-filter_complex",
                "[0:v]colorchannelmixer=aa=1[ov];[1:v][ov]overlay=0:0[video_out]",
                "-map",
                "[video_out]",
                "-map",
                "0:a",
                videoResultPath.mp4
    };
    ffmpeg.execute(mergeVideosCommand, responseHandler);
    

    Both videos get merged, but the non-transparent one freezes after one second of playing but the video with alpha channel keeps moving and both audios work fine as well. I have tried the same command from my computer (with ffmpeg v2.6.3) and it works fine but I need to make it work on Android (ffmpeg v3.0.1). Anybody experienced something similar? I would appreciate any help. Thanks.

  • How can I tell ffmpeg to start to write on file as soon as it detects some motion ?

    29 mai 2017, par krvl

    A little background. I am recording a stream from a camera (using rtsp protocol) and I'd like to save on the disk not the whole input stream but only some excerpts after a motion is detected.
    The "basic" command I'm using is something like:

    ffmpeg -i rtsp://{my_camera_address}/ -movflags +frag_keyframe+separate_moof+omit_tfhd_offset+empty_moov -acodec aac -vcodec h264 output.mp4
    

    I recently add the -movflags option to achieve a sort of realtime, that is I can read the video file while is't been written by ffmpeg.
    A user suggested in this question to add a filter to ffmpeg command in order to grab only the frames where a motion is detected, they used this option:

    -vf select=gt(scene\,0.05),setpts=N/(25*TB)
    

    But it has some incompatibility with the -vcodec copy option, although this is not a big issue.

    My question is: is it possibile to use the filter (or another option) just to trigger the file writing? For example, I save a 5 minutes video after a motion-detection is triggered.

  • ffmpeg - how to merge multiple audio with time offset into a video ? [on hold]

    29 mai 2017, par Xi Xiao

    I want to use FFMPEG to merege multiple audios and one video.

    Materials are:

    1. two short audio clips (short-clip-1.3gp, short-clip-2.3gp),
    2. one video clip (1.mp4) with sound,
    3. and one audio clip (1.mp3) that has same duration as the video clip.

    Requirement is:

    1. Remove video clip's sound
    2. add 1.mp3
    3. add short-clip-1.3gp at 0 sec timetamp, short-clip-2.3gp at 10 sec timestamp.

    The requirement is depicted like below.

    <--short-clip-1.3gp time duration--> <--short-clip-2.3gp time duration-->

    <-------------------------------------- 1.mp3 ----------------------------------------------------->

    <-------------------------------------- 1.mp4 ----------------------------------------------------->

    The command I use is as below, but it does not work as expected. ffmpeg -i 1.mp4 -i 1.3gp -itsoffset 00:00:10 -i 2.3gp -i 1.mp3 -map 0:v -map 1:a -map 2:a -map 3:a -c:v copy -c:a copy result.mp4

    Any hint is appreciated!

  • File for preset 'slower' not found in ffmpeg with linux

    29 mai 2017, par urdesh kumar

    When I am using the below command then getting the error "File for preset 'slower' not found"

    /usr/bin/ffmpeg -i mainFile.mp4 -ss 00:03:22 -t 00:00:22 -acodec libfaac -vcodec libx264 -vpre slower -crf 18 -aspect 16:9 -r 25 -b 3000k -vpre main -level 21 -refs 2 -threads 0 spliteFile.mp4
    

    But when I am trying basic ffmpeg command then it is working fine.

    /usr/bin/ffmpeg -i mainFile.mp4 -ss 0 -t 100 spliteFile.mp4
    

    Please suggest. I think I am missing the parameter? thanks in advance....