mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Expect Python to be already in PATH (#114)
* Expect python to already be in PATH * Expect python to be in PATH * Fix special handlling of conversion on windows * Some cleaning * Update docs
This commit is contained in:
@@ -2,6 +2,16 @@ import subprocess
|
||||
import os
|
||||
|
||||
|
||||
"""
|
||||
What are the differences and similarities between ffmpeg, libav, and avconv?
|
||||
https://stackoverflow.com/questions/9477115
|
||||
ffmeg encoders high to lower quality
|
||||
libopus > libvorbis >= libfdk_aac > aac > libmp3lame
|
||||
libfdk_aac due to copyrights needs to be compiled by end user
|
||||
on MacOS brew install ffmpeg --with-fdk-aac will do just that. Other OS?
|
||||
https://trac.ffmpeg.org/wiki/Encode/AAC
|
||||
"""
|
||||
|
||||
def song(input_song, output_song, folder, avconv=False, verbose=False):
|
||||
"""Do the audio format conversion."""
|
||||
if not input_song == output_song:
|
||||
@@ -17,17 +27,12 @@ def song(input_song, output_song, folder, avconv=False, verbose=False):
|
||||
|
||||
def convert_with_avconv(input_song, output_song, folder, verbose):
|
||||
"""Convert the audio file using avconv."""
|
||||
if os.name == 'nt':
|
||||
avconv_path = '..\\Scripts\\avconv.exe'
|
||||
else:
|
||||
avconv_path = 'avconv'
|
||||
|
||||
if verbose:
|
||||
level = 'debug'
|
||||
else:
|
||||
level = '0'
|
||||
|
||||
command = [avconv_path,
|
||||
command = ['avconv',
|
||||
'-loglevel', level,
|
||||
'-i', os.path.join(folder, input_song),
|
||||
'-ab', '192k',
|
||||
@@ -37,27 +42,11 @@ def convert_with_avconv(input_song, output_song, folder, verbose):
|
||||
|
||||
|
||||
def convert_with_ffmpeg(input_song, output_song, folder, verbose):
|
||||
"""Convert the audio file using FFMpeg.
|
||||
|
||||
What are the differences and similarities between ffmpeg, libav, and avconv?
|
||||
https://stackoverflow.com/questions/9477115
|
||||
ffmeg encoders high to lower quality
|
||||
libopus > libvorbis >= libfdk_aac > aac > libmp3lame
|
||||
libfdk_aac due to copyrights needs to be compiled by end user
|
||||
on MacOS brew install ffmpeg --with-fdk-aac will do just that. Other OS?
|
||||
https://trac.ffmpeg.org/wiki/Encode/AAC
|
||||
"""
|
||||
|
||||
if os.name == "nt":
|
||||
ffmpeg_pre = '..\\Scripts\\ffmpeg.exe '
|
||||
else:
|
||||
ffmpeg_pre = 'ffmpeg '
|
||||
|
||||
ffmpeg_pre += '-y '
|
||||
"""Convert the audio file using FFmpeg."""
|
||||
ffmpeg_pre = 'ffmpeg -y '
|
||||
if not verbose:
|
||||
ffmpeg_pre += '-hide_banner -nostats -v panic '
|
||||
|
||||
ffmpeg_params = ''
|
||||
input_ext = input_song.split('.')[-1]
|
||||
output_ext = output_song.split('.')[-1]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user