Mobile video issues

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
MarkDHamill
Registered User
Posts: 3487
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Mobile video issues

Post by MarkDHamill » Tue Sep 25, 2018 6:53 pm

Not sure this is quite the right forum for this.

phpBB embeds videos with <object> and <embed> tags that basically requires the integration of a Quicktime player plug in, not ideal and something I've raised about three years ago as a needed enhancement. This is not ideal for "web ready" video formats: .mp4 and .ogg basically, which can play natively if encoded with a <video> tag. So I've commented out code in attachment_body.html and added in the <video> tag instead. I also limited "Flash" files to ONLY .mp4 and .ogg file extensions to avoid for now the issue of how to deal with other video formats. So attachment_body.html (snippet) now looks like this:

Code: Select all

		<!-- IF _file.S_FLASH_FILE -->
			<video width="{_file.WIDTH}" height="{_file.HEIGHT}" controls>
				<source src="{_file.U_VIEW_LINK}" type="video/mp4">
				<source src="{_file.U_VIEW_LINK}" type="video/ogg">
				Your browser does not support the video tag.
			</video>
			<!--object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=5,0,0,0" width="{_file.WIDTH}" height="{_file.HEIGHT}">
				<param name="movie" value="{_file.U_VIEW_LINK}" />
				<param name="play" value="true" />
				<param name="loop" value="true" />
				<param name="quality" value="high" />
				<param name="allowScriptAccess" value="never" />
				<param name="allowNetworking" value="internal" />
				<embed src="{_file.U_VIEW_LINK}" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="{_file.WIDTH}" height="{_file.HEIGHT}" play="true" loop="true" quality="high" allowscriptaccess="never" allownetworking="internal"></embed>
			</object-->
			<p><a href="{_file.U_DOWNLOAD_LINK}">{_file.DOWNLOAD_NAME}</a> [ {_file.FILESIZE} {_file.SIZE_LANG} | {_file.L_DOWNLOAD_COUNT} ]</p>
		<!-- ENDIF -->
A couple of issues. The height and width do not appear as attributes of the <video> tag -- they are blank/null. The same is true in the commented out code too, so this would be an issue with Quicktime as well. The view source snippet looks like this:

Code: Select all

		<video width="" height="" controls>
				<source src="./download/file.php?id=1729&amp;view=1" type="video/mp4">
				<source src="./download/file.php?id=1729&amp;view=1" type="video/ogg">
				Your browser does not support the video tag.
			</video>
			<!--object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=5,0,0,0" width="" height="">
				<param name="movie" value="./download/file.php?id=1729&amp;view=1" />
				<param name="play" value="true" />
				<param name="loop" value="true" />
				<param name="quality" value="high" />
				<param name="allowScriptAccess" value="never" />
				<param name="allowNetworking" value="internal" />
				<embed src="./download/file.php?id=1729&amp;view=1" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="" height="" play="true" loop="true" quality="high" allowscriptaccess="never" allownetworking="internal"></embed>
			</object-->
			<p><a href="./download/file.php?id=1729">20180925_110717.mp4</a> [ 10.98 MiB | Viewed 11 times ]</p>
So this may be a bug in phpBB.

In any event the sample video is very large in dimensions. I changed attachment settings to set a maximum height and width, hoping the video will be shrunk by the browser. But the width and height attributes of the video tag don't change.

Another issue is that while the video will render fine on a desktop browser, even smaller sized videos won't appear embedded in the post on a mobile browser. The video player play button comes up, but when you press it the video is never rendered.

Suggestions on how to solve these issues? Or maybe they aren't solvable?
Get the latest versions of my Digests and Smartfeed mods and extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
MarkDHamill
Registered User
Posts: 3487
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: Mobile video issues

Post by MarkDHamill » Fri Sep 28, 2018 12:33 am

To answer my own question, I think there is a bug in phpBB.

MP4 and OGG files are treated as Flash files by phpBB. In /includes/functions_content.php, starting at line 1284 is this code:

