Sim
Well-known member
- Affected version
- XF2.1.4 + XFMG 2.1.4
I've just set up a new XF installation with XFMG and have been trying to upload videos to the gallery.
These files are in mp4 format but every file I've tried to upload has given me an error
After quite a long time tracing through the code to work out why these mp4 files are failing, I determined that there is a bug in the video type detection function.
In
Looking at my mp4 files, they all contain
However, you are doing a case sensitive
Can I suggest you either add the upper case
I've tested both these approaches, and they both work fine with my video files.
I also note that most references I find to
These files are in mp4 format but every file I've tried to upload has given me an error
The uploaded file was not a video as expected.
After quite a long time tracing through the code to work out why these mp4 files are failing, I determined that there is a bug in the video type detection function.
In
XF\Http\Upload::analyzeVideo()
, you are comparing the first few bytes of the file to a pre-determined set of file types:
PHP:
$mp4Ftypes = [
'avc1', 'iso2', 'iso6', 'isom', 'mmp4', 'msnv',
'ndas', 'ndsc', 'ndsh', 'ndsm', 'ndsp', 'ndss', 'ndxc', 'ndxh',
'ndxm', 'ndxp', 'ndxs', 'XAVC'
// mp41/2 handled via regex
];
Looking at my mp4 files, they all contain
ftypMSNV
, with the MSNV
in upper case.However, you are doing a case sensitive
preg_match
against msnv
in lower case, which means that it is not finding a match in my files.Can I suggest you either add the upper case
MSNV
to the list of $mp4Ftypes
or alternatively, make the match case insensitive, for example:
PHP:
// add i modifier to make search case insensitive
if (preg_match('#^(....)ftyp(M4V |qt |mp4[0-9]|' . $mp4FtypesRegex . ')#i', $preamble, $match))
{
...
}
I've tested both these approaches, and they both work fine with my video files.
I also note that most references I find to
MSNV
online has it listed in upper case, so it seems that this is the expected format.