jim-easterbrook / Photini

An easy to use digital photograph metadata (Exif, IPTC, XMP) editing application.
https://photini.readthedocs.io/
GNU General Public License v3.0
157 stars 24 forks source link

Are video files supported? #31

Closed ericdanan closed 7 years ago

ericdanan commented 7 years ago

Hello,

I see in the changelog "started adding support for video files", and that the Open Images dialog offers to select video files. But Photini crashes ("pythonw.exe has stopped working") as soon as I open a video file. I am using the latest version 2017.6.0 windows installer on Windows 10. I have tried with several AVI and MP4 videos.

So I wonder if perhaps video support is not complete yet? Or a specific issue with the Windows version? Or is it supposed to work and perhaps something wrong on my machine?

Thanks in advance.

jim-easterbrook commented 7 years ago

Video support is currently a bit experimental. The Exiv2 metadata library can optionally be compiled with video support - I've tried this on a Linux machine and it crashed when opening video files. On Windows I just use the ready built version from https://sourceforge.net/projects/pygobjectwin32/. I've not tested this with video files, but will have a go later today. When the Exiv2 library doesn't support video, as on most Linux installations, Photini just uses an XML sidecar file to store metadata. This means you don't get the camera generated info such as time and date of the photograph.

jim-easterbrook commented 7 years ago

Running Photini from a Windows 7 command window (see http://photini.readthedocs.io/en/latest/other/installation.html#troubleshooting) I get this when I open a video file:

C:\Users\Jim\Documents\GitHub\Photini>python -m photini.editor -t -v
terminate called after throwing an instance of 'Exiv2::BasicError<char>'
  what():  The memory contains data of an unknown image type

C:\Users\Jim\Documents\GitHub\Photini>

It appears this is a C++ exception that is not being caught in Python, where I could do something about it. I'll investigate further.

jim-easterbrook commented 7 years ago

I've found a workaround. Using the 'pgi' Python interface to GObject instead of the 'PyGObject' interface avoids the problematic library function. You can test this by opening a command window (as in the 'troubleshooting' documentation mentioned above) and installing pgi:

pip install pgi

Do let me know if this works for you, and if you run into any other problems. Photini's support for video files will be minimal, as the installed version of the Exiv2 library doesn't handle them. I hope to improve this in future.

jim-easterbrook commented 7 years ago

I've managed to build and install GExiv2 on my main Linux box so it doesn't crash now. Exiv2 can't write to video files as far as I can tell, so all new/changed metadata has to be stored in sidecar files. The data fields are very different to still images, so there's some work in getting Photini to read them. There's also a lack of consistency between camera makers, e.g. time stamps relative to 1970 vs 1904.

ericdanan commented 7 years ago

Thanks a lot for your detailed answers.

When I open Photini from the Windows 10 command prompt as per the troubleshooting documentation, I get a different error:

(python.exe :4464): GLib-ERROR **- gmem.c:165: failed to allocate 536870912 bytes

The file I am opening is an mp4 file, and from the Windows file properties its size is 380178432 bytes.

If I install pgi from the command prompt, I am indeed able to open the video file in photini. It has no thumbnail. I successfully added a title to it and an XMP sidecar file was created. I didn't test further, in what sense is video support "minimal" ?

jim-easterbrook commented 7 years ago

I've written some documentation about video support in the current development version of Photini: http://photini.readthedocs.io/en/latest/manual/video.html In summary, you can add metadata (to an XMP sidecar) but you can't read any metadata that might be present in the video file. Usually there isn't much of any use to Photini except the timestamps.

ericdanan commented 7 years ago

I see. I think the windows version with pgi will be good enough for me, but I'm not sure whether you want to close the issue since you added a the "bug" label so I prefer to leave that up to you.

Thanks again.

jim-easterbrook commented 7 years ago

I need to make sure I include pgi in the next Windows installer release. I'm currently having problems with the exiv2 library crashing if I do anything with an XMP namespace it doesn't know about. I may end up trying to compile my own copies of gexiv2 and exiv2 with video support. There's a bit of a learning curve before I get there though.

jim-easterbrook commented 7 years ago

Today I've succeeded in building exiv2 on Windows using MinGW. I have an executable exiv2.exe that can be run from a Windows command shell and reads video files. Tomorrow I'll try and build GExiv2, which I suspect will be a bit more difficult. [Edit - building GExiv2 was a lot more difficult. I gave up, after I found a pre-built version with video support!]

jim-easterbrook commented 7 years ago

Release 2017.8.0 includes a Windows installer that has video support. As well as reading metadata from video files it can read image data to generate a thumbnail. (The extra libraries required have doubled the size of the installer though.)

ericdanan commented 7 years ago

This is great news! I'm on a bad internet connection currently and unable to download the installer, but I will try the new version ASAP.

ericdanan commented 7 years ago

Just tried and it is working as expected. Thanks a lot!