Code: Select all

				// Macromedia Flash Files
				case ATTACHMENT_CATEGORY_FLASH:
					list($width, $height) = @getimagesize($filename);
					$block_array += array(
						'S_FLASH_FILE'	=> true,
						'WIDTH'			=> $width,
						'HEIGHT'		=> $height,
						'U_VIEW_LINK'	=> $download_link . '&amp;view=1',
					);
					// Viewed/Heared File ... update the download count
					$update_count_ary[] = $attachment['attach_id'];
				break;
It turns out that PHP's getimagesize function can't read MP4 and OGG files. In fact, it looks like it only supports images, not videos. So there is nothing in the array it returns where the width and height values are returned, so they are blank. Thus the width and height attributes are null. This has likely always been the case, but has never been noticed.

So I wrote a little hack to includes/functions_content.php as a proof of concept. I used the getID3 PHP library and placed it in /vendor/getid3. I decided to use the post maximum image width configuration variable (if it is not zero) as a basis for resizing the video to make the height proportional. New code (obviously it can be improved):

Code: Select all

				// Macromedia Flash Files
				case ATTACHMENT_CATEGORY_FLASH:
				
					// Begin changes by Mark D. Hamill, phpbbservices.com, September 27, 2018
					include('./vendor/getid3/getid3.php');
					$getID3 = new getID3;
					$file = $getID3->analyze($filename);
					if (substr($file['mime_type'],0,6) == 'video/')
					{
						$width = $file['quicktime']['moov']['subatoms'][3]['subatoms'][0]['width'];
						$height = $file['quicktime']['moov']['subatoms'][3]['subatoms'][0]['height'];
						if (($config['max_post_img_width'] > 0) && ($width > $config['max_post_img_width']))
						{
							// Reduce height and width to be proportional to maximum post image width
							$height = round(($height * $config['max_post_img_width']) / $width);
							$width =  $config['max_post_img_width'];
						}
					}
					else
					{
						list($width, $height) = @getimagesize($filename);
					}
					// End changes by Mark D. Hamill, phpbbservices.com, September 27, 2018

					$block_array += array(
						'S_FLASH_FILE'	=> true,
						'WIDTH'			=> $width,
						'HEIGHT'		=> $height,
						'U_VIEW_LINK'	=> $download_link . '&amp;view=1',
					);

					// Viewed/Heared File ... update the download count
					$update_count_ary[] = $attachment['attach_id'];
				break;
This works fine. I guess I should put this in the bug tracker.
Last edited by MarkDHamill on Fri Sep 28, 2018 2:26 am, edited 5 times in total.
Get the latest versions of my Digests and Smartfeed mods and extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
david63
Jr. Extension Validator
Posts: 14729
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Mobile video issues

Post by david63 » Fri Sep 28, 2018 1:41 am

MarkDHamill wrote:
Fri Sep 28, 2018 12:33 am
I guess I should put this in the bug tracker.
That would seem the logical thing to do - along with the PR for the fix
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
MarkDHamill
Registered User
Posts: 3487
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: Mobile video issues

Post by MarkDHamill » Fri Sep 28, 2018 1:45 am

Here is the issue in the issue tracker:

https://tracker.phpbb.com/browse/PHPBB3-15808?filter=-2

Not sure what you mean about the PR for the fix, but I referenced this topic.
Get the latest versions of my Digests and Smartfeed mods and extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
david63
Jr. Extension Validator
Posts: 14729
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Mobile video issues

Post by david63 » Fri Sep 28, 2018 2:23 am

MarkDHamill wrote:
Fri Sep 28, 2018 1:45 am
Not sure what you mean about the PR for the fix, but I referenced this topic.
I mean that as you have found the fix for it that works you can create a pull request to have it added to the core
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
MarkDHamill
Registered User
Posts: 3487
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: Mobile video issues

Post by MarkDHamill » Fri Sep 28, 2018 12:25 pm

Ah, in my world PR means "problem report". I'm not sure my code is quite up to snuff as a pull request and I suspect if they fix this bug they will likely go with a different third-party package and change the code quite a bit.
Get the latest versions of my Digests and Smartfeed mods and extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 2 guests