postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
870 stars 94 forks source link

NSOSStatusErrorDomain with only some mp4 files #2450

Open acheong08 opened 1 month ago

acheong08 commented 1 month ago

Describe the bug

out.mp4:  ISO Media, MP4 v2 [ISO 14496-14]
out1.mp4: ISO Media, MP4 Base Media v1 [ISO 14496-12:2003]
out2.mp4: ISO Media, MP4 Base Media v1 [ISO 14496-12:2003]
out3.mp4: ISO Media, MP4 v2 [ISO 14496-14]

This works: out.mp4: http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4

These don't: out[1-3].mp4 wf-recorder -f out1.mp4

All of them play just fine on my laptop so I have no idea what's causing the issue:

Error log

Traceback (most recent call last):
  File "/home/acheong/Projects/airplay/main.py", line 100, in <module>
    asyncio.run(main())
  File "/usr/lib64/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/acheong/Projects/airplay/main.py", line 67, in main
    await airplay.stream.play_url(os.path.join(pwd, path))
  File "/home/acheong/.local/lib/python3.12/site-packages/pyatv/core/facade.py", line 357, in play_url
    await self.relay("play_url")(url, **kwargs)
  File "/home/acheong/.local/lib/python3.12/site-packages/pyatv/protocols/airplay/__init__.py", line 136, in play_url
    return await self._play_task
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/acheong/.local/lib/python3.12/site-packages/pyatv/protocols/airplay/player.py", line 68, in play_url
    await self._wait_for_media_to_end()
  File "/home/acheong/.local/lib/python3.12/site-packages/pyatv/protocols/airplay/player.py", line 101, in _wait_for_media_to_end
    raise exceptions.PlaybackError(
pyatv.exceptions.PlaybackError: got error -6707 (NSOSStatusErrorDomain) when playing video
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f37de748410>

How to reproduce the bug?

  1. wf-recorder -f out1.mp4
  2. Optional: ffmpeg -i out1.mp4 -brand mp42 out3.mp4 (to get it into the same format)

What is expected behavior?

Stream properly

Operating System

Linux

Python

3.11

pyatv

0.14.5

Device

MacOS Sonoma

Additional context

Pass the video through Handbrake and it works properly

postlund commented 1 month ago

The Apple TV is very picky when it comes to correct format, so I guess something is wrong. It gives more or less no indication of what is wrong unfortunately (other than that error message you get), so it's hard to tell. Can you boost the files somewhere so that I can try them out?