nathom / streamrip

A scriptable music downloader for Qobuz, Tidal, SoundCloud, and Deezer
GNU General Public License v3.0
2.35k stars 209 forks source link

[BUG] Bad concatenation of mp3 segments (Soundcloud) #633

Open acrilique opened 4 months ago

acrilique commented 4 months ago

Describe the bug

When playing the mp3 track obtained with the command below, I notice that every few seconds, a portion of the audio is empty and/or skipped. It almost seems like the segments of the mp3 are reordered in a weird way. I've tried with different audio tracks from soundcloud and I also tried playing the audio in different systems (my Android phone, my Fedora Linux laptop and my Windows 11 PC). I have also tried downloading from different systems: Fedora Server and Windows 11, both with latest version (git). I have tried modifying the sections of downloadable.py that carry this task but I haven't succeeded fixing this yet.

Command Used

rip -vvv search soundcloud track --first 'carrion sin chito'

Debug Traceback

C:\Users\Estudi>rip -vvv search --first soundcloud track "carrion sin chito"
[21:43:43] DEBUG    Showing all debug logs                                                                                                                                                             cli.py:102
⠋ Logging into soundcloud           DEBUG    Current valid client_id='yQRB7PK9NryQ0XujK7NOwO2K5YcSBRc5' app_version='1708424140'
         soundcloud.py:52
           DEBUG    Requesting https://api-v2.soundcloud.com/search/tracks with _params={'client_id': 'yQRB7PK9NryQ0XujK7NOwO2K5YcSBRc5', 'app_version': '1708424140', 'app_locale': 'en', 'q': soundcloud.py:239
                    'carrion sin chito', 'facet': 'genre', 'user_id': '174818-284079-659070-272534', 'limit': 1, 'offset': 0, 'linked_partitioning': '1'}, headers=None
           DEBUG    Executing SELECT EXISTS(SELECT 1 FROM downloads WHERE id=?)                                                                                                                         db.py:108
           DEBUG    Requesting https://api-v2.soundcloud.com/tracks/842051494 with _params={'client_id': 'yQRB7PK9NryQ0XujK7NOwO2K5YcSBRc5', 'app_version': '1708424140', 'app_locale': 'en'},  soundcloud.py:239
                    headers=None
⠋ Resolving URLs...           DEBUG    infos=['842051494', 'https://api-v2.soundcloud.com/media/soundcloud:tracks:842051494/cccea43a-dec4-426d-836e-5f2778c10cbd/stream/hls']                                      soundcloud.py:110
           DEBUG    Requesting https://api-v2.soundcloud.com/media/soundcloud:tracks:842051494/cccea43a-dec4-426d-836e-5f2778c10cbd/stream/hls with _params={'client_id':                       soundcloud.py:239
                    'yQRB7PK9NryQ0XujK7NOwO2K5YcSBRc5', 'app_version': '1708424140', 'app_locale': 'en'}, headers=None
[21:43:45] DEBUG    Tagging with [('TIT2', TIT2(encoding=<Encoding.UTF8: 3>, text=['Eladio Carrion - Sin Ti'])), ('TPE1', TPE1(encoding=<Encoding.UTF8: 3>, text=['Eladio Carrion'])), ('TALB',     tagger.py:253
                    TALB(encoding=<Encoding.UTF8: 3>, text=['Sauce Boyz Care Package'])), ('TPE2', TPE2(encoding=<Encoding.UTF8: 3>, text=['Eladio Carrion'])), ('TYER',
                    TYER(encoding=<Encoding.UTF8: 3>, text=['2020'])), ('TCON', TCON(encoding=<Encoding.UTF8: 3>, text=['Latin Music'])), ('TCOP', TCOP(encoding=<Encoding.UTF8: 3>, text=['℗ 2020
                    Rimas Entertainment LLC.'])), ('TRCK', TRCK(encoding=<Encoding.UTF8: 3>, text=['1/1'])), ('TPOS', TPOS(encoding=<Encoding.UTF8: 3>, text=['0/1'])), ('TSRC',
                    TSRC(encoding=<Encoding.UTF8: 3>, text=['QM6P42002694']))]
           DEBUG    No arguments provided. Codec defaults will be used                                                                                                                            converter.py:66
           DEBUG    FFmpeg codec extra argument: -q:a 0                                                                                                                                           converter.py:72
           DEBUG    ['ffmpeg', '-i', 'C:\\Users\\Estudi\\StreamripDownloads\\01. Eladio Carrion - Eladio Carrion - Sin Ti.mp3', '-c:a', 'libmp3lame', '-c:v', 'copy', '-q:a', '0', '-y',         converter.py:148
                    'C:\\Users\\Estudi\\AppData\\Local\\Temp\\01. Eladio Carrion - Eladio Carrion - Sin Ti.mp3']
           DEBUG    Generated conversion command: ['ffmpeg', '-i', 'C:\\Users\\Estudi\\StreamripDownloads\\01. Eladio Carrion - Eladio Carrion - Sin Ti.mp3', '-c:a', 'libmp3lame', '-c:v',       converter.py:85
                    'copy', '-q:a', '0', '-y', 'C:\\Users\\Estudi\\AppData\\Local\\Temp\\01. Eladio Carrion - Eladio Carrion - Sin Ti.mp3']
[21:43:49] DEBUG    Source removed: C:\Users\Estudi\StreamripDownloads\01. Eladio Carrion - Eladio Carrion - Sin Ti.mp3                                                                           converter.py:95
           DEBUG    Moved: C:\Users\Estudi\AppData\Local\Temp\01. Eladio Carrion - Eladio Carrion - Sin Ti.mp3 -> C:\Users\Estudi\StreamripDownloads\01. Eladio Carrion - Eladio Carrion - Sin    converter.py:98
                    Ti.mp3
           DEBUG    Executing INSERT INTO downloads (id) VALUES (?)                                                                                                                                     db.py:124
           DEBUG    Items to add: (842051494,)                                                                                                                                                          db.py:125
           DEBUG    UNIQUE constraint failed: downloads.id                                                                                                                                              db.py:132
────────────────────────────────────────────────────────────────────────────────────── Downloading Eladio Carrion - Sin Ti ──────────────────────────────────────────────────────────────────────────────────────
           DEBUG    Removing dirs {'C:\\Users\\Estudi\\StreamripDownloads\\__artwork'}                                                                                                              artwork.py:19

Config File

[downloads]
# Folder where tracks are downloaded to
folder = "/home/user/media/music"
# Put Qobuz albums in a 'Qobuz' folder, Tidal albums in 'Tidal' etc.
source_subdirectories = false

# Download (and convert) tracks all at once, instead of sequentially. 
# If you are converting the tracks, or have fast internet, this will 
# substantially improve processing speed.
concurrency = true
# The maximum number of tracks to download at once
# If you have very fast internet, you will benefit from a higher value,
# A value that is too high for your bandwidth may cause slowdowns
# Set to -1 for no limit
max_connections = 6
# Max number of API requests per source to handle per minute
# Set to -1 for no limit
requests_per_minute = 60

[qobuz]
# 1: 320kbps MP3, 2: 16/44.1, 3: 24/<=96, 4: 24/>=96
quality = 3
# This will download booklet pdfs that are included with some albums
download_booklets = true

# Authenticate to Qobuz using auth token? Value can be true/false only
use_auth_token = false
# Enter your userid if the above use_auth_token is set to true, else enter your email
email_or_userid = ""
# Enter your auth token if the above use_auth_token is set to true, else enter the md5 hash of your plaintext password
password_or_token = ""
# Do not change
app_id = ""
# Do not change
secrets = []

[tidal]
# 0: 256kbps AAC, 1: 320kbps AAC, 2: 16/44.1 "HiFi" FLAC, 3: 24/44.1 "MQA" FLAC
quality = 3
# This will download videos included in Video Albums.
download_videos = true

# Do not change any of the fields below
user_id = ******
country_code = "ES"
access_token = "******"
refresh_token = "******"
# Tokens last 1 week after refresh. This is the Unix timestamp of the expiration
# time. If you haven't used streamrip in more than a week, you may have to log
# in again using `rip config --tidal`
token_expiry = 1708046007.9562185

[deezer]
# 0, 1, or 2
# This only applies to paid Deezer subscriptions. Those using deezloader
# are automatically limited to quality = 1
quality = 2
# An authentication cookie that allows streamrip to use your Deezer account
# See https://github.com/nathom/streamrip/wiki/Finding-Your-Deezer-ARL-Cookie
# for instructions on how to find this
arl = ""
# This allows for free 320kbps MP3 downloads from Deezer
# If an arl is provided, deezloader is never used
use_deezloader = true
# This warns you when the paid deezer account is not logged in and rip falls
# back to deezloader, which is unreliable
deezloader_warnings = true

[soundcloud]
# Only 0 is available for now
quality = 0
# This changes periodically, so it needs to be updated
client_id = "******"
app_version = "******"

[youtube]
# Only 0 is available for now
quality = 0
# Download the video along with the audio
download_videos = false
# The path to download the videos to
video_downloads_folder = "/home/use/StreamripDownloads/YouTubeVideos"

[database]
# Create a database that contains all the track IDs downloaded so far
# Any time a track logged in the database is requested, it is skipped
# This can be disabled temporarily with the --no-db flag
downloads_enabled = false
# Path to the downloads database 
downloads_path = "/home/user/.config/streamrip/downloads.db"
# If a download fails, the item ID is stored here. Then, `rip repair` can be
# called to retry the downloads
failed_downloads_enabled = true
failed_downloads_path = "/home/user/.config/streamrip/failed_downloads.db"

# Convert tracks to a codec after downloading them.
[conversion]
enabled = false
# FLAC, ALAC, OPUS, MP3, VORBIS, or AAC
codec = "FLAC"
# In Hz. Tracks are downsampled if their sampling rate is greater than this. 
# Value of 48000 is recommended to maximize quality and minimize space
sampling_rate = 48000
# Only 16 and 24 are available. It is only applied when the bit depth is higher
# than this value.
bit_depth = 24
# Only applicable for lossy codecs
lossy_bitrate = 320

# Filter a Qobuz artist's discography. Set to 'true' to turn on a filter.
# This will also be applied to other sources, but is not guaranteed to work correctly
[qobuz_filters]
# Remove Collectors Editions, live recordings, etc.
extras = false
# Picks the highest quality out of albums with identical titles.
repeats = false
# Remove EPs and Singles
non_albums = false
# Remove albums whose artist is not the one requested
features = false
# Skip non studio albums
non_studio_albums = false
# Only download remastered albums
non_remaster = false

[artwork]
# Write the image to the audio file
embed = true
# The size of the artwork to embed. Options: thumbnail, small, large, original.
# "original" images can be up to 30MB, and may fail embedding. 
# Using "large" is recommended.
embed_size = "large"
# If this is set to a value > 0, max(width, height) of the embedded art will be set to this value in pixels
# Proportions of the image will remain the same
embed_max_width = -1
# Save the cover image at the highest quality as a seperate jpg file
save_artwork = false
# If this is set to a value > 0, max(width, height) of the saved art will be set to this value in pixels
# Proportions of the image will remain the same
saved_max_width = -1

[metadata]
# Sets the value of the 'ALBUM' field in the metadata to the playlist's name. 
# This is useful if your music library software organizes tracks based on album name.
set_playlist_to_album = true
# If part of a playlist, sets the `tracknumber` field in the metadata to the track's 
# position in the playlist instead of its position in its album
renumber_playlist_tracks = true
# The following metadata tags won't be applied
# See https://github.com/nathom/streamrip/wiki/Metadata-Tag-Names for more info
exclude = []

# Changes the folder and file names generated by streamrip.
[filepaths]
# Create folders for single tracks within the downloads directory using the folder_format
# template
add_singles_to_folder = false
# Available keys: "albumartist", "title", "year", "bit_depth", "sampling_rate",
# "id", and "albumcomposer"
folder_format = "{albumartist} - {title} ({year}) [{container}] [{bit_depth}B-{sampling_rate}kHz]"
# Available keys: "tracknumber", "artist", "albumartist", "composer", "title",
# and "albumcomposer", "explicit"
track_format = "{tracknumber:02}. {artist} - {title}{explicit}"
# Only allow printable ASCII characters in filenames.
restrict_characters = false
# Truncate the filename if it is greater than this number of characters
# Setting this to false may cause downloads to fail on some systems
truncate_to = 120

# Last.fm playlists are downloaded by searching for the titles of the tracks
[lastfm]
# The source on which to search for the tracks.
source = "qobuz"
# If no results were found with the primary source, the item is searched for 
# on this one.
fallback_source = ""

[cli]
# Print "Downloading {Album name}" etc. to screen
text_output = true
# Show resolve, download progress bars
progress_bars = true
# The maximum number of search results to show in the interactive menu
max_search_results = 100

[misc]
# Metadata to identify this config file. Do not change.
version = "2.0.3"
# Print a message if a new version of streamrip is available 
check_for_updates = true

Operating System

Linux (Fedora Server), Windows 11

streamrip version

rip, version 2.0.5 (git, latest)

Screenshots and recordings

No response

Additional context

I have 2 very different versions of ffmpeg in the fedora server and in the windows pc:

Fedora: ffmpeg version 6.0.1 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 13 (GCC) configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcdio --enable-libdrm --enable-libjack --enable-libjxl --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-libplacebo --enable-librsvg --enable-librav1e --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libshaderc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libvpl --enable-runtime-cpudetect libavutil 58. 2.100 / 58. 2.100 libavcodec 60. 3.100 / 60. 3.100 libavformat 60. 3.100 / 60. 3.100 libavdevice 60. 1.100 / 60. 1.100 libavfilter 9. 3.100 / 9. 3.100 libswscale 7. 1.100 / 7. 1.100 libswresample 4. 10.100 / 4. 10.100 libpostproc 57. 1.100 / 57. 1.100

Windows: ffmpeg version N-113651-g37e4635212 Copyright (c) 2000-2024 the FFmpeg developers built with gcc 13.2.0 (Rev3, Built by MSYS2 project) configuration: --disable-static --enable-shared --pkg-config=pkgconf --cc='ccache gcc' --cxx='ccache g++' --ld='ccache g++' --extra-cxxflags=-fpermissive --extra-cflags=-Wno-int-conversion --disable-autodetect --enable-amf --enable-bzlib --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-iconv --enable-lzma --enable-nvenc --enable-schannel --enable-zlib --enable-sdl2 --enable-ffnvcodec --enable-nvdec --enable-cuda-llvm --enable-libkvazaar --enable-gmp --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libdav1d --enable-libaom --disable-debug --enable-libfdk-aac --extra-libs=-liconv --extra-cflags=-DKVZ_STATIC_LIB --enable-gpl --enable-version3 --enable-nonfree --shlibdir=/local64/bin-video libavutil 58. 38.100 / 58. 38.100 libavcodec 60. 39.100 / 60. 39.100 libavformat 60. 21.100 / 60. 21.100 libavdevice 60. 4.100 / 60. 4.100 libavfilter 9. 17.100 / 9. 17.100 libswscale 7. 6.100 / 7. 6.100 libswresample 4. 13.100 / 4. 13.100 libpostproc 57. 4.100 / 57. 4.100

acrilique commented 4 months ago

Here is a track that I have downloaded: sample.zip