axcore / tartube

A GUI front-end for youtube-dl, partly based on youtube-dl-gui and written in Python 3 / Gtk 3
GNU Lesser General Public License v2.1
2.12k stars 112 forks source link

How to change downloaded audio file speed/tempo? #560

Closed bheeshmpita closed 1 year ago

bheeshmpita commented 1 year ago

i like to download the audio files through mp3 drag and drop mode and change its speed through ffmpeg using following command ffmpeg -i input.mp3 -f:a atempo=1.5 output.mp3 How can i integrate these 2 steps into 1 in tartube where I drop a link to the audio and the final output is automatically the desired 1.5 (or any other factor) times the original audio in link? @axcore any suggestions?

axcore commented 1 year ago

I don't know. Probably the download option you need is --postprocessor-args (see the yt-dlp documentation for yourself), but I have never experimented with it.

Reddit is a good place ask how to make yt-dlp do things like this; once you have the answer for yt-dlp, then it's quite simple to translate it to Tartube.

bheeshmpita commented 1 year ago

but the desired process has to be done by ffmpeg, i think. In one of the earlies issues submitted, you mentioned that you could help in translating appropriate command for the tartube, so i thought maybe you could help here when the command for the ffmpeg is ffmpeg -i input.mp3 -f:a atempo=1.5 output.mp3

axcore commented 1 year ago

Alas, I don't know anything about FFmpeg. Tartube supports FFmpeg only because yt-dlp supports it, and because I was able to borrow someone else's code for the FFmpeg options.

If you are happy to perform two separate steps (download the videos, then process them with FFmpeg), then you can do that in Tartube. In the Videos tab, download the videos. Then select them all, right-click them, and select Special > Process with FFmpeg.

Fill in the Extra command line options box like this, then click the Process files button at the bottom of the window.

ffmpegstuff

