Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • how to solve ffmpeg video merging complain about parameters mismatching

    22 septembre 2019, par mohammad rostami siahgeli

    I'm trying to concatenate an intro video to a main video. Here's my command:

    ffmpeg -i C:\Temp\intro.mp4 -i C:\Temp\main.mp4 -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" C:\Temp\output.mp4
    

    When I run this command in cmd, I get the following error:

    ffmpeg version N-95004-g2f87c9f646 Copyright (c) 2000-2019 the FFmpeg developers
      built with gcc 9.2.1 (GCC) 20190918
      configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
      libavutil      56. 35.100 / 56. 35.100
      libavcodec     58. 58.101 / 58. 58.101
      libavformat    58. 33.100 / 58. 33.100
      libavdevice    58.  9.100 / 58.  9.100
      libavfilter     7. 58.102 /  7. 58.102
      libswscale      5.  6.100 /  5.  6.100
      libswresample   3.  6.100 /  3.  6.100
      libpostproc    55.  6.100 / 55.  6.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\intro.mp4':
      Metadata:
        major_brand     : mp42
        minor_version   : 0
        compatible_brands: mp42mp41
        creation_time   : 2019-09-21T09:23:34.000000Z
      Duration: 00:00:07.32, start: 0.000000, bitrate: 706 kb/s
        Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 960x540, 323 kb/s, 15 fps, 15 tbr, 30k tbn, 30 tbc (default)
        Metadata:
          creation_time   : 2019-09-21T09:23:34.000000Z
          handler_name    : ?Mainconcept Video Media Handler
          encoder         : AVC Coding
        Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
        Metadata:
          creation_time   : 2019-09-21T09:23:34.000000Z
          handler_name    : #Mainconcept MP4 Sound Media Handler
    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\main.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf56.40.101
      Duration: 00:00:08.78, start: 0.000000, bitrate: 499 kb/s
        Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x640 [SAR 1:1 DAR 1:1], 430 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
    Stream mapping:
      Stream #0:0 (h264) -> concat:in0:v0
      Stream #0:1 (aac) -> concat:in0:a0
      Stream #1:0 (h264) -> concat:in1:v0
      Stream #1:1 (aac) -> concat:in1:a0
      concat:out:v0 -> Stream #0:0 (libx264)
      concat:out:a0 -> Stream #0:1 (aac)
    Press [q] to stop, [?] for help
    [Parsed_concat_0 @ 0000018168eedec0] Input link in0:v0 parameters (size 640x640, SAR 1:1) do not match the corresponding output link in0:v0 parameters (960x540, SAR 1:1)
    [Parsed_concat_0 @ 0000018168eedec0] Failed to configure output pad on Parsed_concat_0
    Error reinitializing filters!
    Failed to inject frame into filter network: Invalid argument
    Error while processing the decoded data for stream #1:0
    Conversion failed!
    

    I'm not a video ninja. I know parameters are different, but I have no idea after hours of search on how to solve this. A lot of online video services concatenate these two videos and give me a reasonable result. They have a GUI though. I need to do it in code, so that I can automate it.

    How can I solve these errors?

    Update: This is the second error:

    ffmpeg version N-95004-g2f87c9f646 Copyright (c) 2000-2019 the FFmpeg developers
      built with gcc 9.2.1 (GCC) 20190918
      configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
      libavutil      56. 35.100 / 56. 35.100
      libavcodec     58. 58.101 / 58. 58.101
      libavformat    58. 33.100 / 58. 33.100
      libavdevice    58.  9.100 / 58.  9.100
      libavfilter     7. 58.102 /  7. 58.102
      libswscale      5.  6.100 /  5.  6.100
      libswresample   3.  6.100 /  3.  6.100
      libpostproc    55.  6.100 / 55.  6.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\intro.mp4':
      Metadata:
        major_brand     : mp42
        minor_version   : 0
        compatible_brands: mp42mp41
        creation_time   : 2019-09-21T09:23:34.000000Z
      Duration: 00:00:07.32, start: 0.000000, bitrate: 706 kb/s
        Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 960x540, 323 kb/s, 15 fps, 15 tbr, 30k tbn, 30 tbc (default)
        Metadata:
          creation_time   : 2019-09-21T09:23:34.000000Z
          handler_name    : ?Mainconcept Video Media Handler
          encoder         : AVC Coding
        Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)
        Metadata:
          creation_time   : 2019-09-21T09:23:34.000000Z
          handler_name    : #Mainconcept MP4 Sound Media Handler
    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Temp\main.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf56.40.101
      Duration: 00:00:08.78, start: 0.000000, bitrate: 499 kb/s
        Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x640 [SAR 1:1 DAR 1:1], 430 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
    File 'C:\Temp\output.mp4' already exists. Overwrite ? [y/N] Y
    Stream mapping:
      Stream #0:0 (h264) -> scale
      Stream #0:1 (aac) -> concat:in0:a0
      Stream #1:0 (h264) -> concat:in1:v0
      Stream #1:1 (aac) -> concat:in1:a0
      concat:out:v0 -> Stream #0:0 (libx264)
      concat:out:a0 -> Stream #0:1 (aac)
    Press [q] to stop, [?] for help
    [mp4 @ 000002f17869d7c0] Frame rate very high for a muxer not efficiently supporting it.
    Please consider specifying a lower framerate, a different muxer or -vsync 2
    [libx264 @ 000002f178acfec0] using SAR=1/1
    [libx264 @ 000002f178acfec0] MB rate (1600000000) > level limit (16711680)
    [libx264 @ 000002f178acfec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
    [libx264 @ 000002f178acfec0] profile High, level 6.2, 4:2:0, 8-bit
    [libx264 @ 000002f178acfec0] 264 - core 158 r2984 3759fcb - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    More than 1000 frames duplicated
    Too many packets buffered for output stream 0:0.
    [libx264 @ 000002f178acfec0] frame I:1     Avg QP:16.45  size:  4679
    [libx264 @ 000002f178acfec0] frame P:32    Avg QP:14.16  size:    33
    [libx264 @ 000002f178acfec0] frame B:96    Avg QP:17.67  size:    30
    [libx264 @ 000002f178acfec0] consecutive B-frames:  0.8%  0.0%  0.0% 99.2%
    [libx264 @ 000002f178acfec0] mb I  I16..4: 58.1% 34.8%  7.1%
    [libx264 @ 000002f178acfec0] mb P  I16..4:  0.1%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:99.9%
    [libx264 @ 000002f178acfec0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.8%  0.0%  0.0%  direct: 0.0%  skip:99.2%  L0: 0.0% L1:100.0% BI: 0.0%
    [libx264 @ 000002f178acfec0] 8x8 transform intra:33.8%
    [libx264 @ 000002f178acfec0] coded y,uvDC,uvAC intra: 4.6% 8.2% 7.3% inter: 0.0% 0.0% 0.0%
    [libx264 @ 000002f178acfec0] i16 v,h,dc,p: 74% 22%  5%  0%
    [libx264 @ 000002f178acfec0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  1% 16% 83%  0%  0%  0%  0%  0%  0%
    [libx264 @ 000002f178acfec0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 17% 26%  7%  5%  5%  5%  6%  5%
    [libx264 @ 000002f178acfec0] i8c dc,h,v,p: 93%  3%  3%  1%
    [libx264 @ 000002f178acfec0] Weighted P-Frames: Y:0.0% UV:0.0%
    [libx264 @ 000002f178acfec0] ref P L0: 62.5% 37.5%
    [libx264 @ 000002f178acfec0] ref B L1: 99.8%  0.2%
    [libx264 @ 000002f178acfec0] kb/s:535069.75
    Conversion failed!
    
  • Why does ffmpeg stop recording at midnight ?

    22 septembre 2019, par peter

    I have a shellscript like this under Kubuntu 19.10,

    #!/bin/bash
    
    while true
    do
        FILE=/media/petermc/Security5/Camera2/Camera2_.mp4  
        FILE=${FILE%.*}`date +%Y-%m-%d_%H-%M-%S-%N`.${FILE#*.}
        echo $FILE
    
        ffmpeg -rtsp_transport tcp -t 00:15:00 -i rtsp://*user*:*password*@192.168.1.60:554/ch02/0 -c copy -map 0 $FILE
    done
    

    It records files like this,

    Camera2_2019-09-21_23-36-57-874602376.mp4
    Camera2_2019-09-21_23-51-57-876639147.mp4
    

    Basically recording 15 minutes at a time from the RTSP feed, then starting a new file.

    However it stops working at midnight, the last few lines from the log file are this,

    frame= 3987 fps= 13 q=-1.0 size=  117760kB time=00:05:06.51 bitrate=3147.3kbits/s speed=1.01x    
    frame= 3994 fps= 13 q=-1.0 size=  118016kB time=00:05:07.07 bitrate=3148.4kbits/s speed=1.01x    
    frame= 4001 fps= 13 q=-1.0 size=  118016kB time=00:05:07.59 bitrate=3143.1kbits/s speed=1.01x    
    frame= 4008 fps= 13 q=-1.0 size=  118272kB time=00:05:08.11 bitrate=3144.6kbits/s speed=1.01x 
    

    So there doesn't seem to be any error, it stops recording at 5 minutes into the last file with no error.

    Another piece of information is that I have 6 cameras, and 4 stopped recording, the ones connected to a DVR. I have a couple of IP cameras and they kept recording.

    What could be the cause of this? Plus, what else could I do to work around this or diagnose this?

    UPDATE:

    I believe the issue is because the DVR has a maintenance setup to restart once at week at midnight. If this is what happened, is there any way I can configure ffmpeg to restart if it has lost the stream?

  • Compressing videos from a smartphone

    21 septembre 2019, par fejesjoco

    I have a Nexus 6p with the stock camera. It's set to record at 1080p, 30fps. Here's a 5 second sample (11 MB).

    Videos from this phone come out at about 17 Mbps on average. I tried to compress it with ffmpeg with -c:v libx264 -crf 23 -preset veryslow, the result comes out at about 5.5 MB, which is about 9 Mbps.

    I think this bitrate is a bit too much. When I look at torrent file listings, I can see high quality videos at 3 GB in size on average, and if such a movie is 90 minutes long on average, that is about 4-5 Mbps which sounds okay.

    I'm wondering, why the big difference? I can notice that my video is noisy/grainy (which is expected from a phone), and that might reduce compressibility. I tried a few ffmpeg filters, like hqdn3d and atadenoise, but the noise mostly remained (maybe I didn't play with it enough). Then I figured, the video is also shaky (which is also expected), and that might reduce compressibility too (and even makes temporal noise filtering less effective). I tried to stabilize it with the deshake filter, but that didn't help either.

    I know I could just limit the bandwidth to whatever I like, but there must be a reason why ffmpeg thinks it needs a high bandwidth to maintain a certain quality, and a lower bandwidth would just decrease the quality.

    Why do these videos have such a high bitrate? What's the best way to compress them more while keeping or even increasing their quality?

  • pydub no ffprobe found

    21 septembre 2019, par Virgil Sisoe

    I have an app for MacOS that is compiled with py2app. The app uses the pydub module and the latter uses ffmpeg family package.

    The problem is that once I compile the app and move it to a different OS, the subprocess call from pydub fails to find any of the ffmpeg packages even though they are installed in /usr/local/bin.

    If I launch the app from terminal ./Nameapp.app/Contents/MacOs/Nameapp then it runs no problem, but if I launch it with double click then pydub complains not finding the packages and the app hangs where ffmpeg/ffprobe should do the work.

    I can see that pydub searches in the /usr/local/bin only if launched from terminal, otherwise no. If I add /usr/local/bin to PATH, pydub doesnt complain anymore that it doesnt find ffmpeg/ffprobe, but it still gives me an error for both ffmpeg and ffprobe: [Errno 2] No such file or directory:.

    If I hardcode the path pydub.AudioSegment.converter = "/usr/local/bin/ffmpeg", the app gives me only ffprobe error [Errno 2] No such file or directory:'ffprobe': 'ffprobe'.

    On some other posts i've seen pydub.AudioSegment.ffprobe = "/path/to/ffprobe" but it doesnt seem to work in my case?

    So my two questions are:

    How to hardcode the ffprobe path in pydub?
    How to solve this without hardcoding path?

  • How can I use FFMPEG in my discord bot thats on github

    21 septembre 2019, par Waldre

    I moved my discord bot to GitHub and Heroku today, everything works fine but I get this error that causes the bot to stop working

    I have already tried adding FFmpeg as a submodule by doing this:

    git submodule add git://source.ffmpeg.org/ffmpeg FFmpeg but it still doesn't work

    These are the errors I'm getting

    2019-09-21T14:03:30.753963+00:00 heroku[web.1]: State changed from starting to crashed

    2019-09-21T14:03:30.641312+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

    2019-09-21T14:03:30.641385+00:00 heroku[web.1]: Stopping process with SIGKILL

    2019-09-21T14:03:30.730681+00:00 heroku[web.1]: Process exited with status 137

    2019-09-21T14:10:20.814035+00:00 app[worker.1]: [36m| I: Prefix was used by RoyaleNiteTM. COMMAND USED : join |[0m

    2019-09-21T14:10:20.832129+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Error: FFMPEG not found

    2019-09-21T14:10:20.832138+00:00 app[worker.1]: at Function.selectFfmpegCommand (/app/node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js:46:13)

    2019-09-21T14:10:20.832141+00:00 app[worker.1]: at new FfmpegTranscoder (/app/node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js:7:37)

    2019-09-21T14:10:20.832143+00:00 app[worker.1]: at new MediaTranscoder (/app/node_modules/prism-media/src/transcoders/MediaTranscoder.js:10:19)

    2019-09-21T14:10:20.832145+00:00 app[worker.1]: at new Prism (/app/node_modules/prism-media/src/Prism.js:5:23)

    2019-09-21T14:10:20.832147+00:00 app[worker.1]: at new VoiceConnection (/app/node_modules/discord.js/src/client/voice/VoiceConnection.js:46:18)

    2019-09-21T14:10:20.832150+00:00 app[worker.1]: at Promise (/app/node_modules/discord.js/src/client/voice/ClientVoiceManager.js:63:22)

    2019-09-21T14:10:20.832154+00:00 app[worker.1]: at new Promise ()

    2019-09-21T14:10:20.832156+00:00 app[worker.1]: at ClientVoiceManager.joinChannel (/app/node_modules/discord.js/src/client/voice/ClientVoiceManager.js:45:12)

    2019-09-21T14:10:20.832158+00:00 app[worker.1]: at VoiceChannel.join (/app/node_modules/discord.js/src/structures/VoiceChannel.js:130:30)

    2019-09-21T14:10:20.832160+00:00 app[worker.1]: at Client. (/app/index.js:227:53)

    2019-09-21T14:10:20.832203+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

    2019-09-21T14:10:20.832279+00:00 app[worker.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

    2019-09-21T14:25:08.488516+00:00 heroku[worker.1]: State changed from up to crashed

    2019-09-21T14:25:08.464878+00:00 heroku[worker.1]: Process exited with status 1`