NewPipePlaylistExtractor icon indicating copy to clipboard operation
NewPipePlaylistExtractor copied to clipboard

Error when export certain videos to MP3

Open Userofthenick opened this issue 1 year ago • 8 comments

The error that appears is this: Decoding failed. ffmpeg returned error code: 183

Output from ffmpeg/avlib:

ffmpeg version 6.1.2 Copyright (c) 2000-2024 the FFmpeg developers built with Android (12027248, +pgo, +bolt, +lto, +mlgo, based on r522817) clang version 18.0.1 (https://android.googlesource.com/toolchain/llvm-project d8003a456d14a3deb8054cdaa529ffbf02d9b262) configuration: --arch=aarch64 --as=aarch64-linux-android-clang --cc=aarch64-linux-android-clang --cxx=aarch64-linux-android-clang++ --nm=llvm-nm --pkg-config=/home/builder/.termux-build/_cache/android-r27-api-24-v1/bin/pkg-config --strip=llvm-strip --cross-prefix=aarch64-linux-android- --disable-indevs --disable-outdevs --enable-indev=lavfi --disable-static --disable-symver --enable-cross-compile --enable-gnutls --enable-gpl --enable-version3 --enable-jni --enable-lcms2 --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libharfbuzz --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenmpt --enable-libopus --enable-librav1e --enable-libsoxr --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-mediacodec --enable-opencl --enable-shared --prefix=/data/data/com.termux/files/usr --target-os=android --extra-libs=-landroid-glob --disable-vulkan --enable-neon --disable-libfdk-aac libavutil 58. 29.100 / 58. 29.100 libavcodec 60. 31.102 / 60. 31.102 libavformat 60. 16.100 / 60. 16.100 libavdevice 60. 3.100 / 60. 3.100 libavfilter 9. 12.100 / 9. 12.100 libswscale 7. 5.100 / 7. 5.100 libswresample 4. 12.100 / 4. 12.100 libpostproc 57. 3.100 / 57. 3.100 [mov,mp4,m4a,3gp,3g2,mj2 @ 0xb4000071428ca280] moov atom not found [in#0 @ 0xb4000071428c2a00] Error opening input: Invalid data found when processing input Error opening input file /data/data/com.termux/files/home/./Playlists/a/Pokémon Black and White - Relic Castle (Remix).webm. Error opening input files: Invalid data found when processing input

If Error is: get_throttling_function_name: could not find match for multiple Read the Error chapter in the README

Userofthenick avatar Sep 14 '24 22:09 Userofthenick

Hi @Userofthenick

  • Does this only happen when exporting to MP3, the other codecs work? (does MP4 work?)
  • From what sources (YouTube, Soundcloud etc.) are the videos (all the same or does it not matter)?

Cheers

Quasolaris avatar Sep 15 '24 13:09 Quasolaris

Hello, thank you for your fast response, export only works with MP4, all others show the same error as MP3

I have tried exporting with soundcloud or bandcamp videos but it shows me a different error, it says: (Name of the video or creator) is unavaible.

ghost avatar Sep 15 '24 13:09 ghost

I am not able to reproduce the error.

  • From the error message I assume this is on Android?
  • Did you try a pkg update && pkg upgrade, maybe ffmpeg needs an update on your device.
  • Could you try to convert one .mp4 to a .mp3 file manually? Just download a playlist as MP4 and then use the following command to convert one audio file:
ffmpeg -i filename.mp4 filename.mp3
  • I read that this could happen when the download was terminated unexpectedly (as the moov atom mostly gets written last in an MP4), could it be that your internet connections has drops or sudden disconnects?

Cheers

Quasolaris avatar Sep 15 '24 15:09 Quasolaris

Oh sorry I forgot to mention it, yes, I'm on Android, I've tried updating packages but the error persists, I tried to convert the file as you told me but while doing so I realized that for some reason the videos I downloaded are in WEBM format instead of MP4. I edited the command you gave me by changing the MP4 to WEBM and it worked, although I usually download many videos, I would prefer to be able to download them in MP3 from the beginning

My Internet connection is good, I have a 5G network, just in case I tried using 4G and mobile data but I had the same result. In addition, this error is only happening to me with some specific videos, of about 50 that I download 10 have this error, the rest is downloaded without any problems

ghost avatar Sep 15 '24 16:09 ghost

It is strange that the videos are in the WEBM format. The script downloads the audio as MP4, then converts that MP4 to an MP3 (or other codec) and then deletes the no longer needed MP4 file. No WEBM file should be created.

Could you post some URLs where this happens, as I do not have this problem with URLs I test with.

As a HotFix you could add a line in the script to check for this (line 183 in main.py):

THIS IS NOT TESTED

This could work as a workaround, I would first test it with a playlist that only has one song where this happens.

if(codec != "mp4"):
                    
# check if mp4 or webm, act accordingly
                    if ".webm" in audioFile:
                        given_audio = AudioSegment.from_file(audioFile, format="webm")
                    else:
                        given_audio = AudioSegment.from_file(audioFile, format="mp4")

                    base, ext = os.path.splitext(audioFile)
                    newFile = base + "."+ codec
                    given_audio.export(newFile, format=codec)
                
                    # removes .mp4 file after conversion is done
                    os.remove(audioFile)

I do not roll out that it could be something strange YouTube is doing to counter Pytube or other similar libraries.

Quasolaris avatar Sep 15 '24 16:09 Quasolaris

Sure, These are the videos that have been giving me problems lately

https://www.youtube.com/watch?v=QFWnb34yFcY

https://www.youtube.com/watch?v=GYzChWAPPus

I think this is because YouTube was tweaking things recently, since I downloaded those videos more than once a while ago and they didn't give me problems

I tried what you told me and I got another different error, it's this one: [Errno 2] No such file or directory: '/data/data/com.termux/files/home/./Playlists/a/Pokémon Black and White - Relic Castle (Remix).webm'

ghost avatar Sep 15 '24 17:09 ghost

OK, I was able to reproduce the behavior where this URLs generate WEBM files instead of MP4, even when specifically set to download as MP4 (By using Pytube step by step). I was also able to reproduce the first error you got, but not the second. My hotfix seems not to work on my phone somehow. Why this is I do not know, I was able to convert the files without problems when doing it step by step. Why the script does not find the WEBM file on your device I cannot determine at the moment.

As seen here it worked as intended, and the script does the exact same steps:

>>> given_audio = AudioSegment.from_file('Pokemon Mystery Dungeon 2 - Fortune Ravine Remix [Kamex].webm', format="webm")
>>> given_audio.export('testconvertTOmp3.mp3', format='mp3')
<_io.BufferedRandom name='testconvertTOmp3.mp3'>
>>> os.system('ls')
'Pokemon Mystery Dungeon 2 - Fortune Ravine Remix [Kamex].webm'
testconvertTOmp3.mp3

I am sorry to not have a solution for now other than to tell you, that you have to convert them separately. When I have more time I will take a deeper look at it, but for now I do not see how to fix this.

Cheers

Quasolaris avatar Sep 16 '24 19:09 Quasolaris

Don't worry, I appreciate your help, anyway I will continue investigating to see if I find any other hotfix on the Internet.

ghost avatar Sep 16 '24 19:09 ghost

Closing as account of issue owner is no longer active.

Quasolaris avatar Feb 25 '25 17:02 Quasolaris