Own Your Content. AVideo (YOUPHPTUBE) Helps You.

O

Have you been keeping an eye on the world? Not since the beginning of the social media era has it been more important to own your content. And not only own that content, but be in ultimate control of it.

Video Present Screen (AVideo)

An important lesson of social media is that, regardless of the platform, you are not the customer. You are the product. Social media companies take information you provide and sell it to marketers, social engineers and others who stand to benefit from the information you provide to your friends and publicly. They can also do this via their crawl mechanisms on your site, but it is much more difficult to target you if you don’t want them to.

Sometimes these sites will object, censor, or otherwise decide your content doesn’t meet “community standards” and pull them down. These standards are usually malleable and change with the tide of public opinion. This happens in such a way that what was acceptable one day, becomes objectionable the next.

The goal of this article isn’t to talk about that any more than to emphasize that being able to own, control and publish your content on your platform and your own way has never been more important.

Video Management Screen

For several years I have been familiar with a project now called AVideo but what was at one time called YouPHPTube. It allows you to set up your own streaming system and provide your own video content on your platform. And they make is relatively simple to do so.

While they do have a Dockerfile available to help you set up and configure Docker images for this, I have taken the step to create my own Docker-based containers for their streaming and encoding service which you can set up with a docker-compose.yml file, your own virtual (or bare metal) server and a decent internet connection.

AVideo is written in PHP but utilizes several server level technologies such as FFMPEG and YouTube-DL (optional use) and MariaDB/MySQL to tie into transcoding, integration and databases respectively. It has a web interface for uploading and encoding videos. You can even set it up with advertising to do pre-roll video and monetize your platform using several methods that are outside the scope of this specific article.

Setting this up is pretty straightforward and I’ve made an effort to create a Docker-orchestrated way of implementing this. There are two docker containers you may wish to familiarize yourself with:

https://hub.docker.com/r/mbagnall/avideo-encoder
https://hub.docker.com/r/mbagnall/avideo-streamer

These are both open source and can be viewed on GitHub:

https://github.com/ElusiveMind/avideo-encoder
https://github.com/ElusiveMind/avideo-streamer

But you do not have to build these containers yourself, or configure them. I am providing you a sample docker-compose.yml file that should help you get started.

version: '3'
services:

  stream:
    image: mbagnall/avideo-streamer:11.1.1
    container_name: avideo-streamer
    ports:
      - 8120:80
      - 9120:443
    environment:
      PHP_MEMORY_LIMIT: 512M
      PHP_MAX_EXECUTION_TIME: 300
      PHP_MAX_INPUT_TIME: 300
      PHP_POST_MAX_SIZE: '10240M'
      PHP_UPLOAD_MAX_FILESIZE: '10240M'
    volumes:
      - ./avideo-streamer/videos:/var/www/html/web/videos
    depends_on:
      - datastore
    networks:
      - avid
    restart: unless-stopped

  encoder:
    image: mbagnall/avideo-encoder:3.7
    container_name: avideo-encoder
    ports:
      - 8121:80
      - 9121:443
    environment:
      PHP_MEMORY_LIMIT: 512M
      PHP_MAX_EXECUTION_TIME: 7200
      PHP_MAX_INPUT_TIME: 300
      PHP_POST_MAX_SIZE: '10240M'
      PHP_UPLOAD_MAX_FILESIZE: '10240M'
    volumes:
      - ./avideo-encoder/videos:/var/www/html/web/videos
    depends_on:
      - datastore
    networks:
      - avid
    restart: unless-stopped

  datastore:
    image: mariadb:10.6
    container_name: avideo-datastore
    environment:
      MYSQL_USER: 'user'
      MYSQL_DATABASE: 'avideo'
      MYSQL_PASSWORD: 'SailAway77'
      MYSQL_ROOT_PASSWORD: 'SailAway77'
      MYSQL_ALLOW_EMPTY_PASSWORD: 'no'
    expose:
      - "3306"
    volumes:
      - ./avideo-database/mysql:/var/lib/mysql
    networks:
      avid:
        aliases:
          - db
    restart: unless-stopped

networks:
  avid: null

Once you have this in place (I have tested it on Linux and Intel and M1 Macintosh computers) You should be able to go to the respective localhost address and port and access the setup pages. Be advised, I had trouble getting videos to play on the localhost domain as it would complain about an invalid domain name. I had to set up my own locally hosted environment on an internal dev server to get things truly working.

Do to that part, I used Nginx to proxy to the service using HTTPS (the containers above contain localhost certificates that satisfy the proxy security requirement for Nginx).

  server {
    client_max_body_size 4096M;
    server_name avideo.domain.io;
    location / { 
      proxy_pass https://127.0.0.1:9120;
      proxy_set_header Host $host;
    }
    listen 443 ssl;
    ssl_certificate           /opt/ssl/STAR_domain_io.crt;
    ssl_certificate_key       /opt/ssl/STAR_domain_io.key;
  }

  server {
    client_max_body_size 4096M;
    server_name avideo-encoder.domain.io;
    location / { 
      proxy_pass https://127.0.0.1:9121;
      proxy_set_header Host $host;
    }
    listen 443 ssl;
    ssl_certificate           /opt/ssl/STAR_domain_io.crt;
    ssl_certificate_key       /opt/ssl/STAR_domain_io.key;
  }

  server {
    listen 80;
    server_name avideo.domain.io avideo-encoder.domain.io;
    return 301 https://$host$request_uri;
  }

This article assumes you at least have some working knowledge of Docker and Nginx, but if you don’t, I will have an article coming very soon on how to make these items work for you.

Please feel free to provide issues and comments at the GitHub places above. I am working on a self-hosted GitHub and Gist solution for my code and will keep you advised. Even those places have started censoring projects.

About the author

Michael Bagnall

I am a web solutions architect working to develop PHP, JavaScript and Docker-based solutions in the public and private sector. Currently working out of the Middle Tennessee area, I am also an avid Ice Hockey fan and also play in an adult league. In addition to CodeRefactored.com, I also blog on hockey related items at BagOfPucks.com.

By Michael Bagnall

Recent Posts

PROJECTS

Tag Cloud