Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFMPEG : Is it possible to merge video clips but cutout overlapping frames ?

    18 avril 2019, par Muhammad Umer

    I've got clips of video game. These clips are highlights and recorded automatically when some event happens. I can find solutions to merge them using cli and ffmpeg. Clips are 3 minutes recordings. So if 2 events happen closely, < 3 min apart, then there is overlap. Is it possible to ignore/subtract/delete subsequent clips upto point where last frame that's overlapping.

    EX: 
    Clips= A(1-4), B(7-11), C(9-13).
    
    B and C are overlapping. 
    
    Can ffmpeg detect overlapping frames in C and only merge (12-13).
    
    Clips are alphabetically sortable. 
    
  • PHP FFMPEG How to calculate file size of video from bitrate and duration before conversion ?

    17 avril 2019, par Ally

    I am using php-ffmpeg (a PHP api to ffmpeg) to probe video files before they are converted. I am getting all the information I need just fine, but I want to use it to calculate the estimated file size of the video once it has been converted so that I can convert videos more efficiently for quality vs space etc.

    The post-conversion file size only has to be an estimate. So far I have tried multiplying the duration by the anticipated video bitrate plus the anticipated audio bitrate. However, that gives me a size way larger than the original video file that has a higher video and audio bitrate. I'm assuming there is a compression factor that may have to be taken into account for each different video codec, but am just trying to get somewhere with .mp4/m4v for now.

    This is what I have tried;

    // duration | vid bitrate | aud bitrate
    $estimated_converted_size = $duration * ((4992 * 1024) + (128 * 1024));
    

    The result for a video of 24 seconds, with a video bitrate of 29302kbps and file size of 87.86 MB estimates as being 121.11 MB once converted down to 4992kbs - clearly not right!

    I'm not too clued up on the technicals of video, but is there a way of fairly accurately estimating the file size after conversion?

  • How to pass less parameters to ffmpeg when adding image overlays

    17 avril 2019, par DarioBB

    I am doing processing of video with ffmpeg and I am trying to add image overlays at certain times. I have command something like this:

    ffmpeg -i video.mp4 -i img_a.png -i img_xx.png -i some_third_image.png -i yy_img.png 
    -filter_complex overlay=185:H-h-85:enable=between(t\\,1.1\\,2.3),overlay=285:H-h-415:enable=between(t\\,3.3\\,4.7),overlay=185:H-h-35:enable=between(t\\,5.7\\,6.0),overlay=45:H-h-515:enable=between(t\\,7.1\\,8.6) 
    -c:v libx264 -crf 20 -preset veryfast vid0.mp4
    

    As I am forming/passing parameters to ffmpeg dynamically (programatically), there can be really very very long parameters list. So large, I can even recieve message about too long parameter list (based on operating system) and then I cannot process video. I would like to avoid this. I would like to know how to write code with ffmpeg so there would be less parameters passed to ffmpeg? For example, instead:

    -i img_a.png -i img_xx.png -i some_third_image.png -i yy_img.png
    

    can it be something like:

    -i "img_a.png,img_xx.png,some_third_image.png,yy_img.png"
    

    (Or something similar, where less parameters would be passed to ffmpeg). If it can, please provide example how to write such command in ffmpeg.

  • How to force ffmpeg into non-interactive mode ?

    17 avril 2019, par ubershmekel

    Sometimes you want ffmpeg to ask you whether it should overwrite a file. Sometimes it's just a script that you prefer would fail if something is amiss. I.e. don't rely on stdin to answer if you have a question.

  • I have a problem withInvalid file index 1 in filtergraph description

    17 avril 2019, par Davide

    This is my code:

    ffmpeg -i wireframe-spendo.mov palette.png -filter_complex fps=25,scale=800:600:flags=lanczos[x],[x][1:v]paletteuse wireframe-spendo.gif
    

    but after then:

    ffmpeg -i wireframe-spendo.mov palette.png -filter_complex fps=25,scale=800:600:flags=lanczos[x],[x][1:v]paletteuse wireframe-spendo.gif
    ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
      built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
      configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.3 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/openjdk-12.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/openjdk-12.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
      libavutil      56. 22.100 / 56. 22.100
      libavcodec     58. 35.100 / 58. 35.100
      libavformat    58. 20.100 / 58. 20.100
      libavdevice    58.  5.100 / 58.  5.100
      libavfilter     7. 40.101 /  7. 40.101
      libavresample   4.  0.  0 /  4.  0.  0
      libswscale      5.  3.100 /  5.  3.100
      libswresample   3.  3.100 /  3.  3.100
      libpostproc    55.  3.100 / 55.  3.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'wireframe-spendo.mov':
      Metadata:
        major_brand     : qt  
        minor_version   : 0
        compatible_brands: qt  
        creation_time   : 2019-04-17T09:38:24.000000Z
        com.apple.quicktime.make: Apple
        com.apple.quicktime.model: iMac12,2
        com.apple.quicktime.software: Mac OS X 10.13.6 (17G6029)
        com.apple.quicktime.creationdate: 2019-04-17T11:37:00+0200
      Duration: 00:00:16.42, start: 0.000000, bitrate: 3170 kb/s
        Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1476x1074 [SAR 1:1 DAR 246:179], 3163 kb/s, 60 fps, 60 tbr, 6k tbn, 12k tbc (default)
        Metadata:
          creation_time   : 2019-04-17T09:38:24.000000Z
          handler_name    : Core Media Video
          encoder         : H.264
    

    output terminal says:

    Invalid file index 1 in filtergraph description fps=25,scale=800:600:flags=lanczos[x],[x][1:v]paletteuse.