redsolver / yt-splitter

Downloads and splits audio tracks from a YouTube video according to the chapters/tracks. Useful for compilations or full album uploads.
MIT License
74 stars 9 forks source link

Feature Request: Use best quality audio setting on youtube-dl #5

Open gobuchul opened 2 years ago

gobuchul commented 2 years ago

The current implementation uses the default audio quality setting on youtube-dl passing the flag: "-audio-quality 0" would achieve this.

nicolaasjan commented 1 year ago

The current implementation uses the default audio quality setting on youtube-dl passing the flag: "-audio-quality 0" would achieve this.

That would be: --audio-quality 0 (VBR; 256kbps) ;) The default for youtube-dl is 128kbps.

nicolaasjan commented 1 year ago

The following change in yt_splitter.dart results in a much faster download (only audio is downloaded) and better mp3 quality:

@@ -47,9 +47,13 @@ void main(List<String> arguments) async {
         //'--write-description',
         '--write-info-json',
         '--write-thumbnail',
+        '--format',
+        'bestaudio',
         '--extract-audio',
         '--audio-format',
         'mp3',
+        '--audio-quality',
+        '0',
         '--output',
         'output.%(ext)s',
         'https://www.youtube.com/watch?v=$videoId'

Tested with https://www.youtube.com/watch?v=13m5-0EOwIM :

yt-splitter 13m5-0EOwIM
YT video: 13m5-0EOwIM...
Downloading and converting audio file from YouTube...
[youtube] 13m5-0EOwIM: Downloading webpage
[info] Writing video description metadata as JSON to: output.info.json
[youtube] 13m5-0EOwIM: Downloading thumbnail ...
[youtube] 13m5-0EOwIM: Writing thumbnail to: output.jpg
[download] Destination: output.webm
08/21 19:48:08 [NOTICE] Downloading 1 item(s)
[#66ec7b 11MiB/108MiB(10%) CN:10 DL:11MiB ETA:8s]
[#66ec7b 22MiB/108MiB(20%) CN:10 DL:11MiB ETA:7s]
[#66ec7b 34MiB/108MiB(31%) CN:10 DL:11MiB ETA:6s]
[#66ec7b 45MiB/108MiB(42%) CN:10 DL:11MiB ETA:5s]
[#66ec7b 57MiB/108MiB(52%) CN:10 DL:11MiB ETA:4s]
[#66ec7b 69MiB/108MiB(63%) CN:10 DL:11MiB ETA:3s]
[#66ec7b 80MiB/108MiB(74%) CN:10 DL:11MiB ETA:2s]
[#66ec7b 92MiB/108MiB(85%) CN:10 DL:11MiB ETA:1s]
[#66ec7b 103MiB/108MiB(95%) CN:7 DL:11MiB]
[#66ec7b 103MiB/108MiB(95%) CN:7 DL:10MiB]
[#66ec7b 103MiB/108MiB(95%) CN:7 DL:9.3MiB]
[#66ec7b 103MiB/108MiB(95%) CN:7 DL:8.1MiB]
[#66ec7b 104MiB/108MiB(96%) CN:7 DL:6.9MiB]
[#66ec7b 104MiB/108MiB(96%) CN:7 DL:5.8MiB]
[#66ec7b 104MiB/108MiB(96%) CN:7 DL:4.6MiB]
[#66ec7b 104MiB/108MiB(96%) CN:7 DL:3.4MiB ETA:1s]
[#66ec7b 105MiB/108MiB(96%) CN:7 DL:2.2MiB ETA:1s]
[#66ec7b 105MiB/108MiB(97%) CN:7 DL:1.1MiB ETA:2s]
[#66ec7b 105MiB/108MiB(97%) CN:7 DL:216KiB ETA:13s]
[#66ec7b 105MiB/108MiB(97%) CN:7 DL:216KiB ETA:12s]
[#66ec7b 105MiB/108MiB(97%) CN:7 DL:217KiB ETA:11s]
[#66ec7b 106MiB/108MiB(97%) CN:7 DL:217KiB ETA:10s]
[#66ec7b 106MiB/108MiB(98%) CN:7 DL:218KiB ETA:9s]
[#66ec7b 106MiB/108MiB(98%) CN:6 DL:246KiB ETA:6s]
[#66ec7b 106MiB/108MiB(98%) CN:6 DL:244KiB ETA:5s]
[#66ec7b 107MiB/108MiB(98%) CN:6 DL:241KiB ETA:5s]
[#66ec7b 107MiB/108MiB(99%) CN:6 DL:238KiB ETA:4s]
[#66ec7b 107MiB/108MiB(99%) CN:6 DL:235KiB ETA:3s]
[#66ec7b 107MiB/108MiB(99%) CN:6 DL:232KiB ETA:2s]
[#66ec7b 107MiB/108MiB(99%) CN:6 DL:229KiB ETA:2s]
[#66ec7b 108MiB/108MiB(99%) CN:6 DL:226KiB ETA:1s]
[#66ec7b 108MiB/108MiB(99%) CN:6 DL:223KiB]
08/21 19:48:40 [NOTICE] Download complete: /home/nico/.cache/yt-splitter/13m5-0EOwIM/output.webm.part
Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
66ec7b|OK  |   3.3MiB/s|/home/nico/.cache/yt-splitter/13m5-0EOwIM/output.webm.part
Status Legend:
(OK):download completed.
[aria2c] Downloaded 113672069 bytes
[download] 100% of 108.41MiB in 00:32
[ffmpeg] Destination: output.mp3
Deleting original file output.webm (pass -k to keep)
[ffmpeg] Adding metadata to 'output.mp3'
[ffmpeg] Adding thumbnail to "output.mp3"
Tracks will be saved to Pink Floyd - "Delicate Sound of Thunder" New 4k Edition
Splitting mp3 file...
[splitting] 1. Shine On You Crazy Diamond...
[splitting] 2. Signs of Life...
[splitting] 3. Learning to Fly...
[splitting] 4. Sorrow...
[splitting] 5. Dogs of War...
[splitting] 6. On The Turning Away...
[splitting] 7. One of These Days...
[splitting] 8. Time...
[splitting] 9. On The Run...
[splitting] 10. The Great Gig in the Sky...
[splitting] 11. Wish You Were Here...
[splitting] 12. US and Them...
[splitting] 13. Money...
[splitting] 14. Comfortably Numb...
[splitting] 15. One Slip...
[splitting] 16. Run Like Hell...