Closed TogarUshindi closed 4 years ago
@ShayBox Do you have any idea why it says "Invalid Argument"? I think v4l2 works, because video50 exists, but for some reason it still doesn't work.
I'm not an expert in ffmpeg, but my guess is the old version of ffmpeg ubuntu still provides doesn't work in the way mon2cam uses it, 3.4.6 is what you have, 4.2 is what is currently out, if possible could you either use a ppa to update ffmpeg, or download a binary and put it in the mon2cam folder, and modify the script to use that one instead and see if that fixes it?
If that's the fix, I might be able pinpoint a change to fix older ffmpeg support
I just updated to ffmpeg 4.2 using a PPA and here's the error output. There are some differences, but ultimately comes to the same "Invalid argument" in the fourth to the last line:
0: +*DVI-I-2 1920/518x1200/324+1920+0 DVI-I-2
1: +DVI-I-3 1920/518x1200/324+0+0 DVI-I-3
Which monitor: 0
CTRL + C to stop
Your screen will look mirrored for you, not others
ffmpeg version 4.2.1-0york0~18.04 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix=/usr --extra-version='0york0~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-nonfree --enable-libfdk-aac --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[x11grab @ 0x5611fe830fc0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':1+1920,0':
Duration: N/A, start: 1571450764.435110, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1200, 60 fps, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[video4linux2,v4l2 @ 0x5611fe83b500] ioctl(VIDIOC_G_FMT): Invalid argument
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Conversion failed!
Okay, after doing some testing, it appears it's not ffmpeg, Ubuntu 18.04 still ships with v4l2loopback 0.10 which had this bug which has been fixed, so the solution is to update v4l2loopback to 0.12, Ubuntu provides this for 18.10+, so you can either update ubuntu, compile v4l2loopback, or use the PPA for the newer version of ubuntu.
Okay wow you replied as I was typing my message lol
Hmmmmm.... It's trying to get me to upgrade to 19.04, which I might want to play with later, but for now I just want to see if I can get this script working, so I'll get the PPA going for v4l2loopback. (if I can locate one...)
Okay, slight change of plans. Couldn't find a PPA for v4l2loopback 0.12, so I compiled (which I'm amazed I was able to do with no problems, being a newbie!)
user@host:~/apps/v4l2loopback-master$ ./currentversion.sh
0.12.2
So, with that in place, I attempted to run the script again. Still getting an error.
$ ./apps/Mon2Cam/Mon2Cam-master/Mon2Cam.sh
Monitors: 2
0: +*DVI-I-2 1920/518x1200/324+1920+0 DVI-I-2
1: +DVI-I-3 1920/518x1200/324+0+0 DVI-I-3
Which monitor: 0
CTRL + C to stop
Your screen will look mirrored for you, not others
ffmpeg version 4.2.1-0york0~18.04 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix=/usr --extra-version='0york0~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-nonfree --enable-libfdk-aac --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[x11grab @ 0x5566b058afc0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':1+1920,0':
Duration: N/A, start: 1571453331.801893, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1200, 60 fps, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[video4linux2,v4l2 @ 0x5566b0595500] ioctl(VIDIOC_G_FMT): Invalid argument
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Conversion failed!
Run these two commands in the v4l2loopback folder you have, then reboot and try mon2cam again
make && sudo make install
sudo depmod -a
That should make, and install the compiled version, and generates mod files
If it still errors, try uninstalling the other v4l2loopback-dkms
package with apt, that fixed it in my vm
Okay so... it's not erroring out! I rebooted (makes sense. kernel module.), but still didn't work, apt remove'd the old version, and now it's (apparently) encoding frames!
The Preview window in Discord is still black, but as soon as I have a partner who's willing to try this out with me I shall see if it is working!
Okay, testing with a friend now. It's still displaying both monitors as one.
"Entire screen" shows as one long monitor, and picking an Application Window is ignored.
CTRL + C to stop
Your screen will look mirrored for you, not others
ffmpeg version 4.2.1-0york0~18.04 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
configuration: --prefix=/usr --extra-version='0york0~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-nonfree --enable-libfdk-aac --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[x11grab @ 0x55b2f997efc0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':1+0,0':
Duration: N/A, start: 1571456761.459577, bitrate: N/A
Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1200, 60 fps, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
Output #0, video4linux2,v4l2, to '/dev/video50':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1200, q=2-31, 1658880 kb/s, 60 fps, 60 tbn, 60 tbc
Metadata:
encoder : Lavc58.54.100 rawvideo
frame= 6680 fps= 31 q=-0.0 Lsize=N/A time=00:01:51.33 bitrate=N/A speed=0.513x
video:22545000kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exits normally on CTRL + C
You have to change your webcam and turn webcam on
I'm sorry, webcam? I don't have a webcam.
This doesn't fix discord screen sharing, it loops your monitor into a camera, mon2cam, click the webcam button in discord
My reaction: https://media.giphy.com/media/l0MYziGczQ3xenGaA/giphy.gif
Alright, so.... got the script running, Mon2Cam is selected, preview is still black, went into a call, selected webcam, and the two blue squares are rotating in discord, and system starts lagging a lot.
Black screen usually means abnormal resolution or aspect ratio, discord doesn't like weird webcams, try some of the scaling options like -b
Tip: you can make a single person group to call in so you don't have to be in a call with someone
Alright! It's working! I used this:
./Mon2Cam.sh -r 1280:720
Interesting note, that while -b --border
is an option in the README.md, there is no such option listed in the --help
listing. Also, -b does not specify what value it needs to implement it.
But, it's working! Thank you so much for helping me!
-b is just border, there's no value for it, but it's only needed for non 16:9 screens, glad you got it working
Oh yeah I totally forgot that I had to compile v4l2l myself aswell. I'm glad you finally got it working :)
@ShayBox I'm gonna push some examples to git, should I put it in the help page as well or only the github page?
Sure, add an examples section or link if you want, anything's good if it helps people out
I think this can be closed.
On this thread for discord-monitors-to-vc, an issue came up and I was advised to open up a thread here on the fork.
Summary: What started as a "I can't get discord-monitors-to-vc to install" issue morphed into a "I can't get Mon2Cam to work" issue, and it apparently has something to do with ffmepg. Here is the output when running in debug mode: