AntidotE Posted December 23, 2020 Posted December 23, 2020 Hello guys, Recently decided to figure out how to extract MotionPhoto part from photos I do with my Galaxy Note 10+. Research shown that all data is kept inside single jpg and can be extracted by simple splitting file on specific marker - string "MotionPhoto_Data". Working proof of concept code is here: expandcollapse popup#include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <String.au3> $searchdata = StringTrimLeft(StringToBinary("MotionPhoto_Data"),2) $title = 'Samsung Motion Photo Converter by AntidotE' $version = '0.0.0.1' Split() Func Split() if $CmdLine[0] = 0 Then MsgBox($MB_SYSTEMMODAL,$title,'You need to specify input jpg file') Exit EndIf Local $sFilePath = $CmdLine[1] if StringRight($sFilePath,4) <> '.jpg' Then MsgBox($MB_SYSTEMMODAL, $title, "Only jpg files supported.") Return False EndIf Local $sFilemp4 = StringLeft($sFilePath,StringLen($sFilePath)-4) & "_cut.mp4" Local $sFilejpg = StringLeft($sFilePath,StringLen($sFilePath)-4) & "_cut.jpg" ; Open the file for reading and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePath, $FO_READ + $FO_BINARY + $FO_ANSI) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, $title, "An error occurred when reading the file.") Return False EndIf ; Read the contents of the file using the handle returned by FileOpen. Local $sFileRead = FileRead($hFileOpen) $sData = StringTrimLeft($sFileRead,2) Local $pos = StringInStr($sData,$searchdata) if $pos = 0 Then MsgBox($MB_SYSTEMMODAL, $title, "File does not contain required marker.") FileClose($hFileOpen) Return False EndIf FileClose($hFileOpen) Local $bData = Binary("") $bData = BinaryToString("0x" & StringMid($sData,1,$pos - 1)) Local $hFilejpg = FileOpen($sFilejpg, $FO_CREATEPATH + $FO_OVERWRITE + $FO_BINARY + $FO_ANSI) FileWrite($hFilejpg,$bData) FileClose($hFilejpg) $bData = BinaryToString("0x" & StringMid($sData,$pos + StringLen($searchdata))) Local $hFilemp4 = FileOpen($sFilemp4, $FO_CREATEPATH + $FO_OVERWRITE + $FO_BINARY + $FO_ANSI) FileWrite($hFilemp4,$bData) FileClose($hFilemp4) EndFunc ;==>Split Running script expects <originalfilename>.jpg file as single parameter and result is two additional files - <originalfilename>_cut.jpg and <originalfilename>_cut.mp4. Actual code can be found on my Github, there is a chance I will expand it some day to be more fancy or user friendly. If you have any comments or suggestions - feel free to write here, contact me or create pull requests 🙂.
Confuzzled Posted January 1, 2021 Posted January 1, 2021 Are you accessing 'EXIF' data that is standard in some/most picture files?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now