(This is just a suggestion, I don't know if it will work or not.)

pukkandan commented 1 year ago

ffmpeg -i input.mp3 -f:a atempo=1.5 output.mp3

This is wrong. Maybe you meant -f:a mp3 atempo=1.5?

Assuming the mp3 is being created by passing -x --audio-format mp3 to yt-dlp, what you want is --ppa "ffmpeg:-f:a mp3 atempo=1.5". If not, I'd have to see the logs to figure out the exact command.

bheeshmpita commented 1 year ago

@pukkandan I tried --ppa "ffmpeg:-f:a mp3 atempo=1.5" but it didn't helped. Here is the output of the commands. output.txt

pukkandan commented 1 year ago

Try --ppa "ExtractAUdio+ffmpeg:-f:a mp3 atempo=1.5". Also, confirm directly with ffmpeg that -f:a mp3 atempo=1.5 is actually what you want. I suggested just based on your comment, I don't know if it's correct. If you can confirm ffmpeg works, but yt-dlp doesn't, provide logs of both - make sure to run yt-dlp with -v

bheeshmpita commented 1 year ago

@pukkandan the ffmpeg command earlier submitted by me seems not to be working somehow, dont know why. Instead this format is working ffmpeg -i input.mp3 -af atempo=1.5 output.mp3 please make suitable changes for me to be fed into the the tartube. here is the output of ffmpeg processing. ffmpeg process output.txt

pukkandan commented 1 year ago

Just put whatever's between input and output after --ppa ExtractAudio+ffmpeg:. But are you sure that works when input file is webm? - Since you are trying to change tempo and convert to mp3 in one go. Or, if you just wanted to do this after conversion, do https://github.com/axcore/tartube/issues/560#issuecomment-1587680949

axcore commented 1 year ago

Neither ffmpeg:-f:a mp3 atempo=1.5 nor ExtractAUdio+ffmpeg:-f:a mp3 atempo=1.5 is working for me.

Tested with yt-dlp 2023.06.22, Tartube not used.


$ yt-dlp -vU -x --audio-format mp3 --postprocessor-args "ffmpeg:-f:a mp3 atempo=1.5" https://www.youtube.com/watch?v=CS9OO0S5w2k

[debug] Command-line config: ['-vU', '-x', '--audio-format', 'mp3', '--postprocessor-args', 'ffmpeg:-f:a mp3 atempo=1.5', 'https://www.youtube.com/watch?v=CS9OO0S5w2k'] [debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8 [debug] yt-dlp version stable@2023.06.22 [812cdfa06] (pip) [debug] Python 3.10.6 (CPython x86_64 64bit) - Linux-5.15.0-72-generic-x86_64-with-glibc2.35 (OpenSSL 3.0.2 15 Mar 2022, glibc 2.35) [debug] exe versions: ffmpeg 4.4.2 (setts), ffprobe 4.4.2 [debug] Optional libraries: Cryptodome-3.17, brotli-1.0.9, certifi-2020.06.20, mutagen-1.46.0, secretstorage-3.3.1, sqlite3-2.6.0, websockets-10.4 [debug] Proxy map: {} [debug] Loaded 1851 extractors [debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest Available version: stable@2023.06.22, Current version: stable@2023.06.22 yt-dlp is up to date (stable@2023.06.22) [youtube] Extracting URL: https://www.youtube.com/watch?v=CS9OO0S5w2k [youtube] CS9OO0S5w2k: Downloading webpage [youtube] CS9OO0S5w2k: Downloading ios player API JSON [youtube] CS9OO0S5w2k: Downloading android player API JSON [youtube] CS9OO0S5w2k: Downloading m3u8 information [debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto [debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id [info] CS9OO0S5w2k: Downloading 1 format(s): 251 [debug] Invoking http downloader on "https://rr4---sn-cu-nuoz.googlevideo.com/videoplayback?expire=1687454521&ei=2S6UZKLBIs--mLAPmsyUoAw&ip=91.110.100.47&id=o-ALPloyLmfbLkr1nQHxM0lmsljlbsmZpxYJukWZmh1NVo&itag=251&source=youtube&requiressl=yes&mh=VS&mm=31%2C29&mn=sn-cu-nuoz%2Csn-cu-ajte6&ms=au%2Crdu&mv=m&mvi=4&pl=25&gcr=gb&initcwndbps=1697500&spc=qEK7B3MkLV5p6P7Hn3RmJkRI9K24uh0&vprv=1&svpuc=1&mime=audio%2Fwebm&gir=yes&clen=3847741&dur=241.161&lmt=1574949542802277&mt=1687432629&fvip=5&keepalive=yes&fexp=24007246%2C24362686&beids=24350017&c=ANDROID&txp=5531432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cgcr%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRAIgCcKXpdal5fg6GEAxazbxwhyT8pfRAG-3mAiDUO3sedcCID_701WAWp7OIXfZA2UxVjXazuNg50g3L-9v5pP_JFtM&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIhANminBH8yYk6Uo4VDx_TwKc8pXEPQI5fmiP96kMiBU0HAiAuMvGbLQRGbsphPEcSHYxmvR_mDsSRu3ssbjTWhkxOSg%3D%3D" [download] Destination: Village People - YMCA OFFICIAL Music Video 1978 [CS9OO0S5w2k].webm [download] 100% of 3.67MiB in 00:00:00 at 3.99MiB/s [debug] ffmpeg command line: ffprobe -show_streams 'file:Village People - YMCA OFFICIAL Music Video 1978 [CS9OO0S5w2k].webm' [ExtractAudio] Destination: Village People - YMCA OFFICIAL Music Video 1978 [CS9OO0S5w2k].mp3 [debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Village People - YMCA OFFICIAL Music Video 1978 [CS9OO0S5w2k].webm' -vn -acodec libmp3lame -q:a 5.0 -movflags +faststart -f:a mp3 atempo=1.5 'file:Village People - YMCA OFFICIAL Music Video 1978 [CS9OO0S5w2k].mp3' Deleting original file Village People - YMCA OFFICIAL Music Video 1978 [CS9OO0S5w2k].webm (pass -k to keep)

pukkandan commented 1 year ago

OP changed their command to

ffmpeg -i input.mp3 -af atempo=1.5 output.mp3

which would translate to:

❯ yt-dlp -x --audio-format mp3 --ppa "ExtractAudio+ffmpeg:-af atempo=1.5" -v test:youtube --force-over
[debug] Command-line config: ['--ignore-config', '-x', '--audio-format', 'mp3', '--ppa', 'ExtractAudio+ffmpeg:-af atempo=1.5', '-v', 'test:youtube', '--force-over']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.06.22 [812cdfa06] (source)
[debug] Lazy loading extractors is disabled
[debug] Git HEAD: 29b741553
[debug] Python 3.11.0 (CPython AMD64 64bit) - Windows-10-10.0.22000-SP0 (OpenSSL 1.1.1q  5 Jul 2022)
[debug] exe versions: ffmpeg n5.1.2-8-g5746987bad-20221204 (fdk,setts), ffprobe N-109332-g45ab5307a6-20221201, phantomjs 2.1.1
[debug] Optional libraries: Cryptodome-3.18.0, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-10.4
[debug] Proxy map: {}
[debug] Loaded 1851 extractors
[TestURL] Extracting URL: test:youtube
[TestURL] Test URL: https://www.youtube.com/watch?v=BaW_jenozKc&t=1s&end=9
[youtube] Extracting URL: https://www.youtube.com/watch?v=BaW_jenozKc&t=1s&end=9
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading ios player API JSON
[youtube] BaW_jenozKc: Downloading android player API JSON
[youtube] BaW_jenozKc: Downloading m3u8 information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
[info] BaW_jenozKc: Downloading 1 format(s): 251
Deleting existing file youtube-dl test video "'⧸⧹ä↭𝕐 [BaW_jenozKc].mp3
[debug] Invoking http downloader on "https://rr3---sn-gwpa-jjwe.googlevideo.com/videoplayback?expire=1687478552&ei=uIyUZO-UKPSY3LUPsYGGmA8&ip=49.37.227.147&id=o-AJoviVuGkfl9cYEmf_9mzJFWGpNQE77hY03S-EnQc_BV&itag=251&source=youtube&requiressl=yes&mh=Rf&mm=31%2C29&mn=sn-gwpa-jjwe%2Csn-gwpa-h55e7&ms=au%2Crdu&mv=m&mvi=3&pl=20&initcwndbps=486250&spc=qEK7B3_a1NsPI9Ugxfyfo210uZVQAYg&vprv=1&svpuc=1&mime=audio%2Fwebm&gir=yes&clen=142292&dur=9.841&lmt=1506055557712479&mt=1687456861&fvip=1&keepalive=yes&fexp=24007246%2C24363391&c=ANDROID&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRAIgWCy16e7pRV_jCgUCtDkVFPf7Cq6kA2iSEFTEVHCTorwCIC9nKFJ3qbqdftu3kK_ilDq00kKc1ErJV9-iz0JauWjf&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhAKfwU3KELysi5h7DFmchurY9KC1SNgUfwIySt9oy_ovPAiEAxdaZGecAUC2ZBo6mEqJiyAJJFhwq5pUrJYxgIznfSVY%3D"
[debug] File locking is not supported. Proceeding without locking
[download] Destination: youtube-dl test video "'⧸⧹ä↭𝕐 [BaW_jenozKc].webm
[download] 100% of  138.96KiB in 00:00:00 at 1.15MiB/s
[debug] ffmpeg command line: ffprobe -show_streams "file:youtube-dl test video "'⧸⧹ä↭𝕐 [BaW_jenozKc].webm"
[ExtractAudio] Destination: youtube-dl test video "'⧸⧹ä↭𝕐 [BaW_jenozKc].mp3
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:youtube-dl test video "'⧸⧹ä↭𝕐 [BaW_jenozKc].webm" -vn -acodec libmp3lame "-q:a" 5.0 -movflags "+faststart" -af "atempo=1.5" "file:youtube-dl test video "'⧸⧹ä↭𝕐 [BaW_jenozKc].mp3"
Deleting original file youtube-dl test video "'⧸⧹ä↭𝕐 [BaW_jenozKc].webm (pass -k to keep)
axcore commented 1 year ago

Ok, the equivalent for Tartube is:

high speed

bheeshmpita commented 1 year ago

Thanks @pukkandan @axcore for your help, ExtractAudio+ffmpeg:-af atempo=1.5 is the solution.