Open justin-pierce opened 3 years ago
you can try av://avfoundation:0:none
, eg instead of using the name using the index. the :none
is to select no audio device.
you can specify various demuxer properties via demuxer-lavf-o
, some examples:
--demuxer-lavf-o=video_size=1920x1080
--demuxer-lavf-o=pixel_format=uyvy420
--demuxer-lavf-o=framerate=23.976
Removing the video/audio tags seems to help, along with specifying framerate.
V: 00:00:09 / 00:00:10 (97%)
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] ...treating it as fatal error.
Runs for a split second and then closes.
demuxer-force-retry-on-eof=yes
Keeps it going, though choppy and randomly drops later. Will keep playing with options. Thanks!
I've had more luck piping through FFmpeg to MPV then using MPV directly, however latency is slightly worse than Genki Arcade itself
ffmpeg -f avfoundation \
-video_size 1280x720 -framerate 60 -pix_fmt yuyv422 -i "ShadowCast" \
-vcodec libx264 -preset ultrafast -tune zerolatency \
-f mpegts - | mpv -profile=low-latency -untimed -
Thank you @m-sifi and @justin-pierce.
Earlier today I was using Photo Booth on my MacBook Pro M1 2020 as a way of displaying the output of the "FaceTime HD Camera" built-in web camera of the machine to someone, so that they could see how they were sitting while we were shooting a video using a separate camera not connected to said machine. However, after about 4 or 5 minutes of not interacting with the machine, Photo Booth will pause and turn off the FaceTime HD Camera since it's not being used for recording. Presumably to conserve battery power.
So now this evening I decided that maybe we can use mpv instead of Photo Booth, if we want to use the FaceTime HD Camera that same way again in the future, and that's how I came across this GitHub issue and comments (it was among the first results on Google for mpv macos webcam source). Alternatively, we may just find a regular old mirror or other reflective surface and use that instead of using a computer and web camera for that purpose next time :P
Here is the command-line from m-sifi's comment but adjusted for ffmpeg v4.4 and using the FaceTime HD Camera of the MacBook Pro M1 2020 as input. It's only a couple of trivial differences, but I figured it might be useful to someone in the future if they too come across these comments from some search on Google and they just want to copy-paste something quickly in order to get on with whatever they were doing.
ffmpeg -f avfoundation \
-video_size 1280x720 -framerate 30 -pixel_format yuyv422 -i "FaceTime HD Camera" \
-vcodec libx264 -preset ultrafast -tune zerolatency \
-f mpegts - | mpv -profile=low-latency -untimed -
PS: According to ffmpeg demuxer output on my MacBook Pro M1 2020 running macOS Big Sur 11.6, the FaceTime HD Camera of said machine through avfoundation supports the following modes:
1280x720@[1.000000 30.000000]fps
640x480@[1.000000 30.000000]fps
and the following pixel formats:
uyvy422
yuyv422
nv12
0rgb
bgr0
I'm having the same [lavf] error reading packet: Resource temporarily unavailable.
issue as @justin-pierce using the latest brew
build. It does work piping it in from ffmpeg
, but I'd rather open it directly from mpv
to avoid the reencoding.
Has anybody gotten mpv
on the Mac to open a webcam stream directly? I have a feeling I may just be missing a parameter somewhere. Here's my command line on an M1 Max MacBook Pro:
mpv --demuxer-lavf-o=video_size=1920x1080,framerate=30,pixel_format=uyvy422 av://avfoundation:0:none  ✔
[ffmpeg/demuxer] avfoundation: Stream #0: not enough frames to estimate rate; consider increasing probesize
(+) Video --vid=1 (rawvideo 1920x1080)
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] error reading packet: Resource temporarily unavailable.
[lavf] ...treating it as fatal error.
VO: [libmpv] 1920x1080 uyvy422
V: 00:00:00 / 00:00:00 (0%)
Exiting... (End of file)
mpv --version  ✔
mpv 0.34.1 Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects
built on Wed Aug 31 13:00:56 UTC 2022
FFmpeg library versions:
libavutil 57.28.100
libavcodec 59.37.100
libavformat 59.27.100
libswscale 6.7.100
libavfilter 8.44.100
libswresample 4.7.100
FFmpeg version: 5.1.2
I've been trying for several days to see if I can get this to work. I have found this issue also occurs in IINA (obviously) but also even VLC and a few other media applications. It's as if they know how to grab the first available frame, but then something happens and they can't fetch the rest.
Based on "Resource temporarily unavailable" it seems as if libavformat
is hitting an EAGAIN
error reading the packets because it's requesting a non-blocking read from a device which necessarily blocks.
Based on "Resource temporarily unavailable" it seems as if
libavformat
is hitting anEAGAIN
error reading the packets because it's requesting a non-blocking read from a device which necessarily blocks.
That's interesting. I don't know enough about libavformat
but I would imagine ffmpeg
would use the same call path. So it's puzzling that opening the stream with ffmpeg
like it was suggested above does work. For example, this works for me with the MBP FaceTime camera:
ffmpeg -f avfoundation -video_size 1920x1080 -framerate 30 -pixel_format uyvy422 -i "0:none" -f matroska \
- | mpv -profile=low-latency --untimed --fs -
Based on "Resource temporarily unavailable" it seems as if
libavformat
is hitting anEAGAIN
error reading the packets because it's requesting a non-blocking read from a device which necessarily blocks.That's interesting. I don't know enough about
libavformat
but I would imagineffmpeg
would use the same call path. So it's puzzling that opening the stream withffmpeg
like it was suggested above does work. For example, this works for me with the MBP FaceTime camera:ffmpeg -f avfoundation -video_size 1920x1080 -framerate 30 -pixel_format uyvy422 -i "0:none" -f matroska \ - | mpv -profile=low-latency --untimed --fs -
Yeah, I agree it’s a bit odd. But ffmpeg
seems to struggle to capture the stream smoothly as well. I would almost guess it’s just opening and closing the stream repeatedly, based on how the picture and audio stutter when I try it.
Based on "Resource temporarily unavailable" it seems as if
libavformat
is hitting anEAGAIN
error reading the packets because it's requesting a non-blocking read from a device which necessarily blocks.That's interesting. I don't know enough about
libavformat
but I would imagineffmpeg
would use the same call path. So it's puzzling that opening the stream withffmpeg
like it was suggested above does work. For example, this works for me with the MBP FaceTime camera:ffmpeg -f avfoundation -video_size 1920x1080 -framerate 30 -pixel_format uyvy422 -i "0:none" -f matroska \ - | mpv -profile=low-latency --untimed --fs -
Yeah, I agree it’s a bit odd. But
ffmpeg
seems to struggle to capture the stream smoothly as well. I would almost guess it’s just opening and closing the stream repeatedly, based on how the picture and audio stutter when I try it.
I don't see ffmpeg
struggle on a MacBook Pro M1 Max, admittedly one of their higher end machines. It only slows down for me (drops frames, lags) when I add non-accelerated filters to the pipeline, which is what I'm trying to use it for.
In any event, I would love to find out why mpv
is hitting the EAGAIN
error when ffmpeg
doesn't. Or if fmpeg
does get it, how does it manage to ignore it or recover from it.
Did anyone work this out? I'm having trouble with playing the stream with MPV also...
Important Information
Provide following Information:
Reproduction steps
Run in terminal:
"HD Pro Webcam C920" is derived from
Also tried ShadowCast (capture card), same thing. Goal is to achieve this on MacOS.
Expected behavior
mpv opens with view of webcam feed
Actual behavior
Log file
output.txt
When I try to capture the feed directly in ffmpeg, I have to specify a framerate -- is there a way to do that in mpv? The fps flag didn't seem to work -- thinking maybe it instead needs to be in the ffmpeg args?