Fixed 3gp-encoded ,mp4 videos not accepted

mattrogowski

Well-known member
Affected version
2.2.9
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():

PHP:
$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: https://www.garykessler.net/library/file_sigs.html
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:

1653596176112.png

With 3gp in regex:

1653596191705.png

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.
 
Back
Top Bottom