sminterpolate icon indicating copy to clipboard operation
sminterpolate copied to clipboard

butterflow fails to write output when output rate is not 30fps

Open xorgy opened this issue 7 years ago • 5 comments

By sheer luck, I tried 30fps for my first run of butterflow, and it worked great. This was my incantation:

butterflow -e -m -v -r30 in.mp4 -o interp.mp4

(in.mp4 is a 24000/1001 1920x1040 video) It also succeeds with 30000 / 1001, 48000 / 1001, and 96000 / 1001 But when I tried it with 59.95, and 60, it fails

[aaron@aka Wall Street REMASTERED (1987) [1080p]]$ butterflow -e -m -v -r60 in.mp4 -o interp.mp4
[butterflow:INFO]: Version 0.2.3
[butterflow:INFO]: Cache directory:	/tmp/butterflow-0.2.3
[butterflow:INFO]: At least one compatible OpenCL device was detected
[butterflow:INFO]: Using device: Ellesmere (autoselected)
[butterflow:INFO]: Hardware acceleration is enabled
[butterflow:INFO]: Rendering:
[butterflow:INFO]: Sequence: Duration=0:00:10.110000 (10.11s), Frames=242, Rate=23.9760246277
[butterflow:INFO]: Subregion (0): Time=0:00:00-0:00:10.110000 Frames=0-241 Speed=1.0,Duration=?,Fps=?
[butterflow:INFO]: Rendering to:	in.24805.mp4
[butterflow:INFO]: Final destination:	interp.mp4
[butterflow:INFO]: [Subprocess] Opening a pipe to the video writer
[butterflow:INFO]: Rendering progress:	0.00%
[butterflow:INFO]: Start working on Subregion (0): Time=0:00:00-0:00:10.110000 Frames=0-241 Speed=1.0,Duration=?,Fps=?
[butterflow:INFO]: Frames in region:	0-241
[butterflow:INFO]: Region length:	242
[butterflow:INFO]: Region duration:	10.110000s
[butterflow:INFO]: Number of frame pairs:	241
[butterflow:INFO]: Interpolation rate:	2
[butterflow:INFO]: Time stepping:	0.333,0.667
[butterflow:INFO]: Frames to write:	606
[butterflow:INFO]: Will interpolate:	723
[butterflow:INFO]: Extra frames (to discard):	117
[butterflow:INFO]: Drop every:	6
[butterflow:INFO]: Dupe every:	0
[butterflow:INFO]: Ready to run:	242 times
[butterflow:INFO]: Showing a sample of the first and last 15 runs:
[butterflow:INFO]: To write: S0	I1,1	0.33%
[butterflow:INFO]: To write: S1	I2,0	0.83%
[butterflow:INFO]: To write: S2	I1,1	1.16%
[butterflow:INFO]: To write: S3	I1,1	1.49%
[butterflow:INFO]: To write: S4	I2,0	1.98%
[butterflow:INFO]: To write: S5	I1,1	2.31%
[butterflow:INFO]: To write: S6	I2,0	2.81%
[butterflow:INFO]: To write: S7	I1,1	3.14%
[butterflow:INFO]: To write: S8	I1,1	3.47%
[butterflow:INFO]: To write: S9	I2,0	3.96%
[butterflow:INFO]: To write: S10	I1,1	4.29%
[butterflow:INFO]: To write: S11	I2,0	4.79%
[butterflow:INFO]: To write: S12	I1,1	5.12%
[butterflow:INFO]: To write: S13	I1,1	5.45%
[butterflow:INFO]: To write: S14	I2,0	5.94%
[butterflow:INFO]: To write: S15	I1,1	6.27%
[butterflow:INFO]: <Snipping 212 runs from the console, but will update progress periodically every 21 frames rendered>
[butterflow:INFO]: <Rendering progress: 8.25%>
[butterflow:INFO]: <Rendering progress: 16.67%>
[butterflow:INFO]: <Rendering progress: 25.25%>
[butterflow:INFO]: <Rendering progress: 33.50%>
[butterflow:INFO]: <Rendering progress: 41.91%>
[butterflow:INFO]: <Rendering progress: 50.33%>
[butterflow:INFO]: <Rendering progress: 58.91%>
[butterflow:INFO]: <Rendering progress: 67.33%>
[butterflow:INFO]: <Rendering progress: 75.74%>
[butterflow:INFO]: <Rendering progress: 83.99%>
[butterflow:WARNING]: B is None
[butterflow:INFO]: To write: S216
[butterflow:WARNING]: Dropping S216
[butterflow:INFO]: Run 217 (this is the final run):
[butterflow:ERROR]: A is None
[butterflow:INFO]: To write: S217
Traceback (most recent call last):
  File "/usr/bin/butterflow", line 11, in <module>
    load_entry_point('butterflow==0.2.3', 'console_scripts', 'butterflow')()
  File "/usr/lib/python2.7/site-packages/butterflow/cli.py", line 441, in main
    number=1)
  File "/usr/lib/python2.7/timeit.py", line 237, in timeit
    return Timer(stmt, setup, timer).timeit(number)
  File "/usr/lib/python2.7/timeit.py", line 202, in timeit
    timing = self.inner(it, self.timer)
  File "/usr/lib/python2.7/timeit.py", line 100, in inner
    _func()
  File "/usr/lib/python2.7/site-packages/butterflow/render.py", line 467, in render
    self.render_subregion(sub)
  File "/usr/lib/python2.7/site-packages/butterflow/render.py", line 414, in render_subregion
    draw.draw_marker(fr, fill=fr_type == 'INTERPOLATED')
  File "/usr/lib/python2.7/site-packages/butterflow/draw.py", line 15, in wrapper
    scale = min(float(fr.shape[1]) / float(w_fits),
AttributeError: 'NoneType' object has no attribute 'shape'
[butterflow:INFO]: [Subprocess] Closing pipe to the video writer

It seems to be failing somewhere in the middle of the video output.

xorgy avatar Jun 10 '17 00:06 xorgy

Hi, I also encountered this problems, could you tell me how did you solve this problems?

sdlpkxd avatar Jul 02 '18 06:07 sdlpkxd

I have the same or atleast very similar issue:

> butterflow -v -r 60 file_out.mkv -o file_out3.mp4
[butterflow:INFO]: Version 0.2.3
[butterflow:INFO]: Cache directory:     c:\users\redacted\appdata\local\temp\butterflow-0.2.3
[butterflow:INFO]: At least one compatible OpenCL device was detected
[butterflow:INFO]: Using device: Tahiti (autoselected)
[butterflow:INFO]: Hardware acceleration is enabled
[butterflow:WARNING]: W: 854 > 256 but is not divisible by 4, setting to 852
[butterflow:INFO]: Rendering:
[butterflow:INFO]: Sequence: Duration=0:01:26.302000 (86.30s), Frames=2586, Rate=29.9700298309
[butterflow:INFO]: Subregion (0): Time=0:00:00-0:01:26.302000 Frames=0-2585 Speed=1.0,Duration=?,Fps=?
[butterflow:INFO]: Rendering to:        file_out.6348.mp4
[butterflow:INFO]: Final destination:   file_out3.mp4
[butterflow:INFO]: [Subprocess] Opening a pipe to the video writer
[butterflow:INFO]: Rendering progress:  0.00%
[butterflow:INFO]: Start working on Subregion (0): Time=0:00:00-0:01:26.302000 Frames=0-2585 Speed=1.0,Duration=?,Fps=?
[butterflow:INFO]: Frames in region:    0-2585
[butterflow:INFO]: Region length:       2586
[butterflow:INFO]: Region duration:     86.302000s
[butterflow:INFO]: Number of frame pairs:       2585
[butterflow:INFO]: Interpolation rate:  2
[butterflow:INFO]: Time stepping:       0.333,0.667
[butterflow:INFO]: Frames to write:     5178
[butterflow:INFO]: Will interpolate:    7755
[butterflow:INFO]: Extra frames (to discard):   2577
[butterflow:INFO]: Drop every:  3
[butterflow:INFO]: Dupe every:  0
[butterflow:INFO]: Ready to run:        2586 times
[butterflow:INFO]: Showing a sample of the first and last 15 runs:
[butterflow:INFO]: To write: S0 I1,1    0.04%
[butterflow:INFO]: To write: S1 I1,1    0.08%
[butterflow:INFO]: To write: S2 I1,1    0.12%
[butterflow:INFO]: To write: S3 I1,1    0.15%
[butterflow:INFO]: To write: S4 I1,1    0.19%
[butterflow:INFO]: To write: S5 I1,1    0.23%
[butterflow:INFO]: To write: S6 I1,1    0.27%
[butterflow:INFO]: To write: S7 I1,1    0.31%
[butterflow:INFO]: To write: S8 I1,1    0.35%
[butterflow:INFO]: To write: S9 I1,1    0.39%
[butterflow:INFO]: To write: S10        I1,1    0.42%
[butterflow:INFO]: To write: S11        I1,1    0.46%
[butterflow:INFO]: To write: S12        I1,1    0.50%
[butterflow:INFO]: To write: S13        I1,1    0.54%
[butterflow:INFO]: To write: S14        I1,1    0.58%
[butterflow:INFO]: To write: S15        I1,1    0.62%
[butterflow:INFO]: <Snipping 2556 runs from the console, but will update progress periodically every 255 frames rendered>
[butterflow:INFO]: <Rendering progress: 9.85%>
[butterflow:INFO]: <Rendering progress: 19.72%>
[butterflow:INFO]: <Rendering progress: 29.57%>
[butterflow:INFO]: <Rendering progress: 39.44%>
[butterflow:INFO]: <Rendering progress: 49.29%>
[butterflow:INFO]: <Rendering progress: 59.15%>
[butterflow:INFO]: <Rendering progress: 69.02%>
[butterflow:INFO]: <Rendering progress: 78.87%>
[butterflow:ERROR]: Couldn't read 2069 (will abort runs)
[butterflow:WARNING]: Setting B to None
[butterflow:WARNING]: B is None
[butterflow:INFO]: To write: S2068
[butterflow:WARNING]: Dropping S2068
[butterflow:INFO]: Run 2069 (this is the final run):
[butterflow:ERROR]: A is None
[butterflow:INFO]: To write: S2069
Traceback (most recent call last):
  File "C:/msys64/mingw64/lib/python2.7/site-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
  File "butterflow/__main__.py", line 12, in <module>
  File "butterflow/cli.py", line 441, in main
  File "C:/msys64/mingw64/lib/python2.7/timeit.py", line 237, in timeit
  File "C:/msys64/mingw64/lib/python2.7/timeit.py", line 202, in timeit
  File "C:/msys64/mingw64/lib/python2.7/timeit.py", line 100, in inner
  File "butterflow/render.py", line 467, in render
  File "butterflow/render.py", line 435, in render_subregion
AttributeError: 'NoneType' object has no attribute 'data'
[butterflow:INFO]: [Subprocess] Closing pipe to the video writer

pwindle avatar Aug 22 '18 06:08 pwindle

There might be an error in the original video file. You can try fixing it using the following command in ffmpeg:

ffmpeg -err_detect ignore_err -i input.mp4 -c copy -map 0:v -map 0:a output.mkv

This will instruct ffmpeg to copy the original file's video and audio streams into a new file/container, ignoring errors in the original file to the best of its ability and correctly encoding the savable frames into the new file.

Rerun butterflow on the output.mkv file and see if this helps.

wagesj45 avatar Aug 23 '18 18:08 wagesj45

Thanks @wagesj45 that works! I think I've figured it out what went wrong for me. TLDR: butterflow was looking for frames that didn't exist, because ffmpeg did not update frame rate metadata correctly after slowing video down with setpts.

I had already slowed my input file to 80% of the original speed with ffmpeg, then was trying to use butterflow to smooth it as ffmpeg minterpolate didn't work for me (I have since found out all I needed to do was change -filter to -filter:v. But butterflow works better anyway)

In the log I noticed there are 2586 frames and it errors on the 2069th frame: 2069 / 2586 = 0.800077 = 80%

So it is erroring 80% of the way through a video I have slowed to 80% the original frame rate. Original video is 30fps. After slowing it down it should be 24 fps, but the metadata still shows 2586 frames at 30fps: [butterflow:INFO]: Sequence: Duration=0:01:26.302000 (86.30s), Frames=2586, Rate=29.9700298309

After using your command, except I start with an mkv and convert to mp4, I get the correct 24fps metadata: [butterflow:INFO]: Sequence: Duration=0:01:26.289000 (86.29s), Frames=2069, Rate=23.9776325226

So I guess ffmpeg doesn't update frame rate metadata after changing video speed with setpts.

pwindle avatar Aug 24 '18 01:08 pwindle

Glad it worked for you. Though butterflow should be used on the original file so it has as much data to use for the new output as possible. It is possible to both upscale the frame rate and increase the duration as well.

wagesj45 avatar Aug 24 '18 05:08 wagesj45