47 45 43 29 bytes SBCS
You can try it online!
Thanks to @J42161217 for saving me a total of 16 bytes!!
103 101 97 bytes
Saved 2 bytes thanks to Kevin Cruijssen!!!
Saved 4 bytes thanks to Value Ink!!!
from math import* def f(a,b): l=log(b,a) n,m=l.as_integer_ratio() return -1if a**n-b**m else l
Try it online!
88 82 bytes
Try it online! Link is to verbose version of code. Takes input as a list in [value, base] order and outputs numerator and denominator. Edit: Saved 6 bytes by simplifying my check for exclusive factors. Explanation:
Factorise both numbers by trial division.
Collect the factors from both inputs, in case some factors are only present in one of them.
Divide the multiplicity of each factor in both the base and the value by their GCD.
If this is not unique then output
If it is unique then output it.