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

Key Error: height #5

Open
VickTL opened this issue Nov 17, 2019 · 11 comments
Open

Key Error: height #5

VickTL opened this issue Nov 17, 2019 · 11 comments

Comments

@VickTL
Copy link

VickTL commented Nov 17, 2019

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
Copy link

NotRuben commented Mar 3, 2020

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
Copy link
Owner

@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
Copy link

NotRuben commented Mar 4, 2020

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
Copy link

NotRuben commented Mar 4, 2020

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=<animationimporter.animationimporter.Animationimporter object>)
38
39 # run FFProbe to get vidoe info
40 self.findVideoMetada(self.fileName[0])
41
42 # print(ffprobeOutput['streams'][0]['height'])
self = <animationimporter.animationimporter.Animationimporter object>
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=<animationimporter.animationimporter.Animationimporter object>, 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 = <animationimporter.animationimporter.Animationimporter object>
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 =
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 =
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
Copy link

NotRuben commented Mar 4, 2020

please help i cant do anything

@NotRuben
Copy link

NotRuben commented Mar 4, 2020

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
Copy link
Owner

@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
Copy link

NotRuben commented Mar 4, 2020

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
Copy link
Owner

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
Copy link

NotRuben commented Mar 4, 2020

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 added a commit to KnowZero/animator-video-reference that referenced this issue Nov 10, 2020
- Checks codec_type for video before setting which stream to use ( Should fix issue scottpetrovic#5 )
@KnowZero
Copy link

@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.

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

4 participants