Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio from tiktok is not downloading. 0 bytes error #996

Closed
bandicuttt opened this issue Dec 12, 2024 · 13 comments · Fixed by #1050
Closed

Audio from tiktok is not downloading. 0 bytes error #996

bandicuttt opened this issue Dec 12, 2024 · 13 comments · Fixed by #1050

Comments

@bandicuttt
Copy link

problem description

I'm using the latest version of cobalt. When I try to download a tiktok consisting of pictures + audio, I get pictures, but I can't download audio. Surprisingly, if I try to download with the parameter “”downloadMode“: ‘audio’”, the audio is downloaded normally. The same behavior I observe on the main.

Pictures separately -- ok
Audio separately -- ok
Audio + pictures -- not ok

your instance configuration

cobalt-api    |
cobalt-api    | cobalt API ^ω⁠^
cobalt-api    | ~~~~~~
cobalt-api    | version: 10.4.4
cobalt-api    | commit: 5973d70053a6d5642ca2eb242e61813478ec0b6b
cobalt-api    | branch: main
cobalt-api    | remote: imputnet/cobalt
cobalt-api    | start time: Thu, 12 Dec 2024 20:49:55 GMT
cobalt-api    | ~~~~~~
cobalt-api    | url: http://localhost:9000/
cobalt-api    | port: 9000
cobalt-api    |
@lostdusty
Copy link

any links to help replicate the issue?

@bandicuttt
Copy link
Author

bandicuttt commented Dec 12, 2024

any links to help replicate the issue?

https://vm.tiktok.com/ZMkLHUYHq/

None of the links where the tiktok contains a swiper are working

@sertraline
Copy link

Can confirm this is an issue even on the main instance. Debugging this is painful because for some reason there is zero debug logging and helpful information on what's happening, so I gave up. But from what I found out the tiktok URLs are working perfectly fine, requests to tiktok complete successfully and the streamInfo gets cached just fine. But accessing the external tunnel will simply give you 0 bytes output.

@sertraline
Copy link

These are ffmpeg args that I receive on my instance. Note the undefinedk.

[
  '-loglevel',
  '-8',
  '-headers',
  'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36\r\n',
  '-i',
  'http://127.0.0.1:9000/itunnel?id=4mYNHNyKIyPHyQm755y-w',
  '-vn',
  '-b:a',
  'undefinedk'
]


args.push("-b:a", `${streamInfo.audioBitrate}k`)

@ngregrichardson
Copy link

Hey, with TikTok possibly becoming unavailable in the US, I'm wondering if this could be looked at more. Attempting to grab some specific videos and it won't work :/ I'm trying to dig through it locally but I'm not too aware of the tunnelling part of the code base

@wukko
Copy link
Member

wukko commented Jan 12, 2025

@ngregrichardson hey! what videos aren't downloading? can you make a new issue and fill out the template? also, using https://mullvad.net/ or https://windscribe.com/ will help with going around the region lock (i hope).

@ngregrichardson
Copy link

ngregrichardson commented Jan 12, 2025

Yeah, hoping VPNs will still get us there 🤞 .

Even on the main instance, try https://www.tiktok.com/@dailydoseofpositivity444/photo/7377016451950972203 with the auto download mode, then click "Download Audio." It downloads a file with 0 bytes. Thanks for the quick response! I am also running locally, so let me know if I can grab any extra info from there.

This is what the streamInfo variable that @sertraline pointed out above is for me, so audioBitrate is undefined.

{
  "exp": 1736697037760,
  "type": "audio",
  "urls": "http://127.0.0.1:9000/itunnel?id=mavHEhkCa5LmaZ4VAQwho",
  "service": "tiktok",
  "filename": "tiktok_dailydoseofpositivity444_7377016451950972203_audio_original.mp3",
  "headers": {
    "cookie": "removing bc idk"
  },
  "metadata": false,
  "audioCopy": false,
  "audioFormat": "mp3",
  "isHLS": false
}

@ngregrichardson
Copy link

I forgot to mention, downloading via audio mode it works properly!

@wukko
Copy link
Member

wukko commented Jan 12, 2025

try https://www.tiktok.com/@dailydoseofpositivity444/photo/7377016451950972203

image

i got the picker and both images saved just fine, are you sure it's this link?

@ngregrichardson
Copy link

ngregrichardson commented Jan 12, 2025

Did the audio file save (and not be 0 bytes) when you click "download audio"?

@wukko
Copy link
Member

wukko commented Jan 12, 2025

...nope

@ngregrichardson
Copy link

ngregrichardson commented Jan 12, 2025

Running locally, when I make a POST request with this body:

{
  "url": "https://www.tiktok.com/@dailydoseofpositivity444/photo/7377016451950972203",
  "downloadMode": "auto"
}

I get this response

{
  "status": "picker",
  "picker": [
    {
      "type": "photo",
      "url": "https://p16-pu-sign-useast8.tiktokcdn-us.com/tos-useast5-i-photomode-tx/4c0576453fd8410eb670e83400aebb34~tplv-photomode-image.jpeg?lk3s=81f88b70&x-expires=1736870400&x-signature=g95uMu2wclbyDm3EVGRuLDsajfQ%3D&shp=81f88b70&shcp=-"
    },
    {
      "type": "photo",
      "url": "https://p19-pu-sign-useast8.tiktokcdn-us.com/tos-useast5-i-photomode-tx/68bf185da0384c8686f7f5b43e20c74e~tplv-photomode-image.jpeg?lk3s=81f88b70&x-expires=1736870400&x-signature=OJBG9s94beXG44EuD7P7LCK2dFA%3D&shp=81f88b70&shcp=-"
    }
  ],
  "audio": "http://localhost:9000/tunnel?id=nZisFkg1AaYElrUreeC5Y&exp=1736698901732&sig=AYmIIZUyMro8OPRwQfzl9_8TxwtLICWjX5YNfmRfzgY&sec=0_hs5VHhR2IYnSGkz9qnTwKs0hCr34Gr5wl2kOlGq4g&iv=Fzcv6hIXcIIHHpDiZEdMlQ",
  "audioFilename": "tiktok_dailydoseofpositivity444_7377016451950972203_audio_original.mp3"
}

When I follow the audio url, I get an mp3 file downloaded with a size of 0 bytes. However, if I make a change here

args.push("-b:a", `${streamInfo.audioBitrate || '8'}k`)

(just as a hard-coded) test, I get a valid mp3 file. Obviously, though, I'm not sure where to pull the bitrate from if audioBitrate doesn't exist

@ngregrichardson
Copy link

Actually, this might be a simple fix. Does audioBitrate just need to be passed in here?

https://github.com/imputnet/cobalt/blob/main/api/src/processing/match-action.js#L97-L104

If so, I'm happy to make a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants