Showing posts with label line. Show all posts
Showing posts with label line. Show all posts

Thursday, August 31, 2017

Stream Videos To Chromecast From The Command Line Using Stream2Chromecast

Stream Videos To Chromecast From The Command Line Using Stream2Chromecast



Stream2Chromecast is a command line Chromecast media streamer for Linux. The tool can transcode unsupported formats in real time and play them on the Chromecast.

Those who prefer a GUI for for streaming videos to Chromecast can use Videostream for Google Chromecast, a Chrome extension that allows playing local videos (including formats that arent directly supported by Chromecast) on your Chromecast. It supports subtitles, comes with iOS and Android remote controls, and more.


Stream2Chromecast features:
  • cast audio and video to a Chromecast device;
  • pass an URL to be played on the Chromecast; the file must be streamable and a Chromecast supported format since it cant be transcoded;
  • can transcode any formats not supported by the Chromecast in real time (using FFmpeg or Libav), so you dont have to convert any video manually;
  • provides basic control commands: pause / unpause / stop playback (currently this only works when not transcoding), set or mute volume;
  • allows specifying a device when multiple Chromecasts are connected on the same network;
  • supports passing custom custom transcoder parameters to ffmpeg or avconv (thanks to this, you can set the quality, add subtitles even though Stream2Chromecast doesnt directly support it, etc.);
  • supports specifying the port to use for streaming media.

For audio-only files, no metadata (artist, title, cover image, etc.) is displayed by Chromecast.

You may be wondering how Stream2Chromecast compares to castnow, another command-line Chromecast player. 

I initially wanted to write about both castnow and Stream2Chromecast. However, castnow had quite a few issues in my test under Ubuntu 16.04, such as stuttering playback for MKV files, subtitles didnt work with the "--tomp4" flag (which transcodes the video to MP4), and more.

Furthermore, castnow is currently looking for a new maintainer, and its last GitHub commit dates back to April, 2016, so it doesnt look like it will receive any improvements or bug fixes anytime soon.


Basic Stream2Chromecast usage


Notes:
  • the instructions below assume youve installed Stream2Chromecast from the main WebUpd8 PPA (see the installation instructions below). If you install Stream2Chromecast manually, youll need to use the full path to stream2chromecast.py (e.g.: "/path/to/stream2chromecast.py /path/to/my_media.mp4") for the commands below;
  • the computer running Stream2Chromecast and the Chromecast device must be in the same network;
  • ffmpeg or libav-tools are required for transcoding. If both are installed, ffmpeg is used by default.

To stream a supported media file (you can find a list of the media supported by Google Cast, HERE)
 to your Chromecast, simply use the following command:
stream2chromecast "/path/to/some-video.mp4"
Replacing "/path/to/some-video.mp4" with the exact path and filename of the video you want to play (e.fg.: stream2chromecast "/home/andrei/Videos/VIDEO1.mp4").

In my test, Stream2Chromecast failed to connect to my Chromecast if I didnt specify the Chromecast IP address, while other tools, such as pulseaudio-dnla, didnt have this issue, so Im guessing this is a bug.

If thats the case for you too, you can specify the Chromecast IP by adding the "-devicename" flag followed by the Chromecast IP address, to the stream2chromecast command, like this:
stream2chromecast -devicename CHROMECAST_IP_ADDRESS "/path/to/some-video.mp4"
Where "CHROMECAST_IP_ADDRESS" is the Chromecast IP address. You can find out your Chromecast IP address either by looking at your routers connected devices list or from the Google Cast mobile app, under "Device settings", under "Information" (at the bottom of the Device Settings).

Note that if youre having the same issue as me, and you need to enter the device IP address, you must do this for all Stream2Chromecast commands!

In the same way, you can also specify the Chromecast name:
stream2chromecast -devicename CHROMECAST_NAME "/path/to/some-video.mp4"

If you want to play an unsupported format (you can find a list of the media supported by Google Cast, HERE) on your Chromecast, you need to add the "-transcode" flag and have either Libav or FFmpeg installed:
stream2chromecast -transcode "/path/to/some-video.avi"
Where "/path/to/some-video.avi" is the exact path and filename of the media file you want to play on your Chromecast. You can append other flags to this command, like "-devicename CHROMECAST_IP_ADDRESS", which Ive mentioned above.

Stream2Chromecast also supports specifying custom transcoder parameters. As an example, heres a command that passes the device IP address, transcodes the video, and adds subtitles via a custom FFmpeg parameter (for FFmpeg only):
stream2chromecast -devicename CHROMECAST_IP_ADDRESS -transcodeopts -vf subtitles="/path/to/some-video.srt" -transcode "/path/to/some-video.avi"
Where CHROMECAST_IP_ADDRESS is your Chromecast IP address, "/path/to/some-video.avi" is the exact path and filename of the video you want to play on the Chromecast, and "/path/to/some-video.srt" is the exact subtitle path and filename of the subtitle file you want to use.

More about the FFmpeg subtitle filters, HERE.

