.m4v is essentially the same as .mp4 (.m4v has just some added digital rights management options) so just changing the suffix to .mp4 should make it.
On the other hand .mov is a somewhat different wrapper. ffmpeg can losslessly convert .m4v to .mov:
ffmpeg -i input.m4v -c copy output.mp4
That does not preserve metadata but this should:
ffmpeg -i input.m4v -c copy -movflags use_metadata_tags -map_metadata 0 output.mp4
...unfortunately ffmpeg has a very old issue which incorrectly writes metadata (GUI applications usually use ffmpeg under the hood so they misbehave the same) so you must then fix it with exiftool so Photos.app can read it:
exiftool -m -overwrite_original -api LargeFileSupport=1 -Keys:All= -tagsFromFile @ -Keys:All output.mp4