scottpetrovic / animator-video-reference

A Python plugin for Krita 4.2 that allows you to load a video for reference and import frames to your document
GNU General Public License v3.0
45 stars 7 forks source link

Key Error: height #5

Open VickTL opened 4 years ago

VickTL commented 4 years ago

I encountered this problem when opening a mp4 file. It doesn't seem to be able to open it correctly. Ffmpeg is apparently working correctly.

image

This is the output I got, can't really work out what's the problem...

NotRuben commented 4 years ago

i have the same error, ive tried changing the resolution, copying the file, re downloading the file. converting it into other files beside mp4. and yet cant get it to work. ive used the plugin for 3 other videos and no problem but for some reason this one just dosent want to work. please tell me if you find a fix.

scottpetrovic commented 4 years ago

@NotRuben - what are you using to export out these videos. The tool that reads in the data here is "FFprobe" which comes with ffmpeg. It can not tell what the dimensions are for the video file. You can either try to link to the video file here, or manually run ffprobe from your computer to see where the video file is keeping that information. See this answer on how to check the video file manually with ffprobe... https://askubuntu.com/a/577431

NotRuben commented 4 years ago

I use sony vegas to render the clip... 1280x720 and now for some reason, I can't import any new videos to the plugin without getting this error.

NotRuben commented 4 years ago

KeyError Python 3.6.2: python Tue Mar 3 20:42:09 2020

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

C:\Users\heath\AppData\Roaming\krita\pykrita\animationimporter\animationimporter.py in signal_change_location(self=) 38 39 # run FFProbe to get vidoe info 40 self.findVideoMetada(self.fileName[0]) 41 42 # print(ffprobeOutput['streams'][0]['height']) self = self.findVideoMetada = <bound method Animationimporter.findVideoMetada ...rter.animationimporter.Animationimporter object>> self.fileName = ('C:/Users/heath/OneDrive/Desktop/Degalmagic.mp4', 'Videos(.mp4 .avi .mpg, .gif)')

C:\Users\heath\AppData\Roaming\krita\pykrita\animationimporter\animationimporter.py in findVideoMetada(self=, pathToInputVideo='C:/Users/heath/OneDrive/Desktop/Degalmagic.mp4') 243 244 self.ffprobeOutput = json.loads(self.ffprobeOutput) 245 self.ffprobeData_height = self.ffprobeOutput['streams'][0]['height'] 246 self.ffprobeData_width = self.ffprobeOutput['streams'][0]['width'] 247 self = self.ffprobeData_height undefined self.ffprobeOutput = {'streams': [{'avg_frame_rate': '0/0', 'bit_rate': '127997', 'bits_per_sample': 0, 'channel_layout': 'stereo', 'channels': 2, 'codec_long_name': 'AAC (Advanced Audio Coding)', 'codec_name': 'aac', 'codec_tag': '0x6134706d', 'codec_tag_string': 'mp4a', 'codec_time_base': '1/48000', ...}, {'avg_frame_rate': '60000/1001', 'bit_rate': '12254478', 'bits_per_raw_sample': '8', 'chroma_location': 'left', 'codec_long_name': 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10', 'codec_name': 'h264', 'codec_tag': '0x31637661', 'codec_tag_string': 'avc1', 'codec_time_base': '1001/120000', 'codec_type': 'video', ...}]} KeyError: 'height' cause = None class = <class 'KeyError'> context = None delattr = <method-wrapper 'delattr' of KeyError object> dict = {} dir = doc = 'Mapping key not found.' eq = <method-wrapper 'eq' of KeyError object> format = ge = <method-wrapper 'ge' of KeyError object> getattribute = <method-wrapper 'getattribute' of KeyError object> gt = <method-wrapper 'gt' of KeyError object> hash = <method-wrapper 'hash' of KeyError object> init = <method-wrapper 'init' of KeyError object> init_subclass = <built-in method init_subclass of type object> le = <method-wrapper 'le' of KeyError object> lt = <method-wrapper 'lt' of KeyError object> ne = <method-wrapper 'ne' of KeyError object> new = reduce = reduce_ex = <built-in method reduce_ex of KeyError object> repr = <method-wrapper 'repr' of KeyError object> setattr = <method-wrapper 'setattr' of KeyError object> setstate = sizeof = str = <method-wrapper 'str' of KeyError object> subclasshook = __suppress_context = False traceback__ = args = ('height',) with_traceback =

The above is a description of an error in a Python program. Here is the original traceback:

Traceback (most recent call last): File "C:\Users\heath\AppData\Roaming\krita\pykrita\animationimporter\animationimporter.py", line 40, in signal_change_location self.findVideoMetada(self.fileName[0]) File "C:\Users\heath\AppData\Roaming\krita\pykrita\animationimporter\animationimporter.py", line 245, in findVideoMetada self.ffprobeData_height = self.ffprobeOutput['streams'][0]['height'] KeyError: 'height'

NotRuben commented 4 years ago

please help i cant do anything

NotRuben commented 4 years ago

i have reinstalled krita, the plugin, and ffmpeg. ive restarted my pc. i have linked ffmpeg to krita and to environmental. but nothing is working.

scottpetrovic commented 4 years ago

@NotRuben - You are going to have to attach a small video file that is having issues so I can see what is going on. I haven't changed this plugin for a while, so there hasn't been an update to this that might have broken something. I am guessing this Vegas program is creating a video file that is either storing things in a different place...or just isn't storing anything at all with the dimensions.

NotRuben commented 4 years ago

I figured it out... kinda hard but.. -when rendering a video from sony vegas i bleive it stores stuff def. even changing the rendering options it still will not work.

so what i did was in sony vegas get the clip i would like to animate, when going to render it click "image sequence" select "PNG" select a place to output (AN EMPTY FOLDER) then click render.

i downloaded "virtualdub" a long time ago because i would make csgo edits and export the recordings as individual pngs for higher quality.

open virtualdub

file>open video file -goto the location of the output -CLICK THE FIRST IMAGE (i will inport all of the files automatically) -use the timeline on bottem of the program to make sure it is correct. -file>save as AVI.. -select location and name click "save"

open krita -tools>scripts>video reference -click the file icon top left of pop up -goto location of the AVI export

this is the only way i have found to edit a clip from sony vegas and use it in krita... if i find a simpler way ill let you know

thanks for your help!

scottpetrovic commented 4 years ago

alright. If you could send me a small sample video, I could try to import it and modify my plugin to look for other places that the height data might be stored in. That was the main reason I was interested in you uploading a video clip. That way you wouldn't need that workaround with however virtual dub is saving the video file.

NotRuben commented 4 years ago

i can do that, the only reason why i haven't sent the video is because i haven't been home. ive just been using chrome remote desktop and Teamviewer. I can record a sample video when i get home. ill link all the programs and files i use.

KnowZero commented 3 years ago

@NotRuben - Take a look at my pull request and see if it fixes your issue.

Looking at your error report

self.ffprobeOutput = {'streams': [{'avg_frame_rate': '0/0', 'bit_rate': '127997', 'bits_per_sample': 0, 'channel_layout': 'stereo', 'channels': 2, 'codec_long_name': 'AAC (Advanced Audio Coding)', 'codec_name': 'aac', 'codec_tag': '0x6134706d', 'codec_tag_string': 'mp4a', 'codec_time_base': '1/48000', ...}, {'avg_frame_rate': '60000/1001', 'bit_rate': '12254478', 'bits_per_raw_sample': '8', 'chroma_location': 'left', 'codec_long_name': 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10', 'codec_name': 'h264', 'codec_tag': '0x31637661', 'codec_tag_string': 'avc1', 'codec_time_base': '1001/120000', 'codec_type': 'video', ...}]}

Your first stream seems to be an AAC audio stream instead of a video stream. Obviously an audo stream has no height. The video stream is your 2nd stream.

The patch goes through the streams and picks the first video stream instead of the first stream. That should address your issue.

Try to see if it works.