Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFMPEG for aws s3 bucket signed url not working in node js

    21 août 2018, par ahmed sharief

    I am trying to create thumbnails from an amazon s3 bucket signed url. I am able to generate thumbnails when i run the command in terminal

    ffmpeg -ss 00:00:02 -i "https://test-s3-bucket.s3.ap-south-1.amazonaws.com/user_gallery_assets/5b6936069ac2bf0602085367/gallery/images/5b7be08527641dee8c1f8134.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=xxxxxxxxx%2F20180821%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Date=20180821T095101Z&X-Amz-Expires=900&X-Amz-Signature=d7f81f4eed3d6c87c04dc1b0ad06beeb946afa33d417585f57fad72aeadb3ac0&X-Amz-SignedHeaders=host" -vframes 1 -q:v 2 -f image2 output.jpg
    

    I am running the above command in terminal and its working fine but when i try to implement the same in node js its showing "no such file or directory error". Though i am encoding the url with double quotes then also its showign same error. Here is my node js code....

    function uploadThumbNailForVideo(obj,url, thumb_url){
        return new Promise((resolve, reject) => resolve(url))
        .then((url) => awsHelper.getImage(url))
        .then((result) => { 
    
            var resUrl = "\""+result+"\"";
    
            var args = [ 
                '-i', resUrl, 
                '-ss', '00:00:02', 
                '-vframes', '1', 
                '-f','image2', 
                'output.jpg'
            ]
            //console.log(args)
            var ffmpeg = require('child_process').spawn('ffmpeg', args);
    
            ffmpeg.on('error', function (err) {
                console.log(err);
            });
    
            ffmpeg.on('close', function (code) {
    
            });
    
            ffmpeg.stderr.on('data', function (data) {
                var tData = data.toString('utf8');
                var a = tData.split('\n');
                console.log("A",a); 
            });
    
            ffmpeg.stdout.on('data', function (data) {
                //
            });
    
    
        });
    

    }

    and i am getting the following error

    A [ 'ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg 
    developers' ]
    A [ '',
      '  built with Apple LLVM version 9.1.0 (clang-902.0.39.2)',
      '  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable- 
    shared --enable-pthreads --enable-version3 --enable-hardcoded-tables -- 
    enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable- 
    gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable- 
    opencl --enable-videotoolbox --disable-lzma',
       '  libavutil      56. 14.100 / 56. 14.100',
       '  libavcodec     58. 18.100 / 58. 18.100',
      '  libavformat    58. 12.100 / 58. 12.100',
      '  libavdevice    58.  3.100 / 58.  3.100',
      '  libavfilter     7. 16.100 /  7. 16.100',
      '  libavresample   4.  0.  0 /  4.  0.  0',
      '  libswscale      5.  1.100 /  5.  1.100',
      '  libswresample   3.  1.100 /  3.  1.100',
      '  libpostproc    55.  1.100 / 55.  1.100',
      '"https://test-s3-bucket.s3.ap-south-1.amazonaws.com/user_gallery_assets/5b6936069ac2bf0602085367/gallery/images/5b7be08527641dee8c1f8134.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=xxxxxxxxx%2F20180821%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Date=20180821T095101Z&X-Amz-Expires=900&X-Amz-Signature=d7f81f4eed3d6c87c04dc1b0ad06beeb946afa33d417585f57fad72aeadb3ac0&X-Amz-SignedHeaders=host": No such file or directory',
      '' ]
    
    ffmpeg exited with code 1
    
  • Decode using GPU instead of CPU via FFmpeg

    21 août 2018, par hamidi

    platform: Windows application: WinForm application language: C# decoder: ffmpeg

    Hi We're using ffmpeg to decode frames sent via network to us. The program is written in C# and uses FFmpegInvoke as well as the required DLL's like avcodec-56.dll and avutil-54.dll for decoding the frames. We need to use GPU instead of CPU for this purpose. Now CPU is used and decoding is done without any problem. My question is that how can I tell ffmpeg use GPU instead of CPU for decoding? Is there any sample code for this purpose? Thanks

  • ffmpeg with Popen (python) on Windows

    21 août 2018, par Gabrielle

    I am trying to use ffmpeg with Popen. The ffmpeg command I am trying works on cmd but gives me error with Popen.

    I am using the standalone ffmpeg .exe:

    ffmpeg -f gdigrab -offset_x 10 -offset_y 20 -show_region 1 -i desktop -video_size 1536x864 -b:v 2M -maxrate 1M -bufsize 1M -tune fastdecode -crf 15 -preset ultrafast -pix_fmt yuv420p -r 25 /video.mov -qp 1 -y -an
    

    This gives me Invalid argument, but if I remove the last parameters in order to make the output the last thing on the string, I get a different error:

    Output file #0 does not contain any stream

    I tried to use -f dshow -i video="UScreenCapture" instead of the gdigrab, but both give me the same error with and without the parameters in the end.

    Both commands work on command line.

    On command line this ffmpeg -list_devices true -f dshow -i dummy returns this:

    [dshow @ 000001b24fa6a300] DirectShow video devices (some may be both video and audio devices)
    [dshow @ 000001b24fa6a300]  "Integrated Webcam"
    [dshow @ 000001b24fa6a300]     Alternative name "@device_pnp_\\?\usb#vid_1bcf&pid_2b8a&mi_00#6&2c03619a&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
    [dshow @ 000001b24fa6a300]  "UScreenCapture"
    [dshow @ 000001b24fa6a300]     Alternative name "@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\UScreenCapture"
    [dshow @ 000001b24fa6a300] DirectShow audio devices
    [dshow @ 000001b24fa6a300]  "Microphone (Realtek Audio)"
    [dshow @ 000001b24fa6a300]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{35EBFC89-7B09-4557-8032-85AA0B688FE9}"
    

    But on popen I can't check it:

    -list_devices true -f dshow -i dummy: Invalid argument

    For the python part of the code I am using this:

    p = subprocess.Popen([getPathForFile("windows/ffmpeg").replace('\\','/'),  " -f gdigrab -offset_x 10 -offset_y 20 -show_region 1 -i desktop -video_size 1536x864 -b:v 2M -maxrate 1M -bufsize 1M -tune fastdecode -crf 15 -preset ultrafast -pix_fmt yuv420p -r 25 -qp 1 -y -an "+ path.replace('\\\\','/').replace('\\','/')+"video.mov"], shell=True)
    

    The getPathForFile is a custom function that returns the path. this is correct, mainly because the errors I am getting are from the ffmpeg, so...

    I am on a Windows 10. FFmpeg 4.0. Python 3.5.

    Any ideas why am I getting these errors on Popen but not on command line and how to fix them? (mainly the second error)

  • Wrapping an h264 stream with ts (transport stream)

    20 août 2018, par ICU_

    Suppose I have an incoming stream of H264 data wrapped in RTP. After I strip the RTP header, how can I re-wrap it into a TS header (transport stream) for playing on the web browser? I know Ffmpeg can do it, but am not on a windows or linux platform. So I need to manually do it. I would need a simple library in c or c++.

  • ffmpeg giving conversion failure when run on subclips

    20 août 2018, par user2333839

    I have a main video clip and I am generating a subclip out of it using ffmpeg. The command i use to generate the subclip is:

    ffmpeg -i {input_video} -ss {start_time} -to {end_time} {output_filename}
    

    Once I have the subclip, I am doing the following things:

    Step 1: I am calculating the average Frame Rate using ffprobe:

    ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 
    

    Step 2: I am extracting the raw video stream and storing it in a temp location and removing the existing PTS values using:

    ffmpeg -i  -c:v copy -an $TMP_STREAM 2>&1
    

    Step 3: I am remuxing the video to a container forcing the average FPS causing the PTS values to be rewritten:

    ffmpeg-r  -i $TMP_STREAM -c:v copy $OUTPUT_FILE 2>&1
    

    When I do the above 3 steps on the main video clip, it works just fine. But when I do these steps on the subclip (which I generated using ffmpeg), then step 3 is giving me error:

    Can't write packet with unknown timestamp
    av_interleaved_write_frame(): Invalid argument
    

    Any inputs on what might be happening?

    Below are my commands and the logs:

    Command 1:
    ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 abcd.mp4.

    ---> Output: 287/12

    Command 2:
    ffmpeg -i abcd.mp4 -c:v copy -an /tmp/tmp.h264 2>&1

    ---> Output:

    ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
      built with gcc 4.9.4 (GCC)
      configuration: --prefix=/local/p4clients/pkgbuild-DlViY/workspace/src/FFmpeg/build/private/install --disable-static --enable-gpl --enable-libx264 --enable-shared --enable-encoder=vorbis --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libebur128
      libavutil      55. 34.101 / 55. 34.101
      libavcodec     57. 64.101 / 57. 64.101
      libavformat    57. 56.101 / 57. 56.101
      libavdevice    57.  1.100 / 57.  1.100
      libavfilter     6. 65.100 /  6. 65.100
      libswscale      4.  2.100 /  4.  2.100
      libswresample   2.  3.100 /  2.  3.100
      libpostproc    54.  1.100 / 54.  1.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'subclip_fv_1.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf57.56.101
      Duration: 00:00:29.44, start: 0.000000, bitrate: 329 kb/s
        Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 300 kb/s, 23.92 fps, 23.92 tbr, 18368 tbn, 47.83 tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 26 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
    File '/tmp/tmp.h264' already exists. Overwrite ? [y/N] y
    Output #0, h264, to '/tmp/tmp.h264':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf57.56.101
        Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 300 kb/s, 23.92 fps, 23.92 tbr, 23.92 tbn, 23.92 tbc (default)
        Metadata:
          handler_name    : VideoHandler
    Stream mapping:
      Stream #0:0 -> #0:0 (copy)
    Press [q] to stop, [?] for help
    frame=  703 fps=0.0 q=-1.0 Lsize=    1077kB time=00:00:29.31 bitrate= 301.1kbits/s speed=4.47e+03x
    video:1077kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.010517%
    

    Command 3:
    ffmpeg-r 287/12 -i /tmp/tmp.h264 -c:v copy abcd.mp4_retimed.mkv 2>&1

    ----> Ouput:

    ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
      built with gcc 4.9.4 (GCC)
      configuration: --prefix=/local/p4clients/pkgbuild-DlViY/workspace/src/FFmpeg/build/private/install --disable-static --enable-gpl --enable-libx264 --enable-shared --enable-encoder=vorbis --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libebur128
      libavutil      55. 34.101 / 55. 34.101
      libavcodec     57. 64.101 / 57. 64.101
      libavformat    57. 56.101 / 57. 56.101
      libavdevice    57.  1.100 / 57.  1.100
      libavfilter     6. 65.100 /  6. 65.100
      libswscale      4.  2.100 /  4.  2.100
      libswresample   2.  3.100 /  2.  3.100
      libpostproc    54.  1.100 / 54.  1.100
    Input #0, h264, from '/tmp/tmp.h264':
      Duration: N/A, bitrate: N/A
        Stream #0:0: Video: h264 (High), yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], 23.92 fps, 23.92 tbr, 1200k tbn, 47.83 tbc
    Output #0, matroska, to 'subclip_fv_1.mp4_retimed.mkv':
      Metadata:
        encoder         : Lavf57.56.101
        Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], q=2-31, 23.92 fps, 23.92 tbr, 1k tbn, 23.92 tbc
    Stream mapping:
      Stream #0:0 -> #0:0 (copy)
    Press [q] to stop, [?] for help
    [matroska @ 0x43d880] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
    [matroska @ 0x43d880] Can't write packet with unknown timestamp
    av_interleaved_write_frame(): Invalid argument