tanersener/ffmpeg-video-slideshow-scripts

Concatenating video files are always throws an error

Closed this issue · 6 comments

I just downloaded scripts bundle v4 and trying to concatenate 2 videos from https://pixabay.com/videos/wheat-wheat-field-nature-17285 and I always got "Error initializing complex filters. Result too large" message.

Scripts I've tried to execute are

  • box*.sh
  • collapse*.sh
  • clock.sh
  • fade*.sh
  • rotate*.sh
  • push*.sh
  • wipe*.sh

Environment

  • Windows 10 64bit
  • 16 GB RAM
  • FFmpeg 4.3.1

Full logs from fade-in script

Video Slideshow Info
------------------------
Media count: 2
Dimension: 1280x720
FPS: 30
Image duration: 4 s
Transition duration: 1 s

ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.2.1 (GCC) 20200726
  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-libsrt --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-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'media/field.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41isomavc1
    creation_time   : 2018-07-15T03:19:17.000000Z
  Duration: 00:00:28.23, start: 0.000000, bitrate: 2491 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720, 2485 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 120k tbc (default)
    Metadata:
      creation_time   : 2018-07-15T03:19:17.000000Z
      handler_name    : L-SMASH Video Handler
      encoder         : AVC Coding
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'media/field2.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42mp41isomavc1
    creation_time   : 2018-07-15T03:19:17.000000Z
  Duration: 00:00:28.23, start: 0.000000, bitrate: 2491 kb/s
    Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720, 2485 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 120k tbc (default)
    Metadata:
      creation_time   : 2018-07-15T03:19:17.000000Z
      handler_name    : L-SMASH Video Handler
      encoder         : AVC Coding
Input #2, lavfi, from 'aevalsrc=0':
  Duration: N/A, start: 0.000000, bitrate: 2822 kb/s
    Stream #2:0: Audio: pcm_f64le, 44100 Hz, mono, dbl, 2822 kb/s
[trim @ 0596d640] Value -30.000000 for parameter 'end_frame' out of range [0 - 9.22337e+18]
    Last message repeated 1 times
[trim @ 0596d640] Error setting option end_frame to value -30.
[Parsed_trim_15 @ 0594f840] Error applying options to the filter.
[AVFilterGraph @ 05908640] Error initializing filter 'trim' with args 'start_frame=0:end_frame=-30'
Error initializing complex filters.
Result too large

I'm not sure whether or not the problem occurs while calculating frame count. But I can confirm that CALCULATED_FRAME_COUNT variable is always empty/null.

These scripts are bash scripts. Some of the functions used inside them are not available in other terminals. How do you run them under Windows, do you have a bash terminal?

This is the error. end_frame shouldn't be -30.

'trim' with args 'start_frame=0:end_frame=-30'

I'm using git bash window.

Do you have another bash emulator in your machine?

It looks like the bash implementation in git for windows does not support some of the expressions used in the video scrips. The problem is, on Windows, there does not exist a standard bash terminal. There are different implementations and it is hard to test & support all of them. And, I don't want to modify the scripts to support a specific Windows bash implementation.

So, I'll suggest using another bash terminal if you can. If you don't want to try or it does not help, I'll refund the amount to your account.

No problem, I solved the issue by utilizing ffprobe to calculate number of frames. I don't know if this is the correct approach. Grabbing number of frames from .mf.counter file just doesn't works for me.

# TODO
# calculated frames count/(original FPS/desired fps)
CALCULATED_FRAME_COUNT=`ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 ${FILE}`

Well, not exactly. Each input video has a frame rate (A), and the scripts have a target frame rate (B). CALCULATED_FRAME_COUNT is used to calculate B.

Unfortunately your workaround calculates A using ffprobe and assigns it to B. If A and B is the same for your files then you won't have any issues. But if they're not then your slideshow may not run smoothly. You may see dropped frames during transitions.

I'll suggest using the original approach by updating that section about /tmp/.mf.counter and replacing it with a Windows compatible path, something like c:\temp\mf.counter.