AlexAplin / nndownload

Download and process links from Niconico (nicovideo.jp)
MIT License
213 stars 28 forks source link

"FormatNotAvailableException" and can't download #161

Closed xyzxye closed 2 months ago

xyzxye commented 2 months ago

【ffmpeg -version】ffmpeg can operate normally ffmpeg version 2023-07-16-git-c541ecf0dc-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers built with gcc 12.2.0 (Rev10, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband libavutil 58. 14.100 / 58. 14.100 libavcodec 60. 22.100 / 60. 22.100 libavformat 60. 10.100 / 60. 10.100 libavdevice 60. 2.101 / 60. 2.101 libavfilter 9. 8.102 / 9. 8.102 libswscale 7. 3.100 / 7. 3.100 libswresample 4. 11.100 / 4. 11.100 libpostproc 57. 2.100 / 57. 2.100

【code】 import nndownload url = "https://www.nicovideo.jp/watch/sm43660169" output_path = "{id}.{ext}" nndownload.execute("-g", "-vq", "video-h264-480p", "-o", output_path, url)

【console】 Proceeding with no login. Some content may not be available for download or may only be available in a lower quality. For access to all content, please provide a login with --username/--password, --session-cookie, or --netrc. Retrieving video manifest... Retrieved video manifest. Collecting video media URIs... Collected video media URIs. Downloading sm43660169 to "sm43660169.mp4"... sm43660169 0% 0/350 [ 0:00:05 < -:--:-- , ? seg/s ] FormatNotAvailableException: ffmpeg failed to download the video or audio stream with the following error: ""

xyzxye commented 2 months ago

Login and Cookies can't work either and pip reinstalling did not solve the problem, I don't know what problem happened......

xyzxye commented 2 months ago

With an old version of nndownload ( version ="1.12.2") I can download "sm43299122" with "archive_h264_480p" normally But unable to download "sm43479986", console output: nndownload.nndownload.FormatNotAvailableException: Video media not available for download

With the latest version of nndownload I unable to download both"sm43299122" and "sm43479986" with "video-h264-480p", console output: FormatNotAvailableException: ffmpeg failed to download the video or audio stream with the following error: ""

AlexAplin commented 2 months ago

I'm able to download all of the videos you specified (sm43660169, sm43299122, sm43479986) using both no specified quality and video-h264-480p.

Are you using only the module? Have you tried this with the CLI? I used the same script you provided and was successful using v1.16.3:

Proceeding with no login. Some content may not be available for download or may only be available in a lower quality. For access to all content, please provide a login with --username/--password, --session-cookie, or --netrc.
Retrieving video manifest...
Retrieved video manifest.
Collecting video media URIs...
Collected video media URIs.
Downloading sm43660169 to "sm43660169.mp4"...
Resuming partial downloads is not supported for videos using DMS delivery. Any partial video data will be overwritten.
sm43660169 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸ 349/350  [ 0:01:18 < 0:00:01 , 3 seg/s 

Are you on the most current version (nndownload -v)? Windows, Linux?

xyzxye commented 2 months ago

yes, my version is 1.16.3 in Windows. I use this CLI and still not working: nndownload -g -o D:/KagamineYE/desktop/lab/{id}.{ext} https://www.nicovideo.jp/watch/sm43440701 console: `(base) C:\Users\KagamineYE>nndownload -v 1.16.3

(base) C:\Users\KagamineYE>nndownload -g -o D:/KagamineYE/desktop/lab/{id}.{ext} https://www.nicovideo.jp/watch/sm43440701 Proceeding with no login. Some content may not be available for download or may only be available in a lower quality. For access to all content, please provide a login with --username/--password, --session-cookie, or --netrc. Retrieving video manifest... Retrieved video manifest. Collecting video media URIs... Collected video media URIs. Downloading sm43440701 to "D:/KagamineYE/desktop/lab/sm43440701.mp4"... sm43440701 0% ---------------------------------------------------------------- 0/341 [ 0:00:09 < -:--:-- , ? seg/s ] FormatNotAvailableException: ffmpeg failed to download the video or audio stream with the following error: ""`

xyzxye commented 2 months ago

I upgraded ffmpeg to the latest version still failed to download, and I print the prev_line = stdout_line in ffmpeg_dl.py, line 67

the console outputs:

ffmpeg version 2024-04-15-git-5e380bcdb1-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 13.2.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil      59. 15.100 / 59. 15.100
libavcodec     61.  5.103 / 61.  5.103
libavformat    61.  3.100 / 61.  3.100
libavdevice    61.  2.100 / 61.  2.100
libavfilter    10.  2.101 / 10.  2.101
libswscale      8.  2.100 /  8.  2.100
libswresample   5.  2.100 /  5.  2.100
libpostproc    58.  2.100 / 58.  2.100
[hls @ 000001a78ae825c0] Skip ('#EXT-X-VERSION:6')
[hls @ 000001a78ae825c0] Opening 'https://asset.domand.nicovideo.jp/65d890179c07ef8b8b189a15/video/12/video-h264-480p/init01.cmfv?session=46bd6d64ba46eafbb678a32d507cc4c09125b334b0f34d8b000000006620b4b07cbce288521c69ea&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9hc3NldC5kb21hbmQubmljb3ZpZGVvLmpwLzY1ZDg5MDE3OWMwN2VmOGI4YjE4OWExNS92aWRlby8xMi92aWRlby1oMjY0LTQ4MHAvKiIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcxMzQxOTQ0MH19fV19&Signature=pku3ELn-GeVMvbleS~0qWwxkdPnxC~rKuvKStPd6FljbB2D6OORI-NP0iFQG8SzufTghW-VGSsSaN1Xyh9bnqtkrSq-bAeugzxfoU1ufa0yKC1GXv0KAMQ2FW2nNNFq2yIrUil~LGvC9V9DSWmN0W73mV-dawjDH2P9M9K0MKP-lvZcD0J2yvEo1iNi7WyVhh8mO0PCbTy6blWHxprZZetCGL8YGU4nRjrA54~FVBGu40492dn7ENKcaNehCtIwzDXKFKtE00e2TBFcdktX7IbkrEQpWPM3IQ8gm0yLaOB-1K4KNYbxuzRr6dYsmT3~fMINNC9LYBWhi1sfa7TdKQg__&Key-Pair-Id=K11RB80NFXU134' for reading
[tcp @ 000001a78ae97a80] Connection to tcp://asset.domand.nicovideo.jp:443 failed: Error number -138 occurred
[hls @ 000001a78ae825c0] Failed to open an initialization section in playlist 0
[hls @ 000001a78ae825c0] Error when loading first segment 'https://asset.domand.nicovideo.jp/65d890179c07ef8b8b189a15/video/12/video-h264-480p/01.cmfv?session=46bd6d64ba46eafbb678a32d507cc4c09125b334b0f34d8b000000006620b4b07cbce288521c69ea&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9hc3NldC5kb21hbmQubmljb3ZpZGVvLmpwLzY1ZDg5MDE3OWMwN2VmOGI4YjE4OWExNS92aWRlby8xMi92aWRlby1oMjY0LTQ4MHAvKiIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcxMzQxOTQ0MH19fV19&Signature=pku3ELn-GeVMvbleS~0qWwxkdPnxC~rKuvKStPd6FljbB2D6OORI-NP0iFQG8SzufTghW-VGSsSaN1Xyh9bnqtkrSq-bAeugzxfoU1ufa0yKC1GXv0KAMQ2FW2nNNFq2yIrUil~LGvC9V9DSWmN0W73mV-dawjDH2P9M9K0MKP-lvZcD0J2yvEo1iNi7WyVhh8mO0PCbTy6blWHxprZZetCGL8YGU4nRjrA54~FVBGu40492dn7ENKcaNehCtIwzDXKFKtE00e2TBFcdktX7IbkrEQpWPM3IQ8gm0yLaOB-1K4KNYbxuzRr6dYsmT3~fMINNC9LYBWhi1sfa7TdKQg__&Key-Pair-Id=K11RB80NFXU134'
[in#0 @ 000001a78ae821c0] Error opening input: Error number -138 occurred
Error opening input file C:\Users\KAGAMI~1\AppData\Local\Temp\tmpyd5v0wj7\sm43440701_dms_video_uri.m3u8.
Error opening input files: Error number -138 occurred

I guess maybe this "Error number -138" is the reason for the error?

fireattack commented 2 months ago

I cannot reproduce this issue with Windows.

If you can run from source, maybe you can add some debug info for ffmpeg and show us the full log? E.g. add

            print(f'[ffmpeg] {stdout_line}')

At L69 of ffmpeg_dl.py, and then run python -m nndownload {your arguments} inside the cloned repo folder.

xyzxye commented 2 months ago

I just print this when you reply to me XD

fireattack commented 2 months ago

Connection to tcp://asset.domand.nicovideo.jp:443 failed: Error number -138 occurred

It looks like you cannot connect to this domain.

Are you visiting niconico with proxies? Please notice that current download method we have (using ffmpeg) does not support proxy.

xyzxye commented 2 months ago

yes......I used a proxy due to regional reasons, I must use a proxy to access niconico......QAQ

I can use the previous nndownload( version ="1.12.2") with proxy normally. But for some new videos, they cannot be downloaded with that old version now......

fireattack commented 2 months ago

Previously with DMC we can download directly using requests since it's HTTP. It was changed to using external FFMPEG for DMS because it now is HLS.

I'm implementing a native HLS downloader RN so it should be available soon™.

xyzxye commented 2 months ago

thank you! I would appreciate! Orz

xyzxye commented 2 months ago

I find I can use the "TUN mode" in my proxy to solve this problem. and now I can download normally ! THANK YOU !!!

Using Code:

    nndownload.execute(
        "--session-cookie", cookie,
        "-vq", "video-h264-480p",
        "-r", "12",
        "-o", prepath+"{title}■{uploader}■{id}.{ext}",url)

Successfully Downloaded:

Using provided session cookie.
Retrieving video manifest...
Retrieved video manifest.
Collecting video media URIs...
Collected video media URIs.
Downloading sm43440701 to "D:\KagamineYE\desktop\v2x\process\\鏡音新曲ランキング02 #829■とらっきー■sm43440701.mp4"...
Multithreading is only supported for DMC delivery. Video will be downloaded using one thread.
sm43440701 100% ---------------------- 341/341  [ 0:00:58 < 0:00:00 , 5 seg/s ]

another limitation is that without multithreading, the download speed tends to be slower. But it's not a big deal. Thank you very much for your help !!!

fireattack commented 2 months ago

Yes if you use Clash or similar you can use TUN which is transparent for programs. Or things like proxifier.

Multi-threading will be added back too together with native HLS downloader.

AlexAplin commented 2 months ago

Yeah we'll get to proxies in #150. I am concerned that ffmpeg won't deliver a useful error back but I guess it's moot anyway when we get the native HLS in.

AlexAplin commented 2 months ago

Closing to follow verification in #150