2

I have an Apache 2.2.22 webserver running on Raspbian (RasPi Debian). I have .mp4 files in a folder that I can stream flawlessly to my web browser locally or over the internet.

My Playstation 4, however, won't take a link to a file and stream it; It needs an HTML player to stream the video. I don't want to create a player for every video. I can't make a player where you type the video name and hit play, because the names are too long and there are too many of them.

I don't know any way to get passed this without having to create an HTML page for every video, or at least an HTML page that includes every video.

EDIT:

I noticed when I viewed the source of a video in Google Chrome, this came up:

<html>
<head>
<meta name="viewport" content="width=device-width">
<style type="text/css">
</style>
</head>
<body>
<video controls="" autoplay="" name="media">
<source src="http://10.0.0.21/media/blahblahblah.mp4" type="video/mp4">
</video>
</body>
</html>

Is there a way to force the Playstation (or any browser?) to use this? Instead of the browser (google chrome) automatically applying this HTML to the MP4 video?

Rontron
  • 3,963
  • 7
  • 26
  • 44
  • 1
    Any server side (that is, PI-side) script can generate a page. You could use PHP to generate it on the fly, or a simple bash script to pre-generate them on demand. – GolezTrol Aug 17 '15 at 06:09
  • How would I go about the PHP method? – Rontron Aug 17 '15 at 06:14

1 Answers1

2

The Playstation 4 will play a HTML5 video if it's in the correct format, as you noticed above.

The specs for MP4 are:

Video: H.264/MPEG-4 AVC High Profile Level4.2
Audio: AAC LC, AC-3 (Dolby Digital)

In addition you'll have to make sure the moov atom is at the start of the file to be able to start the playback immediately

With Apache you can do redirects. Eg. http://example.com/play/video_id can be redirected to a scripted page that uses the video ID to generate a HTML5 player on the fly.

If you want to avoid creating a script (eg: PHP) that generates the HTML page dynamically based on the MP4 files in a directory the alternative is to use an open-source media server.

An example is the Plex Media Server. It has a Linux version and there are articles on how to stream to PS4. There's also RasPlex and OSMC and others if you fail to install Plex on Raspberry Pi.

As a bonus you get a nice interface.

aergistal
  • 29,947
  • 5
  • 70
  • 92
  • I used Plex before, however it requires me to buy a membership if I want to stream over the internet. That is why I stopped using it. – Rontron Aug 26 '15 at 18:33
  • When I try to use a direct link to a mp4 video on my PS4, it says "Data not supported". I know it can play HTML5 video if it is in a form within the HTML page, but I'm not sure if it can take direct links like you say it does. – Rontron Aug 26 '15 at 18:45
  • No, no direct links. It works only in HTML ` – aergistal Aug 26 '15 at 18:51
  • For encoding and compressing these videos for streaming, I use Handbrake. I set Anamorphic to None; Framerate to Constant; Constant Quality to 23 RF; Audio to 128kbps Dolby Pro Logic II AAC (avcodec); Video to H.264 (x264). – Rontron Aug 26 '15 at 18:57
  • That is why I wanted to use PHP to load a ` – Rontron Aug 26 '15 at 18:59
  • With Apache you can do redirects. Eg. `http://example.com/play/video_id` can be redirected to a PHP page that uses the video ID to generate a HTML5 player. – aergistal Aug 26 '15 at 19:42
  • I will try this, but I'm not sure if the PS4 will ignore the redirect and say Data Not Supported or if it will acknowledge the redirect and continue on. I will have to find out. – Rontron Aug 26 '15 at 21:03
  • How would I go about creating a redirect? I tried to find out how but I can't seem to figure out how. I do not want to create another virtual host, so I found that there is the default one `000-default` located in `/etc/apache2/sites-enabled` but it doesn't end in a `.conf`, it has no file type. So I added `RedirectMatch (.*)\.mp4$ http://10.0.0.21/media/index.php?id=$1.mp4` to `000-default` but it doesn't work. – Rontron Aug 26 '15 at 22:38
  • I've tried adding that line (And even a simple `Redirect`) to `apache2.conf`, `000-default`, `default`, and even a file I created called `default.conf` located in the `sites-available` folder. – Rontron Aug 26 '15 at 23:30
  • You should redirect only the URLs that start with a specific prefix because you still need access to the direct video link within the browser. If you redirect all `mp4` requests then the ` – aergistal Aug 27 '15 at 07:42
  • Where should I place my Redirect line anyway? apache2.conf? 000-default? default? default.conf? – Rontron Aug 29 '15 at 14:39
  • 1
    I awarded the bounty to you for your support. It turns out I didn't even need any of this. I found that using my [first question on stackoverflow](http://stackoverflow.com/questions/23451162/how-to-use-a-php-variable-as-an-url-for-an-iframe-element) worked! All I need to do is type the directory (which is /media) and hit go. Then I can navigate to whatever video/audio I want on my PS4. I think I will make it even easier so I don't have to type /media or even hit go, all I have to do is enclose everything in a big iFrame as a simple fix! :) – Rontron Aug 30 '15 at 02:13