Family Best Time >> Entertainment

How to Make Your Own DIY Chromecast With a Raspberry Pi


A Google Chromecast is an inexpensive casting kit. The Chromecast Ultra is more expensive, but at under $100 it's still affordable. But some parts of the world can't buy Chromecast.

The solution? A DIY alternative based on the Raspberry Pi. Costing less than $50, you can configure this credit card-sized computer to receive streaming media from an Android app.

Let me walk you through how to use your Raspberry Pi as a DIY Chromecast with Raspicast.

Install the Raspicast application

Start by installing Raspicast on your Android device. This is a free application that connects to your Raspberry Pi and transmits data to it. You will find Raspicast in the Google Play App Store. Unfortunately, there is no reliable iPhone alternative for this.

Download: Raspicast for Android

It is important to note that the Android phone and the Raspberry Pi must be on the same network for this. You can't, for example, stream video from your phone to your TV if you're sitting on the bus. If you're trying to share a video with someone sitting at home, just send them the link!

Configure Raspbian for streaming

With the app installed, turn your attention to the Raspberry Pi. This should already be connected to your TV via HDMI and turned on. Note that the Pi will require an individual power source – you can't power it from your TV's USB port. Even if the power rating was adequate, the Pi should not be shut down without the correct command. Ignoring this will cause the Pi's SD card to become corrupted, so use the correct power source.

We tested it on a Raspberry Pi 4 running Raspbian Buster Lite. However, you should find it works with other Raspberry Pi models and distributions (although some commands may differ).

Before proceeding, make sure omxplayer is installed on your Pi:

sudo apt install omxplayer 

As you will need SSH enabled, here is a quick introduction. You have three options to enable it:

  1. Through raspi-config . You can run it from the command line using sudo raspi-config , then select Interfacing Options>SSH and use the arrow keys to confirm with OK .
  2. Use the Raspberry Pi Configuration Tool . From the Raspbian desktop, open Menu>Preferences>Raspberry Pi Configuration . in the Interfaces tab, find SSH and set it to Enabled .
  3. Finally, if you prefer simplicity, you can enable SSH before booting your Pi . Insert the microSD card into your computer, navigate to the boot partition and create a new file. This should be called ssh and have no file extension. Once you've replaced the SD card and rebooted, SSH should be enabled.

The following operations can be performed via a keyboard connected to your Pi or by using SSH. You'll need the Pi's IP address to connect — open a terminal window and enter

ifconfig 

Note the IP address that corresponds to your Pi's connection. For example, use the IP address that corresponds to eth0 input if using Ethernet connection; wlan0 for Wi-Fi.

Once the SSH connection is established, run some updates. Open a terminal window on your Pi and enter:

sudo apt updatesudo apt upgrade 

These commands will update your Raspberry Pi's operating system and find and install any software updates.

Install and build OpenMax

After the updates are installed, we need some prerequisite packages:

sudo apt install libjpeg9-dev libpng12-dev 

The libjpeg9-dev packages and libpng12-dev are needed for programs that can handle JPG and PNG images. This will allow media images to be streamed to your Raspberry Pi via the Raspicast app on Android!

Now install OpenMax. This tool is the best option to stream videos, audio and images from Android to a Raspberry Pi connected to a TV. It's available through GitHub, and you can install it by "cloning" the data repository to your Pi. I don't have git ? Install it with

sudo apt install git 

Then clone the repository with:

git clone https://github.com/HaarigerHarald/omxiv 

It shouldn't take long.

You are almost done; it's time to create the OpenMax software. Start by switching to the omxiv directory and using the make command.

cd omxivmake ilclientmake 

That will take time. Once done, install with:

sudo make install 

A few moments later, OpenMax will be ready to use.

Prepare-to-stream-on-your-raspberry-pi

Everything you need to stream from your Android device to your Raspberry Pi is now in place. Some Raspicast configuration is still required, however.

  1. Run the Raspicast application.
  2. In the SSH settings, enter the hostname or IP address of your Pi.
  3. Enter your Pi username and password.
  4. Click OK to finish.

To stream to your Raspberry Pi, you have two options:

  • Search for content in the Raspicast app and press play .
  • Stream from YouTube, find the video in the app and tap Share>Stream (Raspicast) .

Meanwhile, to send videos, music and photos to your Raspberry Pi screen, just use the main Raspicast screen and select Cast . This will open a screen listing all the videos on your Android device.

Selecting a media file on one of the corresponding tabs will cause it to play immediately on your Raspberry Pi.

Need to change the IP address in the app (e.g. to stream to another Pi)? Open the “three dots” menu and select SSH Settings. Simply enter the new IP address and credentials.

More Raspicast options

Also in the Raspicast menu, you will find a checkbox for Repeat the file being played. Further down the list, Audio Output can be customized, using HDMI (default), local , both , or alsa . This will prove useful for anyone using an external audio solution with their Pi.

You should also check the Advanced Options screen. Here, manage a file queue, volume (audio volume offset), and specify custom controls. You can also switch to using HTTP if needed (HTTPS is the default), and more.

Meanwhile, on the main Raspicast screen, use the Folders button to browse and play media stored on your Raspberry Pi. This includes audio streaming, turning your Raspberry Pi into a Chromecast audio device!

You can also run with Kodi!

Although you can't run Raspicast with a Raspberry Pi running Kodi, don't worry, there is an alternative. With the Kore remote control app for Android, you can also stream media to a Raspberry Pi with Kodi installed.

Download: Kore, official remote control for Kodi

Just install the app, configure it with your Raspberry Pi's IP address, then head to YouTube. As for Raspicast, press the Share on the video you want to stream, then Play on Kodi .

This will immediately stream the video to your TV via Kodi!

Other Chromecast alternatives

The Raspberry Pi isn't the only alternative to a Chromecast. You may already have a solution that you weren't aware of. Your smart TV, game console or set-top box may have a YouTube app, allowing for easy streaming.

In this situation, it is usually possible to stream videos from the YouTube app to the TV as long as the receiver is on the same network.

While other HDMI streaming solutions exist, if you have a device with an official YouTube app (like the Apple TV), you'll probably be able to stream there. And if you don't have either of these devices or a Raspberry Pi, Miracast is a smart alternative.

Want to go further with multimedia streaming and your Raspberry Pi? Here are the best ways to use a Raspberry Pi as a media server.