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

Download file mp3 with link .m3u8 #18813

Closed
6 of 9 tasks
thinh9e opened this issue Jan 11, 2019 · 6 comments
Closed
6 of 9 tasks

Download file mp3 with link .m3u8 #18813

thinh9e opened this issue Jan 11, 2019 · 6 comments

Comments

@thinh9e
Copy link

thinh9e commented Jan 11, 2019

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like this: [x])
  • Use the Preview tab to see what your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2019.01.10. If it's not, read this FAQ entry and update. Issues with outdated version will be rejected.

  • I've verified and I assure that I'm running youtube-dl 2019.01.10

Before submitting an issue make sure you have:

  • At least skimmed through the README, most notably the FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones
  • Checked that provided video/audio/playlist URLs (if any) are alive and playable in a browser

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add the -v flag to your command line you run youtube-dl with (youtube-dl -v https://5bd725165e3d4.s treamlock.net/test/_definst_/mp3:TOEIC/Audio/19990.mp3/chunklist_w303007929.m3u8), copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'https://5bd725165e3d4.streamlock.net/test/_definst_/mp3:TOEIC/Audio/19990.mp3/chunklist_w303007929.m3u8']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2019.01.02
[debug] Python version 2.7.15rc1 (CPython) - Linux-4.4.0-17763-Microsoft-x86_64-with-Ubuntu-18.04-bionic
[debug] exe versions: ffmpeg 3.4.4-0ubuntu0.18.04.1, ffprobe 3.4.4-0ubuntu0.18.04.1
[debug] Proxy map: {}
[generic] chunklist_w303007929: Requesting header
[generic] chunklist_w303007929: Downloading m3u8 information
[debug] Default format spec: bestvideo+bestaudio/best
[debug] Invoking downloader on u'https://5bd725165e3d4.streamlock.net/test/_definst_/mp3:TOEIC/Audio/19990.mp3/chunklist_w303007929.m3u8'
[download] Destination: chunklist_w303007929-chunklist_w303007929.mp4
[debug] ffmpeg command line: ffmpeg -y -loglevel verbose -headers 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0
' -i 'https://5bd725165e3d4.streamlock.net/test/_definst_/mp3:TOEIC/Audio/19990.mp3/chunklist_w303007929.m3u8' -c copy -f mp4 '-bsf:a' aac_adtstoasc 'file:chunklist_w303007929-chunklist_w303007929.mp4.part'
ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
[hls,applehttp @ 0x7fffc9281740] HLS request for url 'https://5bd725165e3d4.streamlock.net/test/_definst_/mp3:TOEIC/Audio/19990.mp3/media_w303007929_0.mp3', offset 0, playlist 0
[hls,applehttp @ 0x7fffc9281740] Opening 'https://dethi.moon.vn/videojs/authenticate.aspx?wowzasessionid=303007929' for reading
[hls,applehttp @ 0x7fffc9281740] Opening 'crypto+https://5bd725165e3d4.streamlock.net/test/_definst_/mp3:TOEIC/Audio/19990.mp3/media_w303007929_0.mp3' for reading
[mp3 @ 0x7fffc95d7680] Skipping 0 bytes of junk at 0.
Input #0, hls,applehttp, from 'https://5bd725165e3d4.streamlock.net/test/_definst_/mp3:TOEIC/Audio/19990.mp3/chunklist_w303007929.m3u8':
  Duration: 00:03:09.23, start: 0.000000, bitrate: 0 kb/s
  Program 0
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Audio: mp3, 22050 Hz, mono, s16p, 24 kb/s
    Metadata:
      variant_bitrate : 0
[AVBSFContext @ 0x7fffc972e100] Codec 'mp3' (86017) is not supported by the bitstream filter 'aac_adtstoasc'. Supported codecs are: aac (86018)
Error initializing bitstream filter: aac_adtstoasc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
    Last message repeated 1 times


ERROR: ffmpeg exited with code 1
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/bin/youtube-dl/__main__.py", line 19, in <module>
    youtube_dl.main()
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 472, in main
    _real_main(argv)
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 462, in _real_main
    retcode = ydl.download(all_urls)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2002, in download
    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 804, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 858, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1636, in process_video_result
    self.process_info(new_info)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1909, in process_info
    success = dl(filename, info_dict)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1848, in dl
    return fd.download(name, info)
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/common.py", line 364, in download
    return self.real_download(filename, info_dict)
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/external.py", line 64, in real_download
    self.get_basename(), retval))
  File "/usr/local/bin/youtube-dl/youtube_dl/downloader/common.py", line 165, in report_error
    self.ydl.report_error(*args, **kargs)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 621, in report_error
    self.trouble(error_message, tb)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 583, in trouble
    tb_data = traceback.format_list(traceback.extract_stack())
<end of log>

Description of your issue, suggested solution and other information

I want to download stream file mp3 by link .m3u8 but I have an error:
[AVBSFContext @ 0x7fffdbaa00e0] Codec 'mp3' (86017) is not supported by the bitstream filter 'aac_adtstoasc'. Supported codecs are: aac (86018) Error initializing bitstream filter: aac_adtstoasc
How can I fix it?
Thanks!

@dstftw dstftw reopened this Jan 11, 2019
@remitamine
Copy link
Collaborator

the commit should fix the parsing of FFmpeg version, in this case, 3.4.4-0ubuntu0.18.04.1 will be parsed as 3.4.4 and the result of the condition:

                if (ffpp.basename == 'ffmpeg' and is_outdated_version(ffpp._versions['ffmpeg'], '3.2', False)) and (not info_dict.get('acodec') or info_dict['acodec'].split('.')[0] in ('aac', 'mp4a')):
                    args += ['-bsf:a', 'aac_adtstoasc']

will be false and '-bsf:a' aac_adtstoasc option will not be part of the ffmpeg command.

@dstftw
Copy link
Collaborator

dstftw commented Jan 11, 2019

Version is not necessarily in X.Y.Z format, e.g. Windows builds ffmpeg N-85653-gb4330a0.

@thinh9e
Copy link
Author

thinh9e commented Jan 11, 2019

So, I use ffmpeg command: ffmpeg -i <URL>.m3u8 -c:v copy -bsf:v aac_adtstoasc <FILE>.mp3 and it's working. But I don't know youtube-dl has a command like it?

@Vangelis66
Copy link

Vangelis66 commented Jan 12, 2019

So, I use ffmpeg command:
ffmpeg -i <URL>.m3u8 -c:v copy -bsf:v aac_adtstoasc <FILE>.mp3
and it's working.

@npthinh1996
Your stream does not have a video component, so
-c:v copy is wrong.
Then, there's no video bitstream filter (-bsf:v) called aac_adtstoasc (in fact, it's an audio bitstream filter), so again -bsf:v aac_adtstoasc is wrong.
Your ffmpeg copy is probably disregarding those invalid arguments and recoding the mp3 stream to default ffmpeg parametres (e.g. @ 128kbps VBR); you do not want that; to save the original stream

Stream #0:0: Audio: mp3, 22050 Hz, mono, s16p, 24 kb/s

you should use:
ffmpeg -i <URL>.m3u8 -c:a copy <FILE>.mp3

MP3 files streamed in AppleHLSe (i.e. AES-128 encrypted) format are quite uncommon; most common audio codec used in HLS is aac, such a HLS stream is first dumped by yt-dl (by ffmpeg or native python downloader) in the default MPEG-TS container, then yt-dl calls ffmpeg (with -bsf:a aac_adtstoasc) to remux to the MPEG4 container and yield an end .m4a audio file...

How I could have dumped your stream?

youtube-dl --console-title --hls-prefer-native --hls-use-mpegts -c --no-part --fixup never "https://5bd725165e3d4.streamlock.net/test/_definst_/mp3:TOEIC/Audio/19990.mp3/master.m3u8" -o foo.mp3

[generic] master: Requesting header
[generic] master: Downloading m3u8 information
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 19
[download] Destination: foo.mp3
[download] 100% of 553.30KiB in 00:42

--hls-prefer-native leaves ffmpeg out from the downloading part, --hls-use-mpegts makes sure the dumped stream is saved in the MPEG-TS container (MP3 compatible) and --fixup never makes sure the downloaded file is not touched at all by ffmpeg.

MediaInfo log of file foo.mp3:

General
Complete name                            : foo.mp3
Format                                   : MPEG Audio
File size                                : 553 KiB
Duration                                 : 3 min 8 s
Overall bit rate mode                    : Constant
Overall bit rate                         : 24.0 kb/s

Audio
Format                                   : MPEG Audio
Format version                           : Version 2
Format profile                           : Layer 3
Duration                                 : 3 min 8 s
Bit rate mode                            : Constant
Bit rate                                 : 24.0 kb/s
Channel(s)                               : 1 channel
Sampling rate                            : 22.05 kHz
Frame rate                               : 38.281 FPS (576 SPF)
Compression mode                         : Lossy
Stream size                              : 553 KiB (100%)

@thinh9e
Copy link
Author

thinh9e commented Jan 12, 2019

youtube-dl --console-title --hls-prefer-native --hls-use-mpegts -c --no-part --fixup never "https://5bd725165e3d4.streamlock.net/test/_definst_/mp3:TOEIC/Audio/19990.mp3/master.m3u8" -o foo.mp3 it can download file mp3 but the sound is so bad.
So, I think I can use ffmpeg command in my case:
ffmpeg -i <URL>.m3u8 -c:a copy <FILE>.mp3
Thanks for your support! :D

@Vangelis66
Copy link

@npthinh1996 wrote:

it can download file mp3 but the sound is so bad.

... blame those people providing the stream; the download command fetches the stream in its original quality, i.e. without re-(trans-)coding 😉 BTW, you never posted any info on the page that .m3u8 playlist was harvested from; perhaps better qualities are available there, but I suspect this matter does not fit in this yt-dl tracker...

So, I think I can use ffmpeg command in my case:
ffmpeg -i <URL>.m3u8 -c:a copy <FILE>.mp3

... and you'll get an identical file to using yt-dl...

Thanks for your support!

You are welcome; just a fellow yt-dl user, sadly with 0 coding skills but with some expertise on streaming methodologies, media files/codecs/containers acquired over the years... 😄

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

No branches or pull requests

4 participants