https://github.com/alexdelorenzo/cast_convert
๐ฝ๏ธ Convert videos to Chromecast compatible formats
https://github.com/alexdelorenzo/cast_convert
chromecast converter ffmpeg transcoding video video-processing
Last synced: 11 months ago
JSON representation
๐ฝ๏ธ Convert videos to Chromecast compatible formats
- Host: GitHub
- URL: https://github.com/alexdelorenzo/cast_convert
- Owner: alexdelorenzo
- License: other
- Created: 2016-10-13T15:26:15.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-09-30T04:28:25.000Z (over 1 year ago)
- Last Synced: 2025-03-18T02:51:47.777Z (about 1 year ago)
- Topics: chromecast, converter, ffmpeg, transcoding, video, video-processing
- Language: Python
- Homepage: https://alexdelorenzo.dev
- Size: 320 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# ๐ฝ๏ธ Convert videos for Chromecasts
Identify and convert videos to formats that are Chromecast supported.
Cast Convert can tell you whether videos will play correctly on your casting devices. If they won't, this project can convert videos into formats that devices do support.
[Click here to see a list of supported devices](#supported-devices).
### What Cast Convert does
`cast-convert` can identify and correct a video's incompatibility with a device caused by the video's:
- Video encoding
- Audio encoding
- Encoder profile
- Encoder level
- Container file format
- Frame rate
- Resolution
- Subtitle format
This utility can tell you if a video will or won't play correctly on your casting device. It can then efficiently modify
the video so that it will play on the device.
### Why use Cast Convert over other options?
Cast Convert calculates the least amount of transcoding required to playback videos. It also has detailed support profiles for every format supported by each device, whereas other transcoding options tend to force all videos into one format.
For example, you may have a video named `video.mp4` that isn't compatible with your device. Cast Convert can generate a transcoding plan that does the least amount of transcoding necessary instead of blindly transcoding every video into the same format.
You can use `cast-convert inspect` to scan the video and come up with the most efficient transcoding plan:
```bash
$ cast-convert inspect --name '1st Gen' video.mp4
[โ๏ธ] Need to convert "~/video.mp4" to play on Chromecast 1st Gen...
Must convert from:
- File Container: mp4
- Video Codec: vp9
- Resolution: 640x480
- Frame Rate: 29.970
- Audio Codec: mp3
To:
- Video Codec: avc
- Encoder Level: 4.1
```
Since the video is encoded with a supported audio codec, within a supported container and supported framerate and resolution, only the video encoding must change.
If you used another tool, it may have tried to convert *all* videos to the same format, no matter how inefficient it is. That means `video.mp4` might have more than its video encoding changed, it might have to have its container, audio codec and framerate changed, as well. That can take up an unnecessary amount of time and resources.
Similarly, the following might have its video track transcoded, too, despite only the audio track needing to be converted to a supported format:
```bash
$ cast-convert inspect --name '1st Gen' video.mp4
[โ๏ธ] Need to convert "~/video.mp4" to play on Chromecast 1st Gen...
Must convert from:
- File Container: mp4
- Video Codec: vp9
- Resolution: 640x480
- Frame Rate: 29.970
- Audio Codec: dts
To:
- Audio Codec: mp3
```
### About Cast Convert
Individual casting devices like the Chromecast have unique video encoding, audio encoding and container support
combinations for video files. Cast Convert has detailed compatibility profiles for each individual Chromecast model on
the market.
`cast-convert` will inspect a video's metadata to determine what video attributes must get changed to successfully play
it. To use resources efficiently, it will determine only the minimum amount of transcoding needed to successfully play
each video back.
### Supported devices
- Chromecast 1st Gen
- Chromecast 2nd Gen
- Chromecast 3rd Gen
- Chromecast Ultra
- Chromecast with Google TV
- Google Nest Hub
- Nest Hub Max
## Requirements
### Minimum
- [Python 3.12](https://www.python.org/downloads/)
- [`mediainfo`](https://mediaarea.net/en/MediaInfo)
- [`ffmpeg`](https://ffmpeg.org/)
### Encoders
- [`libmp3lame`](https://lame.sourceforge.io/)
- [`x264`](https://www.videolan.org/developers/x264.html)
## Installation
```bash
$ python3 -m pip install cast_convert
```
## Usage
### Launch
You can run the Python module directly:
```bash
$ python3 -m cast_convert --help
```
Or you can use launcher that gets added to your `$PATH`:
```bash
$ cast-convert --help
```
### Options and commands
```bash
Usage: cast-convert [OPTIONS] COMMAND [ARGS]...
๐ฝ๏ธ Identify and convert videos to formats that are Chromecast supported.
See https://github.com/alexdelorenzo/cast_contvert for more information.
Copyright ยฉ 2022 Alex DeLorenzo (https://alexdelorenzo.dev).
โญโ โ About โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --log-level -l [critical|debug|error|fata ๐ชต Set the minimum logging โ
โ l|info|warn] level. โ
โ [default: warn] โ
โ --version -v ๐ข Show application versioโฆ โ
โ and quit. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ ๐ Analyze โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ command ๐ Get FFmpeg transcoding command. โ
โ inspect ๐ Inspect videos to see what attributes should get transcoded. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ ๐ฝ๏ธ Convert โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ convert ๐ผ Convert videos so they're compatible with specified device. โ
โ watch ๐ Watch directories for new or modified videos and convert them. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ ๐ ๏ธ Hardware Support โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ devices ๐บ List all supported devices. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
```
### Parameters
#### `--log-level`
You can set the log level using the `--log-level` flag:
```bash
$ cast-convert --log-level debug devices
[06:12:49] DEBUG DEBUG:root:Loaded devices from file base.py:201
You can use these device names with the --name flag:
- Chromecast 1st Gen
- Chromecast 2nd Gen
- Chromecast 3rd Gen
- Chromecast Ultra
- Chromecast with Google TV
- Google Nest Hub
- Nest Hub Max
```
Default log level is `warn`.
#### `--name`
You can specify the model of your device with the `--name` flag. It uses fuzzy matching, so you don't have to type out
device names completely.
The `--name` flag comes *after* [`cast-convert` commands](#commands).
```bash
$ cast-convert inspect --name '1st Gen' ~/video.webm
[๐๏ธ] Need to convert "/home/user/video.webm" to play on Chromecast 1st Gen...
Must convert from:
- Container: webm
- Codec: vp9
- Resolution: 406x260
- Fps: 25.000
- Level: 0
To:
- Codec: avc
- Level: 4.1
```
Default device name is `Chromecast 1st Gen`.
#### `PATHS`
You can specify one or more file or directory paths as `PATHS` arguments.
You must specify at least one path. Paths are supplied after commands, and they are the *last* arguments
to `cast-convert`.
```bash
$ cast-convert command vid1.mkv vid2.mkv
ffmpeg -fflags +genpts -i 'vid1.mkv' -acodec copy -movflags faststart -scodec
copy -threads 12 -vcodec libx264 -vlevel 4.1 'vid1_transcoded.mkv' -y
ffmpeg -fflags +genpts -i 'vid2.mkv' -acodec copy -movflags faststart -scodec
copy -threads 12 -vcodec libx264 -vlevel 4.1 'vid2_transcoded.mkv' -y
```
### Commands
#### `convert`
```bash
Usage: cast-convert convert [OPTIONS] ๐PATHS
๐ผ Convert videos so they're compatible with specified device.
โญโ Arguments โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ * paths ๐PATHS Path(s) to video(s). [required] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --help Show this message and exit. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ ๐บ Device โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --name -n TEXT ๐ Device model name. [default: Chromecast 1st Gen] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ ๐ฅ Encoder Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --replace -r ๐พ Replace original file with transcoded video. โ
โ --threads -t INTEGER ๐งต Number of threads to tell FFMPEG to use per โ
โ job. โ
โ [default: 12] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
```
#### `devices`
```bash
Usage: cast-convert devices [OPTIONS]
๐บ List all supported devices.
โญโ Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --help Show this message and exit. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ ๐บ Device โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --details -d โน Show detailed device information. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
```
#### `command`
```bash
Usage: cast-convert command [OPTIONS] ๐PATHS
๐ Get FFmpeg transcoding command.
โญโ Arguments โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ * paths ๐PATHS Path(s) to video(s). [required] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --help Show this message and exit. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ ๐บ Device โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --name -n TEXT ๐ Device model name. [default: Chromecast 1st Gen] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ ๐ฅ Encoder Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --replace -r ๐พ Replace original file with transcoded video. โ
โ --threads -t INTEGER ๐งต Number of threads to tell FFMPEG to use per โ
โ job. โ
โ [default: 12] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
```
#### `inspect`
```bash
Usage: cast-convert inspect [OPTIONS] ๐PATHS
๐ Inspect videos to see what attributes should get transcoded.
โญโ Arguments โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ * paths ๐PATHS Path(s) to video(s). [required] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --help Show this message and exit. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ ๐บ Device โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --name -n TEXT ๐ Device model name. [default: Chromecast 1st Gen] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
```
#### `watch`
```bash
Usage: cast-convert watch [OPTIONS] ๐PATHS
๐ Watch directories for new or modified videos and convert them.
โญโ Arguments โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ * paths ๐PATHS Path(s) to video(s). [required] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --help Show this message and exit. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ ๐บ Device โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --name -n TEXT ๐ Device model name. [default: Chromecast 1st Gen] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ ๐ฅ Encoder Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --jobs -j INTEGER ๐ข Number of simultaneous transcoding jobs. โ
โ [default: 2] โ
โ --replace -r ๐พ Replace original file with transcoded video. โ
โ --threads -t INTEGER ๐งต Number of threads to tell FFMPEG to use per โ
โ job. โ
โ [default: 12] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
```