RhetTbull / osxphotos

Python app to work with pictures and associated metadata from Apple Photos on macOS. Also includes a package to provide programmatic access to the Photos library, pictures, and metadata.
MIT License
1.87k stars 93 forks source link

Support webm files by automatic conversion #1350

Closed LunarLanding closed 2 months ago

LunarLanding commented 6 months ago

Is your feature request related to a problem? Please describe. My google takeout included a webm file, that osxphotos (0.67.0) could not import. Photos (Version 9.0 (621.0.110)) does not support webm via manual import.

Describe the solution you'd like Automatic conversion of webm to mov.

Describe alternatives you've considered Pre-process takeout so webm is converted to mov.

Against the feature It seems that keeping the transparency channel, if present, is not possible without massively balooning the file size. In my specific case I only had a few files so I manually went over them, converting when necessary with ffmpeg -i "$a.webm" -c copy -f mov "$a.mov, where $a is the file path minus the extension, which worked for my files due to the original encoding being supported in mov. So it is probably better to leave it up to the user and mark this as wont-implement.

RhetTbull commented 6 months ago

Doing this would require custom code for what's likely an edge case. I think the preprocessing step (with a note in the docs) is probably best. That said, it might be possible to add a --pre-command option that preprocesses the file.

Something like --pre-command CONDTION COMMAND NEW_FILEPATH and you'd use like this:

--pre-command "{filepath|endswith(webm)?,}" "ffmpeg -i {filepath} -copy -f mov {filepath.parent}/{filepath.stem}.mov" "{filepath.stem}.mov"

(For simplicity I've left out the "{shell_quote}" template that would needed to escape filepath with spaces...)

But this seems overly complex for what is a one time operation (in the case of takeout) There are other use cases besides takeout though so this might be helpful.

RhetTbull commented 6 months ago

This would work similarly to --post-command in export.

RhetTbull commented 2 months ago

I am in the midst of a big update for osxphotos import and considered implementing this but I'm going to pass for now as the user can easily run a separate command to pre-process the files which is a good work-around. I can't think of any other use cases for this feature that couldn't be implemented with the user pre-processing the files.