baowenbo / DAIN

Depth-Aware Video Frame Interpolation (CVPR 2019)
https://sites.google.com/view/wenbobao/dain
MIT License
8.19k stars 840 forks source link

Colab—# ffmpeg extract #115

Open oghaki opened 3 years ago

oghaki commented 3 years ago

Hey, not sure if this is where I should be reporting issues for the Colab version, but when I get to the '# ffmpeg extract' step, I'm getting an attribute error. I've tried this with a few different video files, using different containers and different encoding, but I still get errors each time. The file that produced this output was a GIF (320 × 178 @ 33.333 fps, 3.33 seconds) I converted to different formats. I started off using H.264 (High@L4.2, 8bpc, YUV 4:2:0), and the version that produced the output below was GIFMOV(PNG encoding)remux: MKV. Here is the console output from the error:

110
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-14-8da4460b8bf0> in <module>()
     18   frame_count += 1
     19   first_frame = f"{FRAME_INPUT_DIR}/00001.png"
---> 20   new_last_frame = f"{FRAME_INPUT_DIR}/{frame_count.zfill(5)}.png"
     21   shutil.copyfile(first_frame, new_last_frame)
     22 

...and here is the code it ran pulled from the console:

# ffmpeg extract - Generating individual frame PNGs from the source file.
%shell rm -rf '{FRAME_INPUT_DIR}'
%shell mkdir -p '{FRAME_INPUT_DIR}'

if (END_FRAME==-1):
  %shell ffmpeg -i '/content/DAIN/{filename}' -vf 'select=gte(n\,{START_FRAME}),setpts=PTS-STARTPTS' '{FRAME_INPUT_DIR}/%05d.png'
else:
  %shell ffmpeg -i '/content/DAIN/{filename}' -vf 'select=between(n\,{START_FRAME}\,{END_FRAME}),setpts=PTS-STARTPTS' '{FRAME_INPUT_DIR}/%05d.png'

from IPython.display import clear_output
clear_output()

png_generated_count_command_result = %shell ls '{FRAME_INPUT_DIR}' | wc -l
frame_count = int(png_generated_count_command_result.output.strip())

import shutil
if SEAMLESS:
  frame_count += 1
  first_frame = f"{FRAME_INPUT_DIR}/00001.png"
  new_last_frame = f"{FRAME_INPUT_DIR}/{frame_count.zfill(5)}.png"
  shutil.copyfile(first_frame, new_last_frame)

print(f"{frame_count} frame PNGs generated.")
AlphaGit commented 3 years ago

Hi! Yes, you're in the right place. Thank you for reporting this.

The info you've provided seems to be enough for me to investigate a bit further. I'll get back to you soon with what I find.

AlphaGit commented 3 years ago

Hi there! Indeed, this is a problem when using the seamless option. That line of code that fails fails because of a wrong type conversion.

This is the full error (the last part is the one giving the actual error message):

15
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-12-8da4460b8bf0> in <module>()
     18   frame_count += 1
     19   first_frame = f"{FRAME_INPUT_DIR}/00001.png"
---> 20   new_last_frame = f"{FRAME_INPUT_DIR}/{frame_count.zfill(5)}.png"
     21   shutil.copyfile(first_frame, new_last_frame)
     22 

AttributeError: 'int' object has no attribute 'zfill'

I'll send a PR with a fix, but in the meantime, you can change this line:

  new_last_frame = f"{FRAME_INPUT_DIR}/{frame_count.zfill(5)}.png"

into this:

  new_last_frame = f"{FRAME_INPUT_DIR}/{str(frame_count).zfill(5)}.png"

You should be able to continue from there!

oghaki commented 3 years ago

Awesome, thank you very much

Sent from my iPhone

On Nov 7, 2020, at 11:31 PM, Alpha notifications@github.com wrote:



Hi there! Indeed, this is a problem when using the seamless option. That line of code that fails fails because of a wrong type conversion.

This is the full error (the last part is the one giving the actual error message):

``python 15

AttributeError Traceback (most recent call last) in () 18 frame_count += 1 19 first_frame = f"{FRAME_INPUT_DIR}/00001.png" ---> 20 new_last_frame = f"{FRAME_INPUT_DIR}/{frame_count.zfill(5)}.png" 21 shutil.copyfile(first_frame, new_last_frame) 22

AttributeError: 'int' object has no attribute 'zfill'

I'll send a PR with a fix, but in the meantime, you can change this line:


  new_last_frame = f"{FRAME_INPUT_DIR}/{frame_count.zfill(5)}.png"

into this:

  new_last_frame = f"{FRAME_INPUT_DIR}/{str(frame_count).zfill(5)}.png"

You should be able to continue from there!

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fbaowenbo%2FDAIN%2Fissues%2F115%23issuecomment-723529278&data=04%7C01%7C%7Cf0ce5a5977b041d555e908d8839f31c6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637404067035043682%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=aiI%2BELSso65jOP%2BNMZeb8YlpodpxFwW3rW%2FqjUnvo88%3D&reserved=0>, or unsubscribe<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FADAXSRSAOFDCRBQHXBLZNJLSOYNK5ANCNFSM4TOBNVNA&data=04%7C01%7C%7Cf0ce5a5977b041d555e908d8839f31c6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637404067035053676%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3DxTsF6cd1Rs4Gav0ymMtA30WEtORf3onYwA6jyDxfU%3D&reserved=0>.