Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Frames Error #197

Open
YoiLikeOrange opened this issue Jul 28, 2020 · 14 comments
Open

Video Frames Error #197

YoiLikeOrange opened this issue Jul 28, 2020 · 14 comments

Comments

@YoiLikeOrange
Copy link

I've been trying different things for a few hours now to get my video to run, and I think it may be the video itself even though I just rendered it myself in Adobe. It's cropped appropriately at 1:1, an MP4, and I really don't know what to do now.

Is there maybe a preferred video format I should be using? I noticed other videos are MP4 that are in the model folder so I didn't know if that would be the case. Anyone able to give me advice? I've looked into other issues on here but none of them seemed to help me.

Here's the error:

RuntimeError                              Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/imageio/plugins/ffmpeg.py in _read_frame_data(self)
   620                     raise RuntimeError(
--> 621                         "Frame is %i bytes, but expected %i." % (len(s), framesize)
   622                     )

RuntimeError: Frame is 0 bytes, but expected 12288.

During handling of the above exception, another exception occurred:

CannotReadFrameError                      Traceback (most recent call last)
5 frames
/usr/local/lib/python3.6/dist-packages/imageio/plugins/ffmpeg.py in _read_frame_data(self)
   626                 err2 = self._stderr_catcher.get_text(0.4)
   627                 fmt = "Could not read frame %i:\n%s\n=== stderr ===\n%s"
--> 628                 raise CannotReadFrameError(fmt % (self._pos, err1, err2))
   629             return s, is_new
   630 

CannotReadFrameError: Could not read frame 1178:
Frame is 0 bytes, but expected 12288.
=== stderr ===
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
 built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
 configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
 libavutil      55. 78.100 / 55. 78.100
 libavcodec     57.107.100 / 57.107.100
 libavformat    57. 83.100 / 57. 83.100
 libavdevice    57. 10.100 / 57. 10.100
 libavfilter     6.107.100 /  6.107.100
 libavresample   3.  7.  0 /  3.  7.  0
 libswscale      4.  8.100 /  4.  8.100
 libswresample   2.  9.100 /  2.  9.100
 libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/content/gdrive/My Drive/first-order-motion-model/DBnuggest_1.mp4':
 Metadata:
   major_brand     : mp42
   minor_version   : 0
   compatible_brands: mp42mp41
   creation_time   : 2020-07-28T17:25:57.000000Z
 Duration: 00:00:19.71, start: 0.000000, bitrate: 368 kb/s
   Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 64x64, 186 kb/s, 60 fps, 60 tbr, 60k tbn, 120 tbc (default)
   Metadata:
     creation_time   : 2020-07-28T17:25:58.000000Z
     handler_name    : Alias Data Handler
     encoder         : AVC Coding
   Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 32000 Hz, mono, fltp, 158 kb/s (default)
   Metadata:
     creation_time   : 2020-07-28T17:25:58.000000Z
     handler_name    : Alias Data Handler

I HAVE been able to use other videos successfully, so that;s what's making me wonder if it's the video itself.

@AliaksandrSiarohin
Copy link
Owner

AliaksandrSiarohin commented Jul 28, 2020

This is a bug in imageio, it fails to read last frame sometime. You could try to run ffmpeg -i video.mp4 out.mp4. Alternatively cover the reading procedure with try catch and save all frames exept last in to some list.

@YoiLikeOrange
Copy link
Author

YoiLikeOrange commented Jul 28, 2020

This is a bug in imageio, it fails to read last frame sometime. You could try to run ffmpeg -i video.mp4 out.mp4. Alternatively cover the reading procedure with try catch and save all frames exept last in to some list.

Ah okay. I should have also said I'm doing this strictly with the colab model. How would I go about the alt. method? I'm studying coding but I'm not too good at it myself yet haha.

I'll let you know if the first method works.

@AliaksandrSiarohin
Copy link
Owner

In colab you should use '!'.
So execute '! ffmpeg -i video.mp4 out.mp4' in some cell. But change the path to the input video.

@YoiLikeOrange
Copy link
Author

Okay, so it seemed to have ran. Do I just run the "Load driving video and source image" cell now? Tried to and I got the same result, I may be missing something.

@AliaksandrSiarohin
Copy link
Owner

AliaksandrSiarohin commented Jul 28, 2020

Yes, just change the path to output from ffmpeg.

@AliaksandrSiarohin
Copy link
Owner

AliaksandrSiarohin commented Jul 28, 2020

You can also replace reading of driving with this

    reader = imageio.get_reader(opt.driving_video)
    driving_video = []
    try:
        for im in reader:
            driving_video.append(im)
    except RuntimeError:
        pass
    reader.close()

@YoiLikeOrange
Copy link
Author

Sorry, I'm super slow! Would I replace this code driving_video = imageio.mimread('/content/gdrive/My Drive/first-order-motion-model/04.mp4') with the one you just posted?

@AliaksandrSiarohin
Copy link
Owner

Yes.

@YoiLikeOrange
Copy link
Author

YoiLikeOrange commented Jul 28, 2020

Okay, then I did do it right. Says this now after putting my video's path in between the brackets:

     10 source_image = imageio.imread('/content/gdrive/My Drive/first-order-motion-model/nickpfp.jpg')
---> 11 reader = imageio.get_reader(opt.driving_video)
     12 driving_video = ['/content/gdrive/My Drive/first-order-motion-model/04.mp4']
     13 try:

NameError: name 'opt' is not defined

Guessing I'm just missing something else to replace?

@AliaksandrSiarohin
Copy link
Owner

AliaksandrSiarohin commented Jul 28, 2020

In line 11 you should replace opt.driving_video with the path to your driving video.

@YoiLikeOrange
Copy link
Author

YoiLikeOrange commented Jul 28, 2020

Feel like we're almost there. New set of errors.

AttributeError                            Traceback (most recent call last)
<ipython-input-3-2edab7cb756d> in <module>()
     21 
     22 source_image = resize(source_image, (256, 256))[..., :3]
---> 23 driving_video = [resize(frame, (256, 256))[..., :3] for frame in driving_video]
     24 
     25 def display(source, driving, generated=None):

1 frames
/usr/local/lib/python3.6/dist-packages/skimage/transform/_warps.py in resize(image, output_shape, order, mode, cval, clip, preserve_range, anti_aliasing, anti_aliasing_sigma)
     89     output_shape = tuple(output_shape)
     90     output_ndim = len(output_shape)
---> 91     input_shape = image.shape
     92     if output_ndim > image.ndim:
     93         # append dimensions to input_shape

AttributeError: 'str' object has no attribute 'shape'

This is after replacing opt.driving_video.

@AliaksandrSiarohin
Copy link
Owner

Hmm, no you should replace argument of a function get_reader. get_reader('/...')

@YoiLikeOrange
Copy link
Author

Again, sorry if I am slow when it comes to this, but the error has now changed.

AttributeError                            Traceback (most recent call last)
<ipython-input-5-f720c248a959> in <module>()
      9 
     10 source_image = imageio.imread('/content/gdrive/My Drive/first-order-motion-model/nickpfp.jpg')
---> 11 reader = imageio.get_reader. get_reader('/content/gdrive/My Drive/first-order-motion-model/04.mp4')
     12 driving_video = ['/content/gdrive/My Drive/first-order-motion-model/damedamesource.mp4']
     13 try:

AttributeError: 'function' object has no attribute 'get_reader'

We'll get there!

@AliaksandrSiarohin
Copy link
Owner

Get_reader 2 times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants