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

No audio while streaming YouTube videos #4253

Closed
1 task
low-batt opened this issue Mar 7, 2023 · 12 comments
Closed
1 task

No audio while streaming YouTube videos #4253

low-batt opened this issue Mar 7, 2023 · 12 comments

Comments

@low-batt
Copy link
Contributor

low-batt commented Mar 7, 2023

System and IINA version:

  • macOS 13.2.1
  • IINA 1.3.1

Expected behavior:
IINA can play YouTube videos.

Actual behavior:
After upgrading to yt-dlp v2023.03.04 (latest release at this time) the video The World in HDR in 4K (ULTRA HD) plays without any audio. Attempting to play the video Wearing This While Working Will Get You Killed fails, displaying this error:
Screenshot 2023-03-07 at 1 48 50 PM

IINA was working correctly using the previous release of yt-dlp, v2023.02.17.

This is what the IINA log shows when attempting to play the second video where neither video or audio streams are found.

IINA log:
13:48:33.833 [iina][d] Menu - Open URL
13:48:36.539 [player0][d] Open URL: https://www.youtube.com/shorts/fCF2nnmPyJI
13:48:36.539 [player0][d] Opening https://www.youtube.com/shorts/fCF2nnmPyJI in main window
13:48:36.605 [iina][d] Created OpenGL pixel format with [__C._CGLPixelFormatAttribute(rawValue: 5), __C._CGLPixelFormatAttribute(rawValue: 96), __C._CGLPixelFormatAttribute(rawValue: 99), __C._CGLPixelFormatAttribute(rawValue: 12800), __C._CGLPixelFormatAttribute(rawValue: 73), __C._CGLPixelFormatAttribute(rawValue: 0)]
13:48:36.611 [iina][d] Falling back to nominal display refresh rate: 120.0 from 0.0
13:48:36.612 [iina][d] window!.screen: Built-in Retina Display visible frame (0.0, 57.0, 1728.0, 1022.0)
13:48:36.612 [iina][d] NSScreen.main: Built-in Retina Display visible frame (0.0, 57.0, 1728.0, 1022.0)
13:48:36.612 [iina][d] NSScreen.screens[0]: Built-in Retina Display visible frame (0.0, 57.0, 1728.0, 1022.0)
13:48:36.614 [player0][d] File started
13:48:36.615 [player0][d] Started auto load
13:48:36.615 [fmatcher][d] **Start matching
13:48:36.621 [player0][d] Track list changed
13:48:41.543 [iina][w] mpv log: [demux] error: EDL specifies no segments.'
13:48:41.544 [iina][w] mpv log: [demux] error: EDL parsing failed.
13:48:41.544 [iina][w] mpv log: [demux] error: Error in EDL.
13:48:41.544 [iina][w] mpv log: [demux] warn: EDL: source file 'edl://!mp4_dash,init=%932%https://rr2---sn-jvhj5nu-cvne7.googlevideo.com/videoplayback?expire=1678236521&ei=CYcHZOH7GY248wSF8a7wBQ&ip=73.16.106.175&id=o-AEQuszkNGik_Lw9QVpJY1WzbeBRa4XukyWExhUt3OOfT&itag=247&source=youtube&requiressl=yes&mh=co&mm=31%2C29&mn=sn-jvhj5nu-cvne7%2Csn-ab5l6nrl&ms=au%2Crdu&mv=m&mvi=2&pl=23&ctier=SH&initcwndbps=1568750&spc=H3gIhsGbIIoaebr7quSq5Yio1beKJ04&vprv=1&svpuc=1&mime=video%2Fwebm&gir=yes&clen=4329592&dur=42.533&lmt=1677367590393486&mt=1678214507&fvip=4&keepalive=yes&fexp=24007246&c=ANDROID&txp=543E434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cctier%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIgK88MbW3ywZqap1yutW2kJ1EMh5Zv84ztwNVwNzpvmWkCIQD0baVI-AuB4oAKpJhBDyo0agEmQS0d1WHl8kIUVN4wOw%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgNX3HUHlxyUnB_4iv-Rdub0Xyt_Hf4SEl1SXHnPcSdsYCIQDaFVI9N8kfsJ6RFzeg7uZpPDsFyIqBySCnBJ3HEsAyJw%3D%3D&range=0-4329592;' has unknown duration.
13:48:41.544 [iina][w] mpv log: [demux] error: EDL specifies no segments.'
13:48:41.544 [iina][w] mpv log: [demux] error: EDL parsing failed.
13:48:41.544 [iina][w] mpv log: [demux] error: Error in EDL.
13:48:41.544 [iina][w] mpv log: [demux] warn: EDL: source file 'edl://!mp4_dash,init=%928%https://rr2---sn-jvhj5nu-cvne7.googlevideo.com/videoplayback?expire=1678236521&ei=CYcHZOH7GY248wSF8a7wBQ&ip=73.16.106.175&id=o-AEQuszkNGik_Lw9QVpJY1WzbeBRa4XukyWExhUt3OOfT&itag=251&source=youtube&requiressl=yes&mh=co&mm=31%2C29&mn=sn-jvhj5nu-cvne7%2Csn-ab5l6nrl&ms=au%2Crdu&mv=m&mvi=2&pl=23&ctier=SH&initcwndbps=1568750&spc=H3gIhsGbIIoaebr7quSq5Yio1beKJ04&vprv=1&svpuc=1&mime=audio%2Fwebm&gir=yes&clen=706724&dur=42.561&lmt=1677366382252896&mt=1678214507&fvip=4&keepalive=yes&fexp=24007246&c=ANDROID&txp=5432434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cctier%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhAJg04LHOG0Ju_uFCCG3olESHM_-v3Yhz0RF9n1EJ0hycAiEA9OVCS1WO5SMip8pbOVH1lX4AhAYPg9I_B4OxNavlGvM%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRQIgNX3HUHlxyUnB_4iv-Rdub0Xyt_Hf4SEl1SXHnPcSdsYCIQDaFVI9N8kfsJ6RFzeg7uZpPDsFyIqBySCnBJ3HEsAyJw%3D%3D&range=0-706724;' has unknown duration.
13:48:41.544 [iina][w] mpv log: [cplayer] fatal: No video or audio streams selected.

Steps to reproduce:
Play the above referenced YouTube videos.

  • MPV does not have this problem.

This is a problem for mpv as well.

How often does this happen?
Every time.

@low-batt
Copy link
Contributor Author

low-batt commented Mar 7, 2023

Apparently changes in the latest version of yt-dlp require the mpv script ytdl_hook.lua be updated. See the mpv issue mpv-player/mpv#11392.

Busy today. Will take a closer look at this soon.

@low-batt
Copy link
Contributor Author

low-batt commented Mar 8, 2023

Workaround

The mpv project has updated the Lua script ytdl_hook.lua to be compatible with the latest version of yt-dlp (2023.03.04). This script is embedded into mpv. To workaround the failure we must obtain the updated version of this script and instruct IINA/mpv to use the updated version instead of the embedded version. There are multiple ways of going about this. The following is how I did it…

From the mpv manual section Script location:

Scripts can be passed to the --script option, and are automatically loaded from the scripts subdirectory of the mpv configuration directory (usually ~/.config/mpv/scripts/).

I decided to use the scripts directory. To create that directory and download the fixed version of the script from the mpv master branch I copied these commands into Terminal:

mkdir -p ~/.config/mpv/scripts/
(cd ~/.config/mpv/scripts/ && curl --location --remote-header-name --remote-name https://raw.githubusercontent.com/mpv-player/mpv/master/player/lua/ytdl_hook.lua)

This is what it looks like running the commands:

low-batt@gag ~$ mkdir -p ~/.config/mpv/scripts/
low-batt@gag ~$ (cd ~/.config/mpv/scripts/ && curl --location --remote-header-name --remote-name https://raw.githubusercontent.com/mpv-player/mpv/master/player/lua/ytdl_hook.lua)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 34829  100 34829    0     0  11981      0  0:00:02  0:00:02 --:--:-- 11997
low-batt@gag ~$ 

After running those commands I have a copy of the updated script in the default scripts directory used by mpv:

low-batt@gag ~$ ls -l ~/.config/mpv/scripts/
total 72
-rw-r--r--  1 low-batt  staff  34829 Mar  8 10:35 ytdl_hook.lua
low-batt@gag ~$ 

The second part of the workaround is to configure IINA/mpv to use the scripts directory and to not use the embedded script. To do that follow these instructions:

  • Start IINA
  • Click on Settings… under the IINA menu
  • The settings panel appears
  • On the left side of the panel click on Advanced
  • Slide the Enable advanced settings toggle button to be on (blue)
  • In the Additional mpv options section click on +
  • A new entry appears in the table
  • Double click on name and replace it with ytdl
  • Double click on value and replace it with no
  • Below Additional mpv options look for Use config directory
  • Enable this setting
  • Leave the config directory set to the default, ~/.config/mpv/, do not change it to point to the scripts directory
  • Confirm the settings panel looks like the screenshot below
  • Restart IINA to activate the new settings
    issue-4253-advanced

Remember to remove this workaround once a version of IINA is released that contains a fix for this issue.

With this workaround in place I am able to successfully stream the two above mentioned YouTube videos using IINA 1.3.1 with yt-dlp 2023.03.04.

If the workaround is correctly applied the mpv.log will contain log messages indicating ytdl_hook.lua is being loaded from the new scripts directory:

[   0.004][d][global] config path: '' -> '/Users/low-batt/.config/mpv'
…
[   0.005][d][global] config path: 'scripts' -> '/Users/low-batt/.config/mpv/scripts'
…
[   0.005][d][ytdl_hook] Loading lua script /Users/low-batt/.config/mpv/scripts/ytdl_hook.lua...

@along02
Copy link

along02 commented Mar 8, 2023

Thanks for the workaround. The workaround works, but it takes like a minute for the video to show up for me.

@low-batt
Copy link
Contributor Author

low-batt commented Mar 9, 2023

I have the IINA setting Resume last playback position enabled. There was a noticeable delay when I opened one of the above videos as IINA needed to seek to the previous position. When playing from the start of the video playback started pretty quickly, but there still was a startup delay while contacting YouTube and accessing the stream. Certainly not a minute.

@along02
Copy link

along02 commented Mar 9, 2023

Yeah, I'm not sure what's wrong. Here's the screen recording of the example video. It took almost 3 minutes for that specific video.

record.mp4

@low-batt
Copy link
Contributor Author

@along02 I watched the video. Bummer. I tried playing The World in HDR in 4K (ULTRA HD) myself again to make sure YouTube had not just changed something. It started playing for me after maybe 10 seconds, not 3 minutes.

If you run yt-dlp directly what kind of download speed do you see? I just tried it and I'm seeing about 5MiB/s:

low-batt@gag issue-4253$ yt-dlp https://www.youtube.com/watch?v=tO01J-M3g0U
[youtube] Extracting URL: https://www.youtube.com/watch?v=tO01J-M3g0U
[youtube] tO01J-M3g0U: Downloading webpage
[youtube] tO01J-M3g0U: Downloading android player API JSON
[info] tO01J-M3g0U: Downloading 1 format(s): 337+251
[dashsegments] Total fragments: 53
[download] Destination: The World in HDR in 4K (ULTRA HD) [tO01J-M3g0U].f337.webm
[download]   9.6% of ~ 530.00MiB at    5.79MiB/s ETA 00:43 (frag 5/53)^C
ERROR: Interrupted by user
low-batt@gag issue-4253$ 

If the download speed is really slow then investigate if your ISP is known to throttle downloads. If the test shows a reasonable speed then we should look into the mpv log file and see if that provides any clue as to what is happening.

Logging is disabled by default. To enabled logging follow these instructions:

  • Start IINA
  • Click on Settings… under the IINA menu
  • The settings panel appears
  • On the left side of the panel click on Advanced
  • Slide the Enable advanced settings toggle button to be on (blue)
  • Click on the checkbox Enable logging
  • Confirm the settings panel looks like the screenshot below
  • Restart IINA to activate logging

Once IINA has restarted, stream the video and reproduce the problem. Then:

  • Click on Settings… under the IINA menu
  • The settings panel appears
  • On the left side of the panel click on Advanced
  • Click on Open log directory
  • A new Finder window appears containing the logs for this session
  • Quit IINA to complete the log files

The Finder window contains two files, iina.log and mpv.log. To attach the log files to this issue, drag-n-drop them from the Finder window to the Leave a comment section below. Include both the iina.log and the mpv.log

The log files can also be accessed using Terminal as shown here:

low-batt@gag com.colliderli.iina$ pwd
/Users/low-batt/Library/Logs/com.colliderli.iina
low-batt@gag com.colliderli.iina$ ls
2022-10-04-17-57-15_jVrbWy
low-batt@gag com.colliderli.iina$ cd 2022-10-04-17-57-15_jVrbWy
low-batt@gag 2022-10-04-17-57-15_jVrbWy$ ls
iina.log	mpv.log
low-batt@gag 2022-10-04-17-57-15_jVrbWy$ 

With logging enabled IINA creates a new log directory each time it is started. If accessing the logs using Terminal be sure to obtain them from the latest log directory.

DO NOT FORGET to disable logging once you have obtained log files for the problem being investigated. IINA does not restrict the size of log files or delete old logs. If you leave logging enabled the logs will continue to accumulate.

@along02
Copy link

along02 commented Mar 10, 2023

Thanks for the tips! It turned out that yt-dlp was also bugging out (not downloading) when I tried to just normally use it on Terminal. I just restarted my computer and it seems to be doing fine now (downloading at 3 Mib/s) on Terminal and on IINA.

@low-batt
Copy link
Contributor Author

Really glad it is now working properly for you. Really disturbing that rebooting fixed the issue. I noticed you have a M1 Mac, so the hardware should not have any trouble handling that 4K video. How much memory? Which version of macOS?

It used to be that if something was leaking memory and had grown too large it could slow down the machine. Rebooting would fix that problem. But with the high speed of solid state disks macOS is really good at swapping memory. Using up all of the physical memory does not slow down the Mac like it used to.

It used to be that if something was looping and consuming all of the CPU it could slow down the machine. Rebooting would sometimes fix that problem. But with the many CPU cores in the M1 a looping application can take up one of the cores and have nearly no effect on performance.

Maybe something got corrupted in the WiFi system?

I would bring up Console and check crash reports to see if macOS background daemons are crashing and restarting. I'd also keep an eye on the system using Activity Monitor.

@along02
Copy link

along02 commented Mar 10, 2023

I have 16 GB of memory and am on Ventura 13.2.1. Also, it wasn't just specifically the 4k video. It was any YouTube video that I put into IINA (and probably yt-dlp as well) took a really long time to load. I also noticed that updating python pip packages the past few days took noticeably longer as well so maybe it was something WiFi related. I checked the Console and didn't find anything weird. I'll keep on eye if it happens again.

@low-batt
Copy link
Contributor Author

Ventura 13.2.1 definitely still contains regressions related to graphics that were not present in Monterey. I'm hoping for an update from Apple that fixes them. Without adding new ones.

Seems other areas of macOS Venturna may need some fixing as well…

@low-batt
Copy link
Contributor Author

I have confirmed the mpv library in the updated dependencies has been correctly patched with the new Lua script and can stream the videos listed in the issue without error.

This issue will be fixed in the next release of IINA. The workaround will no longer be needed.

@low-batt
Copy link
Contributor Author

This issue has been fixed in IINA 1.3.2. If you applied the workaround involving the ytdl_hook.lua script that workaround can now be removed.

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

No branches or pull requests

2 participants