Fixed 3gp-encoded ,mp4 videos not accepted


Well-known member
Affected version
If you have a .mp4 file encoded as 3gp (not a .3gp video), it will not be accepted as a valid video file. I believe this encoding is used when sending a video via MMS/iMessage and over a cellular network.

First bytes of a .mp4 video that works: ftypmp42mp41mp42isom
First bytes of a .mp4 video that doesn't work: ftyp3gp53gp5isom

This is from XF\Http\Upload::analyzeVideo():

$mp4Ftypes = [
    'avc1', 'f4v', 'iso2', 'iso6', 'isom', 'mmp4', 'mp4v', 'msnv',
    'ndas', 'ndsc', 'ndsh', 'ndsm', 'ndsp', 'ndss', 'ndxc', 'ndxh',
    'ndxm', 'ndxp', 'ndxs', 'xavc'
    // mp41/2 handled via regex
$mp4FtypesRegex = implode('|', $mp4Ftypes);

// Signatures adapted from:
if (preg_match('#^(....)ftyp(M4V |qt  |mp4[0-9]|' . $mp4FtypesRegex . ')#i', $preamble, $match))

The second video doesn't match this regex, however if you add '3gp' to $mp4Ftypes, it does.

See in regex101 (with the (....) bit removed as it doesn't seem to understand that):

No 3gp in regex:


With 3gp in regex:


We've had this crop up on two separate forums.
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.12).

Change log:
Add support for 3GP encoded videos
There may be a delay before changes are rolled out to the XenForo Community.
Top Bottom