joemck / ExtractMotionPhotos

Extract Motion Photos created by Samsung phones to mp4 videos and plain jpg photos
MIT License
145 stars 20 forks source link

Google Photos Support #1

Open alsd4git opened 6 years ago

alsd4git commented 6 years ago

it would be awesome to have support for a conversion to google motion photos format, so google photos app could play them, i recently moved away from samsung and now i can only see motion photos on my old phone, while new google format motion photos are "playable" everywhere

joemck commented 6 years ago

Interesting, I didn't know this existed. Am I missing something or do I need a Pixel 2 to create these? Could you either enlighten me or share a sample motion photo with me to analyze?

alsd4git commented 6 years ago

you need google camera to create these, so a pixel device or a google camera port, i actually use a google camera port from this page https://www.celsoazevedo.com/files/android/google-camera/ i have a xiaomi mi a1 and use arnova8g2 pixel3mod to shoot motion photos, if you have any problem let me know and i'll upload some of my photos online to link them here

fresheneesz commented 6 years ago

@ale32thebest

while new google format motion photos are "playable" everywhere

Are they? I'm trying to find a way to play them somehow on my PC and I haven't been able to find a way. Also, facebook doesn't seem to support the format either. I haven't been able to find any information on the format itself that would help me find a viewer that supports them. I'm sure ale could use that info as well if he was going to support google motion photos. Have you found ways to play those photos outside of your phone and google photos?

alsd4git commented 6 years ago

From PC I use Google photos site (online) to view them

joemck commented 6 years ago

@ale32thebest I have tried a number of these apks on my Galaxy S7 Edge but all I get is "Camera has stopped".

alsd4git commented 6 years ago

on my device (mi a1) i use a magisk module to patch this, it looks like there are galaxy s7 specific port on xda https://forum.xda-developers.com/galaxy-s7/themes/google-camera-portrait-mode-t3736859 i can't try them, so i'm not totally sure if they have motion photos, they should

joemck commented 6 years ago

I tried this apk and it let me take photos, but I see no option for live photos in it.

alsd4git commented 6 years ago

i'm sorry, i don't have a galaxy s7 (or a samsung, actually from when i switched to my current phone) to find a working version of google motion photos, i can share with you some pics in a zip file and upload them online if you need them to test

joemck commented 6 years ago

A zip of some sample motion photos would be perfect.

alsd4git commented 6 years ago

here is a sample zip http://www.mediafire.com/file/lzkfxg9wrceoh1l/MVIMG_test.zip

joemck commented 6 years ago

I'm able to extract the video from these and play it in VLC on my PC by searching for an mp4 header in the file. However I'm not able to get my fully updated Google Photos app to do anything other than show the photo part.

What am I missing?

At this point I can extract one of these: search for a JPEG end marker (FF D9) followed by a mp4 header. And I believe I can create one: simply concatenate a jpg and an mp4 together after verifying the last thing in the jpg is an end marker since I'm guessing that's how Google's parser works. However I have no way to test my files.

alsd4git commented 6 years ago

if you have a beta script of something i can help you with testing, do you use telegram?

joemck commented 6 years ago

I'm chupi383 on Telegram. I'll have a Samsung-to-Google motion photo converter beta in about a half hour. From the looks of things, it's a simple enough task.

UPDATE: I got Google Photos to play your motion photo, but it doesn't recognize my naive attempt to create one by extracting the mp4 and jpg from a Samsung motion photo and simply gluing the mp4 onto the end of the jpg. I now believe they're using some special data block inside the jpg half to tell it to look for an mp4 after it, so I'm analyzing the jpg half of what you sent me more.

alex-phillips commented 6 years ago

@joemck It sounds like you were able to successfully pull the MP4s out of android MVIMG files? How did you ultimately do this? I would love to be able to just bulk extract these from all of my images.

joemck commented 6 years ago

@alex-phillips My successful attempt at splitting Google's MVIMGs was to simply look for a JPEG end marker followed by an MP4 header, then extract everything before that to an image and everything after to a video. Samsung ones are the same thing but with a predefined sequence of bytes in between them.

The JPEG portion appears to contain some tag that indicates there's a video -- simply appending a video to a photo did not create a working one.

I hope to add MVIMG support to this splitter program soon, but have been busy lately. My plan is to have it search for the special Samsung string, then if it doesn't find that, search for a JPEG end followed by a MP4 header. That way you'll be able to throw either sort of file at the same program, or even a batch of mixed MVIMG and Motion Photo.

alex-phillips commented 6 years ago

@joemck I think I've finally split some files based on an end jpeg marker and a beginning mp4 marker, but ffprobe is saying that my resulting video file is missing its moov atom. Any thoughts?