Skip to content

Commit

Permalink
Normalize initial volume input to use decibels as that is what will b…
Browse files Browse the repository at this point in the history
…e output when using the + and - keys on the keyboard.
  • Loading branch information
eat-sleep-code committed Oct 28, 2020
1 parent 1462195 commit 48a9d0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tiny-tv-resume
+ _--removeVerticalBars_ : Remove the vertical black bars (pillar box) from the input file. This time-intensive process will also resize the video to the maximum video height. *(default: False)*
+ _--removeHorizontalBars_ : Remove the horizontal black bars (letter box) from the input file. This time-intensive process will also resize the video to the maximum video height. *(default: False)*
+ _--resize_ : Resize the video to the maximum video height. This is a time-intensive process.
+ _--volume_ : Set the initial volume *(default: 100 `[1db]`)*
+ _--volume_ : Set the initial volume in decibels [db] *(default: -20, min: -60, max: 6`)*
+ _--loop_ : Set whether video plays continuously in a loop *(default: True)*

---
Expand Down Expand Up @@ -87,25 +87,25 @@ tiny-tv https://www.youtube.com/watch?v=h8NrKjJPAuw --saveAs 'Bugs Bunny.mp4' --
#### To play a music video from your Raspberry Pi at a volume of 3db:

```
tiny-tv 'Becky G - Mayores (featuring Bad Bunny).mp4' --category 'music' --volume 300
tiny-tv 'Becky G - Mayores (featuring Bad Bunny).mp4' --category 'music' --volume 3
```

Alternatively, you can type the video subfolder instead of using the category argument:

```
tiny-tv 'music/Becky G - Mayores (featuring Bad Bunny).mp4' --volume 300
tiny-tv 'music/Becky G - Mayores (featuring Bad Bunny).mp4' --volume -10
```

#### To play all the cartoons in a loop:

```
tiny-tv 'category' --category 'cartoons' --volume 100
tiny-tv 'category' --category 'cartoons' --volume 0
```

#### Keep Tiny TV playing even after SSH session ends

```
tiny-tv-persist 'category' --music --volume 300
tiny-tv-persist 'category' --category 'christmas' --volume 3
```
After the video begins playing, you may:
1) Press __Ctrl-A__.
Expand Down
15 changes: 11 additions & 4 deletions tiny-tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
parser.add_argument('--removeVerticalBars', dest='removeVerticalBars', help='Remove the vertical black bars from the input file (time-intensive)')
parser.add_argument('--removeHorizontalBars', dest='removeHorizontalBars', help='Remove the horizontal black bars from the input file (time-intensive)')
parser.add_argument('--resize', dest='resize', help='Resize but do not crop')
parser.add_argument('--volume', dest='volume', help='Set the initial volume', type=int)
parser.add_argument('--volume', dest='volume', help='Set the initial volume in decibels (-60 to 6)', type=int)
parser.add_argument('--loop', dest='loop', help='Set whether video plays continuously in a loop')
args = parser.parse_args()

Expand Down Expand Up @@ -79,11 +79,18 @@

# ------------------------------------------------------------------------------

volume = args.volume or 100
volume = args.volume or -20
maxVolume = 6
minVolume = -60
# Convert decibels to millibels
try:
volume = int(volume)
volume = int(volume) * 100
if volume > maxVolume * 100:
volume = maxVolume * 100
if volume < minVolume * 100:
volume = minVolume * 100
except:
volume = 100
volume = -2000

# ------------------------------------------------------------------------------

Expand Down

0 comments on commit 48a9d0f

Please sign in to comment.