mihir-io / MotionPhotoMuxer

Convert Apple Live Photos into Google Motion Photos
GNU General Public License v3.0
111 stars 28 forks source link

Py3exiv2 is not installing on Android #4

Closed gototheskinny closed 2 years ago

gototheskinny commented 2 years ago
~ $ python3 -m pip install -r /sdcard/requirements.txt
Collecting py3exiv2==0.9.3
  Using cached py3exiv2-0.9.3.tar.gz (36 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for py3exiv2, since package 'wheel' is not installed.
Installing collected packages: py3exiv2
  Running setup.py install for py3exiv2 ... error
  error: subprocess-exited-with-error

  × Running setup.py install for py3exiv2 did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      running install
      running build
      running build_py
      creating build
      creating build/lib.linux-aarch64-3.10
      creating build/lib.linux-aarch64-3.10/pyexiv2
      copying src/pyexiv2/__init__.py -> build/lib.linux-aarch64-3.10/pyexiv2
      copying src/pyexiv2/exif.py -> build/lib.linux-aarch64-3.10/pyexiv2
      copying src/pyexiv2/iptc.py -> build/lib.linux-aarch64-3.10/pyexiv2
      copying src/pyexiv2/metadata.py -> build/lib.linux-aarch64-3.10/pyexiv2
      copying src/pyexiv2/preview.py -> build/lib.linux-aarch64-3.10/pyexiv2
      copying src/pyexiv2/utils.py -> build/lib.linux-aarch64-3.10/pyexiv2
      copying src/pyexiv2/xmp.py -> build/lib.linux-aarch64-3.10/pyexiv2
      running build_ext
      building 'libexiv2python' extension
      creating build/temp.linux-aarch64-3.10
      creating build/temp.linux-aarch64-3.10/src
      aarch64-linux-android-clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fstack-protector-strong -O3 -fstack-protector-strong -O3 -fPIC -I/data/data/com.termux/files/usr/include/python3.10 -c src/exiv2wrapper.cpp -o build/temp.linux-aarch64-3.10/src/exiv2wrapper.o -g
      In file included from src/exiv2wrapper.cpp:27:
      src/exiv2wrapper.hpp:34:10: fatal error: 'boost/python.hpp' file not found
      #include "boost/python.hpp"
               ^~~~~~~~~~~~~~~~~~
      1 error generated.
      error: command '/data/data/com.termux/files/usr/bin/aarch64-linux-android-clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> py3exiv2

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

My device is : Samsung Galaxy Note Fan edition A7.0

Ive tried several times its not working.

mihir-io commented 2 years ago

Looks like the Termux maintainers split apart the boost package into the main package and the boost-headers package. Install the boost-headers package, then you should be able to do the python3 -m pip install -r /sdcard/requirements.txt.

I'll update the README.md accordingly.

gototheskinny commented 2 years ago

I can confirm that issue is solved thank you for solving the issue.

gototheskinny commented 2 years ago
~ $ python3 /sdcard/MotionPhotoMuxer.py
Traceback (most recent call last):
  File "/sdcard/MotionPhotoMuxer.py", line 158, in <module>
    main(parser.parse_args())
  File "/sdcard/MotionPhotoMuxer.py", line 145, in main
    convert(photo_path, video_path)
  File "/sdcard/MotionPhotoMuxer.py", line 80, in convert
    validate_inputs(photo_path, video_path)
  File "/sdcard/MotionPhotoMuxer.py", line 18, in validate_inputs
    if not exists(photo_path):
  File "/data/data/com.termux/files/usr/lib/python3.10/genericpath.py", line 19, in exists
    os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

When i try to run this script I get this. Im not an expert at all so how can i run this script?

mihir-io commented 2 years ago

I should probably improve the error handling so that the error messages are more clear, but you need to provide either a video/photo pair, or a directory as an argument to the script. So basically, you need to run it in one of the following ways:

python3 /sdcard/MotionPhotoMuxer.py --photo <path to jpg file> --video <path to video file>

or

python3 /sdcard/MotionPhotoMuxer.py --dir <path to folder containing jpgs and mov/mp4 files>

If you use the second method, then it will only process files where the names are the same (only the extensions differ). For example, it will merge IMG_0001.jpg and IMG_0001.mov together, but if you have IMG_0001.jpg and IMG_0002.mov it will skip over those.

gototheskinny commented 2 years ago

Thank you so much literally there is nothing out there for this specific situation. I wish there is a gui for this script bc I dont know anything about coding.

mihir-io commented 2 years ago

Yeah, unfortunately I haven't had much time to work on this, but that would be a good idea. Maybe I'll look into it when my current semester is over.

gototheskinny commented 2 years ago
~ $ python3 /sdcard/MotionPhotoMuxer.py --dir /sdcard/other/ --verbose
INFO:root:Enabled verbose logging
INFO:root:Processing dir: /sdcard/other/
INFO:root:Looking for videos named: /sdcard/other/IMG_0964
INFO:root:Looking for videos named: /sdcard/other/IMG_0964
INFO:root:Found 1 pairs.
INFO:root:subset of found image/video pairs: [('/sdcard/other/IMG_0964.JPG', '/sdcard/other/IMG_0964.mov')]
INFO:root:Merging /sdcard/other/IMG_0964.JPG and /sdcard/other/IMG_0964.mov.
INFO:root:Merged photo and video.
INFO:root:Reading existing metadata from file.
INFO:root:Found XMP keys: ['Xmp.xmp.CreateDate', 'Xmp.xmp.CreatorTool', 'Xmp.xmp.ModifyDate', 'Xmp.mwg-rs.Regions', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area/stArea:y', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area/stArea:w', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area/stArea:x', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area/stArea:h', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Area/stArea:unit', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Type', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Extensions', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Extensions/apple-fi:AngleInfoYaw', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Extensions/apple-fi:AngleInfoRoll', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Extensions/apple-fi:ConfidenceLevel', 'Xmp.mwg-rs.Regions/mwg-rs:RegionList[1]/mwg-rs:Extensions/apple-fi:FaceID', 'Xmp.mwg-rs.Regions/mwg-rs:AppliedToDimensions', 'Xmp.mwg-rs.Regions/mwg-rs:AppliedToDimensions/stDim:h', 'Xmp.mwg-rs.Regions/mwg-rs:AppliedToDimensions/stDim:w', 'Xmp.mwg-rs.Regions/mwg-rs:AppliedToDimensions/stDim:unit', 'Xmp.photoshop.DateCreated']
WARNING:root:Found existing XMP keys. They *may* be affected after this process.

Im sorry if I missed something but in the log it says Merged but merged file is not there. Ive tried this several times. Edit: i've tried the other method you've said .. same result

mihir-io commented 2 years ago

Hmm, that's weird. Are you looking at the output/ folder for the merged file? It will create the output folder in the directory that you're running the script from (which in your case seems to be the home directory). Does ls ~/output work?

gototheskinny commented 2 years ago
~ $ ls ~/output                                         IMG_0673.JPG  IMG_0964.JPG

It says this. But there is no new file. I suppose there should be a new folder ? Where should i look at?

mihir-io commented 2 years ago

Nope, that's it. Those are the new files that have the video merged with the photo. If you copy those to a phone with Google Photos installed, the photo should work and it should show the "play" button in the top right which should show the video associated with the photo.

Edit: Ah, I think the issue is that you're probably not able to see it from the file browser on your phone, right? That's because the home directory ~/ is under /data/data/com.termux/files/home. You'll want to copy it to the /sdcard/ directory. Run the following in Termux:

$ cp ~/output/*.JPG /sdcard/

And that should copy it to the base of your phone's internal storage. Similarly, you can change it to any other location within /sdcard/ as needed, such as /sdcard/DCIM/Camera.

gototheskinny commented 2 years ago

Oh that was the issue!!! Thank you so much, it works!! I suggest you to inform future users of this script. First of all termux needs storage permission and you need to do manually secondly you need to do the "pkg upgrade" bc ssl part of the termux needs that. People like me needs the full on tutorial to be honest.

mihir-io commented 2 years ago

@gototheskinny Latest commit adds a --output parameter which takes in the path to a folder where the output photos should be written to, making any folders that don't exist (assuming it has permissions to do so). Termux's own setup process is out of the scope for this project so I'm not planning to document that beyond what's already in the README.md.