Update: the app now allows playing a supported file from an URL (the file must be streamable and cannot be transcoded). To play a file from an URL, simply use:
stream2chromecast -playurl URL
Where URL is the video file URL, e.g. "http://www.example.com/my_media.mp4".

To stop stream2chromecast from streaming, either press Ctrl + C in the terminal where you ran the Stream2Chromecast (sometimes this can throw an exception / error - ignore it), or run the following command in a different terminal window:
stream2chromecast -stop

To view all the Stream2Chromecast options, run it in a terminal without any parameters:
stream2chromecast
Or visit the Stream2Chromecast GitHub page.


Download / Install Stream2Chromecast


Ubuntu 16.04 and 14.04 / Linux Mint 18 or 17.x users can install Stream2Chromecast by using the main WebUpd8 PPA. Add the PPA and install it using the following commands:
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt update
sudo apt install stream2chromecast

If you dont want to add the PPA or you dont use Ubuntu, you can grab the deb from HERE or download Stream2Chromecast from GitHub (either via Git or by downloading the latest code as a .tar.gz archive - HEREs a direct link).

Report any bugs you may find @ GitHub.

Also see: How To Stream Audio To A Chromecast Or DLNA / UPnP Device From Linux (Using pulseaudio-dnla)

Thanks to Mahdi for the tip! Image via Wikipedia.

download file now

Read more »

Thursday, August 10, 2017

Suka Duka Commuter Line

Suka Duka Commuter Line



Kembali ke ibukota membawa kebiasaan berkendara baru bagi saya. Setelah lama berada di Semarang, kesan bahwa lingkungan Jabodetabek yang terasa sesak begitu menampar saya. Awalnya berkendara menggunakan kendaraan pribadi saya lakoni hingga 6 bulan lebih saya bekerja. Pulang pergi dari Bekasi menuju Jakarta. Tidak jauh memang, dibandingkan dengan Depok ataupun Bogor. Lambat laun saya mencoba beralih ke beberapa pilihan transportasi umum. Lokasi kantor saya yang terbilang cukup strategis, menjadikan saya untuk memilih transportasi kereta. Saya hanya perlu berjalan kaki 10 hingga 15 menit dari stasiun Cikini. Jalan yang saya lalui pun tidak melewati jalan protokol besar, sehingga cukup nyaman untuk pejalan kaki. 

Jarak yang ditempuh dari Stasiun Bekasi menuju Stasiun Cikini berkisar 45 menit, jika tidak ada gangguan. CommuterLine kini menjadi moda transportasi andalan yang saya gunakan sehari-hari. Sering pula saya mengantarkan pacar saya dari Cikini ke Depok menggunakan CommuterLine. Praktis, cukup cepat dan tidak harus diribetkan dengan macetnya jalanan. Terlebih dengan harga perjalanan yang terbilang sangat terjangkau bagi masyarakat, menggunakan CommuterLine adalah pilihan terbaik dalam tanda kutip. Beruntunglah saya karena berbagai aktivitas harian yang saya jalani lokasinya berdekatan dengan stasiun kereta.

Sayangnya semua tidak semulus itu. Kamu mungkin sering mendengar beberapa keluhan di twitter ataupun media sosial yang memberitakan masalah-masalah di kereta. Saya tidak akan membicarakan soal pelecehan ataupun pencurian di kereta, karena itu balik lagi ke masing-masing individu yang memang harus lebih berhati-hati di tempat umum. Keluhan mendasar terutama saya yang berada di jalur menuju stasiun Bekasi adalah waktu tempuh yang cukup lama, sedangkan jumlah stasiun dari Manggarai-Bekasi tidak banyak. Hal ini disebabkan oleh jumlah rel menuju Bekasi yang hanya sedikit dan harus berbagi dengan kereta Jarak Jauh. Semoga proyek penambahan rel jalur Bekasi dapat segera terlaksana agar pengguna CommuterLine tidak tersiksa.

Singkat cerita saya punya pengalaman pahit menunggu. Saya lupa tepatnya hari apa, mungkin ada di Path atau posting blog ini. Hari itu saya pulang agak malam, sekitar jam 10 malam di stasiun Juanda, menunggu datangnya kereta dari Jakarta Kota menuju Bekasi. Langit gelap bergemuruh disertai hujan lebat. Berkali kali tampias air memasuki peron stasiun Juanda. Saya seolah tidak peduli dengan hujan, baterai hape saya lowbat saat itu, mengenaskan. Hingga tiba kereta, hampir 40 menit menunggu, saya pun naik dengan rombongan lain yang telah lama menunggu. Ternyata kebahagiaan saya harus sirna, karena beberapa kali kereta berhenti cukup lama, seperti masuk manggarai dan cakung. Tahukah? saya sampai stasiun Bekasi jam 1 pagi :)

Semoga PT. KCJ bisa terus meningkatkan pelayanannya, karena sangat banyak warga Jabodetabek yang bergantung pada CommuterLine. Jangan lupa appsnya dibagusin lagi!

download file now

Read more »