Author Topic: Use of webcam  (Read 15118 times)

Remy

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 15
  • Posts: 364
  • Karma: +0/-0
    • View Profile
Re: Use of webcam
« Reply #150 on: July 19, 2020, 11:39:28 pm »
Right now I am working on two companion webcam monitor programs:

wmaudio.exe - Webcam Monitor Audio for OS/2 (ArcaOS/eComStation)
wmvideo.exe - Webcam Monitor Video for OS/2 (ArcaOS/eComstation)

wmaudio.exe /aN plays audio thru AmpMix0N so on any audio adapter.
Input is \PIPE\Webcam\Audio. It plays with minimal delay.

wmvideo.exe is a pm program that shows video on your desktop.
Input is \PiPE\Webcam\Video. It shows with minimal delay.

Best regards,
Wim.

How do you make both been in syncro ?
With ffplay, video has a lot of possible adjustment etc with low latency (as soon input buffer is kept at 0) but ffplay audio has high latency and I didn't find a way to reduce it under ffplay...
Through ffmpeg, I think it could be different... 

May be wmaudio could provide a syncronized audio with the ffplay video output !

Note: WCC updated to allow webcam audio supported sampling (from 16000 up to 48000)
- If AN USB drivers (wait for official USB 12.7 drivers to prevent trap000e)
- With Lars 16 bits drivers, it should work
Once enabled, You have video + audio (audio latency is higher than video)   

note: I apology having left hard coded path I use during development test. Corrected in the the 20072020 build
 
« Last Edit: July 20, 2020, 08:50:48 am by Remy »

Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 37
  • Posts: 212
  • Karma: +1/-0
    • View Profile
    • Wim's home page
Re: Use of webcam
« Reply #151 on: July 20, 2020, 10:49:56 pm »
Hi Rémy,

At last some test results working with WCC_update-20072020.zip:

1. Buttons "Cam is off" and "Cam is on" do their work.
2. Video is shown when using the show and [] buttons.
3. Query vSize list c250 webcam never finds 640x400 video formats.
4. Query vSize list e6500 webcam does not find yuyv 640x480,1024x768,1280x1024 formats.
5. Query vSize list e6500 webcam finds yuyv 1200x1600 format but size button does not show it.[] button shows it.
6. Query vSize list e6500 webcam correctly finds no mjpg formats. But see point 7.
7. Using Defaults Max Vsize after point 6. shows strange VMMXxVHMx default format.

This WCC version works much better than the previous ones.
Audio has not yet been tested but I will try that tomorrow.

Documentation needs brushing up: better structure and better spelling.
Pictures and text need to match what the program does and what it shows.
But you know that already. Not easy to do. To be done...

Regards,
Wim.

Remy

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 15
  • Posts: 364
  • Karma: +0/-0
    • View Profile
Re: Use of webcam
« Reply #152 on: July 20, 2020, 11:46:10 pm »
Hi Rémy,

At last some test results working with WCC_update-20072020.zip:

1. Buttons "Cam is off" and "Cam is on" do their work.
2. Video is shown when using the show and [] buttons.
3. Query vSize list c250 webcam never finds 640x400 video formats.
4. Query vSize list e6500 webcam does not find yuyv 640x480,1024x768,1280x1024 formats.
5. Query vSize list e6500 webcam finds yuyv 1200x1600 format but size button does not show it.[] button shows it.
6. Query vSize list e6500 webcam correctly finds no mjpg formats. But see point 7.
7. Using Defaults Max Vsize after point 6. shows strange VMMXxVHMx default format.

This WCC version works much better than the previous ones.
Audio has not yet been tested but I will try that tomorrow.

Documentation needs brushing up: better structure and better spelling.
Pictures and text need to match what the program does and what it shows.
But you know that already. Not easy to do. To be done...

Regards,
Wim.

About 640x400, 1024x768 and 1280x1024, I missed them into my check list !

For 4/ 5/ 6/ and 7/
Did you try with and without yuyv option ?

7/ could happen if your webcam has a long respons time

Doc:
Right, I'm not top into this part... :D

I updated WCC an included missing video format scan and added more time if needed to get webcam datas.
[] has limited format and query Vsize updates size button entries (no update done under min-size used when [] is used (the min button is limited to small standard sizes supported by ffplay, independent from Vsizes found used to set webcam - Sound is disabled when click on [] but available under [show] with enable audio (*Be careful about USB issue*) with correct sampling rate.
« Last Edit: July 21, 2020, 06:02:26 pm by Remy »

TeLLie

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 10
  • Posts: 94
  • Karma: +0/-0
    • View Profile
Re: Use of webcam
« Reply #153 on: July 21, 2020, 11:14:01 am »
Hi Remy,
With this latest update its working on the W530
Thankz  and also Wim thankz alot :)

Remy

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 15
  • Posts: 364
  • Karma: +0/-0
    • View Profile
Re: Use of webcam
« Reply #154 on: July 21, 2020, 02:36:08 pm »
Hi Remy,
With this latest update its working on the W530
Thankz  and also Wim thankz alot :)

Good news.
Thanks

Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 37
  • Posts: 212
  • Karma: +1/-0
    • View Profile
    • Wim's home page
Re: Use of webcam
« Reply #155 on: July 22, 2020, 06:24:09 pm »
Hi Remy,

Test results with WCC_updated-21072020_nodoc.zip:

1. I saw the "Missing Requirements" popup several times.
    Each time only once just after booting op the system.
    But not always. Too short timeout perhaps?

2. Now all yuyv formats are found for the builtin webcam.
    1600x1200 and 1280x1024 formats only show with the [] button.
    Perhaps because my laptop screen size is 1440x900 pixels?

3. Cam-Intf range is 1:9 but logitech webcams have 1:11 range.
    There could be webcams out there with even a larger range.

4. Audio does not work with my ffmpeg 2.8.6-2 installation.
    Without -volume 30 and without -nodisp audio works.
    And without -sync ext audio works somewhat better.

5. When I set Defaults Audio to 22050HZ then 48000 Hz is used.
    When I set Defaults Audio to 44100HZ then 48000 Hz is used.
    The c250/c270 webcams support 16000/24000/32000/48000 Hz.
    I could make these deliver 22050 Hz and 44100 Hz too.
    At least the list must include 24000 Hz and 32000 Hz.

Regards,
Wim.

Remy

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 15
  • Posts: 364
  • Karma: +0/-0
    • View Profile
Re: Use of webcam
« Reply #156 on: July 22, 2020, 09:22:20 pm »
Hi Remy,

Test results with WCC_updated-21072020_nodoc.zip:

1. I saw the "Missing Requirements" popup several times.
    Each time only once just after booting op the system.
    But not always. Too short timeout perhaps?

2. Now all yuyv formats are found for the builtin webcam.
    1600x1200 and 1280x1024 formats only show with the [] button.
    Perhaps because my laptop screen size is 1440x900 pixels?

3. Cam-Intf range is 1:9 but logitech webcams have 1:11 range.
    There could be webcams out there with even a larger range.

4. Audio does not work with my ffmpeg 2.8.6-2 installation.
    Without -volume 30 and without -nodisp audio works.
    And without -sync ext audio works somewhat better.

5. When I set Defaults Audio to 22050HZ then 48000 Hz is used.
    When I set Defaults Audio to 44100HZ then 48000 Hz is used.
    The c250/c270 webcams support 16000/24000/32000/48000 Hz.
    I could make these deliver 22050 Hz and 44100 Hz too.
    At least the list must include 24000 Hz and 32000 Hz.

Regards,
Wim.

1/ I run in detach mode a process. May be your system isn't fully available when WCC is run ! (I run it under a delayed start folder "AN")
    I added a short delay near what I use under mys system to not having trouble running some process in detach mode and add an extra delay if this process didn't reply in the expected time delay)

2/ If you have virtual desktop, it should display with a part in the next window... (So doesn't look under my system when I select the highest size above my screen size)...  When you use the show button, video size is what webcam provides (no specified size under ffplay) using Size setting. The [] uses the same webcam setting but ffplay has a size set to the min-size  (At start, it may display for a fraction of seconds, original webcam size set but immedialtly, it switches to the specified min-size.
note1: sometimes, I have no output from first webcam start but all next restart work
note2: Now, if you select a Size above what your screen is able, the Text Size goes into red.

3/ increased to 15

4/ "Without -volume 30 and without -nodisp audio works"
     It must work but I think your system audio level is set very low (ref for 100) and when 30 is used, the audio is then very very low may be like no sound (I'll added an option to use default volume at 100 or to reduce it to 50). -nodisp has no impact here and prevent video simulation process for audio stream. About -sync ext (it improves a little audio latency under my system but it could have a little impact on audio under some systems. I removed it

    As I wrote it, audio is comming later then the video (about 2s). You have to wait to hear the audio... Under ffplay, I reduces as much as possible but I know it will introduce long delay du to ffplay internal process. 

5/ 24000 and 32000 added
    When you set 22050HZ, /a22050 is set on webcam (no other value is possible using this setting and so is it for other audio sample settings).
    I did a try  webcam /a22050 | ffplay -f wav -i \PIPE\Webcam\Audio  and I have 48000
    With -f wav , ffplay provides 48000 for the received input stream   (webcam sends wav audio stream)
    I tried -f s16le - ffplay provides 44100 for the received input stream   (but bad audio in this case due input is wav)
    The issued webcam command is correct. In fact, no matter if ffplay output has higher sampling then the input stream.
    If webcam could send needed information to allow ffplay to auto detect the codec, this would prevent -f wav use. 
   
     
« Last Edit: July 22, 2020, 09:31:50 pm by Remy »

Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 37
  • Posts: 212
  • Karma: +1/-0
    • View Profile
    • Wim's home page
Re: Use of webcam
« Reply #157 on: July 23, 2020, 06:09:30 pm »
Hi Remy,

Thank you for your explanations and modifications. WCC_update-22072020.zip works well.

Only audio does not work for me because I have ffmpeg 2.8.6-2 installed which does not support -volume 30 nor -nodisp.
Quote
4/ "Without -volume 30 and without -nodisp audio works"
     It must work but I think your system audio level is set very low (ref for 100) and when 30 is used, the audio is then very very low may be like no sound (I'll added an option to use default volume at 100 or to reduce it to 50). -nodisp has no impact here and prevent video simulation process for audio stream.
That is not the case. It does not work because I am using ffmpeg 2.8.6-2 which rejects -volume 30 and -nodisp.

I have updated webcam.exe because:
A. It now recognizes webcams better while scanning descriptors.
B. It may obtain 22050/44100 Hz. audio streams from logitech webcams.
Note: Audio capabilities are still hardcoded i.e. descriptors not scanned.

Quote
May be wmaudio could provide a syncronized audio with the ffplay video output !
I added wmaudio.exe - Webcam Monitor Audio for OS/2 - first beta version.
Not really synchronized but perhaps more appropriate.
 
Best regards,
Wim.

Remy

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 15
  • Posts: 364
  • Karma: +0/-0
    • View Profile
Re: Use of webcam
« Reply #158 on: July 23, 2020, 06:56:33 pm »
Hi Remy,

Thank you for your explanations and modifications. WCC_update-22072020.zip works well.

Only audio does not work for me because I have ffmpeg 2.8.6-2 installed which does not support -volume 30 nor -nodisp.
Quote
4/ "Without -volume 30 and without -nodisp audio works"
     It must work but I think your system audio level is set very low (ref for 100) and when 30 is used, the audio is then very very low may be like no sound (I'll added an option to use default volume at 100 or to reduce it to 50). -nodisp has no impact here and prevent video simulation process for audio stream.
That is not the case. It does not work because I am using ffmpeg 2.8.6-2 which rejects -volume 30 and -nodisp.

>> ok, parms have changed (not supported)


I have updated webcam.exe because:
A. It now recognizes webcams better while scanning descriptors.
B. It may obtain 22050/44100 Hz. audio streams from logitech webcams.
Note: Audio capabilities are still hardcoded i.e. descriptors not scanned.

Quote
May be wmaudio could provide a syncronized audio with the ffplay video output !
I added wmaudio.exe - Webcam Monitor Audio for OS/2 - first beta version.
Not really synchronized but perhaps more appropriate.
 
Best regards,
Wim.

Nice.
I just did a few test (audio delay seems to be much better but not enough time to be sure "larsen")
tried with c270: default or /a3 provides no audio, I have to set /a1 to get some audio

Now, 22050 and 44100 provides correct results as expected. 

But I can not reduce its volume and it goes immediately into larsen at full volume level. It seems that PMUNIMIX loses control. May it possible to add a volume level flag to wmaudio ?  /vNNN or something like that (volume level adjustable from 0 to 100 ? like ffplay has)
Thanks

regards
Rémy 
« Last Edit: July 24, 2020, 10:22:41 pm by Remy »

Remy

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 15
  • Posts: 364
  • Karma: +0/-0
    • View Profile
Re: Use of webcam
« Reply #159 on: July 24, 2020, 02:15:12 pm »
Hi Wim,

I tried other test using webcam and ffmpeg
- Latency is not a real problem recording video with ffmpeg
- But it is if the output should be streamed

My ffmpeg test show audio having a delay against video but it seems to me that the tempo isn't fully correct.
I tried several ffmpeg test but I didn't find the right setting up to know.
My latest test:
webcam set to 640x360 and audio to 22050
ffmpeg -y -thread_queue_size 128 -f:a atempo=1.01 -f wav -ac 1 -i \PIPE\Webcam\Audio -itsoffset 2.80 -thread_queue_size 128 -framerate 25 -f mjpeg -i \PIPE\Webcam\Video -q:v 4 -vcodec copy -acodec copy -async 1 -threads 2 output.avi

itsoffset reduces audio delay
-tread_queue_size 128 to prevent some messages
copy for video and audio to not convert
async 1 (to try to maintain in sync quickly)
treads 2 to optimize process
outup as avi because it is compatible with wav and mjped
q:v 4 to set video quality
Because audio seems slower than the video, I added atempo to try having a better result (supported with recent ffmpeg build ok with 4.0.2)
(note: setting a slower framerate than 25 could help but to much dropped frames)
The result is better but not good at all...

Any suggestion to improve sync and final result is wellcome

Tried:
ffmpeg -y -thread_queue_size 192 -f:a atempo=1.02 -f wav -ac 1 -i \PIPE\Webcam\Audio -itsoffset 3.23 -thread_queue_size 64 -framerate 16 -f mjpeg -i \PIPE\Webcam\Video -q:v 4 -vcodec copy -acodec copy -async 1 -threads 2 output.avi

Reducing video framerate to 16 instead of source 25 makes things a little bit better. It looks like the video is too fast or audio too slow ! 
« Last Edit: July 24, 2020, 10:24:38 pm by Remy »

Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 37
  • Posts: 212
  • Karma: +1/-0
    • View Profile
    • Wim's home page
Re: Use of webcam
« Reply #160 on: July 25, 2020, 09:57:16 am »
Hi Remy,

Quote
I just did a few test (audio delay seems to be much better but not enough time to be sure "larsen")
tried with c270: default or /a3 provides no audio, I have to set /a1 to get some audio
On my DELL Latitude E6500 laptop /a1 is the builtin audio adapter and /a2 is the Conceptronic CSOUNDU and /a3 is the Behringer UMC204HD.
The Behringer UMC204HD is setup as the default device and thus on my system /a0 is that adapter too.
See USB Audio Adapters on my website. ;) Now you know where wmaudio is coming from.

Quote
May it possible to add a volume level flag to wmaudio ?  /vNNN or something like that (volume level adjustable from 0 to 100 ? like ffplay has)
Done. I added the /vN parameter and I changed the default of the /aN parameter. See wmaudio.txt for more information.

Regards,
Wim.

Remy

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 15
  • Posts: 364
  • Karma: +0/-0
    • View Profile
Re: Use of webcam
« Reply #161 on: July 26, 2020, 11:15:24 am »
Hi Remy,

Quote
I just did a few test (audio delay seems to be much better but not enough time to be sure "larsen")
tried with c270: default or /a3 provides no audio, I have to set /a1 to get some audio
On my DELL Latitude E6500 laptop /a1 is the builtin audio adapter and /a2 is the Conceptronic CSOUNDU and /a3 is the Behringer UMC204HD.
The Behringer UMC204HD is setup as the default device and thus on my system /a0 is that adapter too.
See USB Audio Adapters on my website. ;) Now you know where wmaudio is coming from.

Quote
May it possible to add a volume level flag to wmaudio ?  /vNNN or something like that (volume level adjustable from 0 to 100 ? like ffplay has)
Done. I added the /vN parameter and I changed the default of the /aN parameter. See wmaudio.txt for more information.

Regards,
Wim.

Hi Wim,

I have good results using wmaudio  (I could limit larsen when using PC HPs and hear me very good using headphones)
I did more test using ffmpeg and the strange I found is that the c270 output specifies a framerate of 25 but in fact, it isn't due I have to use framerate 15 to get a ormal video output speed (with ffplay, framerate doesn't change the video speed but it helps to drop latency, read buffer..) . A test which allow me to have a nearly "syncronized" video file (it can be adjusted changing parm -itsoffset value).

switched from mjpeg to yuyv (better for syncro) for webcam with audio rate 48000 or 44100   
Used following command (inverted video and audio order compared ti my previous test and it is better)

ffmpeg -itsoffset 2.38 -framerate 15 -thread_queue_size 128 -f mjpeg -i \PIPE\Webcam\Video -thread_queue_size 192 -f wav -i \PIPE\Webcam\Audio -probesize 128 -q:v 5 -vsync 1 -threads 2 test.avi

A 30s recording test provided me a better result than all tests I previously did.
(wait about 3s second having started the recording to start speak etc...)   

Regards
Rémy

An updated WCC will be available soon.

Remy

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 15
  • Posts: 364
  • Karma: +0/-0
    • View Profile
Re: Use of webcam
« Reply #162 on: July 26, 2020, 07:02:33 pm »
WCC update (including wmaudio volume reduction (one setting only to prevent larsen)

Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 37
  • Posts: 212
  • Karma: +1/-0
    • View Profile
    • Wim's home page
Re: Use of webcam
« Reply #163 on: July 26, 2020, 07:16:37 pm »
Hi Remy,

To record zmovie.avi I used webcam.exe /a/n and the following line:

ffmpeg -async 1 -framerate 25 -itsoffset 2.0 -i \PIPE\Webcam\Video -i \PIPE\Webcam\Audio -c:v copy -c:a copy -map 0:0 -map 1:0 zmovie.avi

And it works very well. The following line produces compressed output (10 times reduction in filesize):

ffmpeg -async 1 -framerate 25 -itsoffset 2.0 -i \PIPE\Webcam\Video -i \PIPE\Webcam\Audio -map 0:0 -map 1:0 zmovie.avi

And works very well too. But I do prefer the uncompressed movie.

There is no delay in the recorded audio and it stays in sync.

Best regards,
Wim.


Remy

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 15
  • Posts: 364
  • Karma: +0/-0
    • View Profile
Re: Use of webcam
« Reply #164 on: July 26, 2020, 09:41:48 pm »
Hi Remy,

To record zmovie.avi I used webcam.exe /a/n and the following line:

ffmpeg -async 1 -framerate 25 -itsoffset 2.0 -i \PIPE\Webcam\Video -i \PIPE\Webcam\Audio -c:v copy -c:a copy -map 0:0 -map 1:0 zmovie.avi

And it works very well. The following line produces compressed output (10 times reduction in filesize):

ffmpeg -async 1 -framerate 25 -itsoffset 2.0 -i \PIPE\Webcam\Video -i \PIPE\Webcam\Audio -map 0:0 -map 1:0 zmovie.avi

And works very well too. But I do prefer the uncompressed movie.

There is no delay in the recorded audio and it stays in sync.

Best regards,
Wim.

Oh well done,
I have missplaced parameters...

Your command line as given:
It will not work with ffmpeg 4.0.2 and up  (many options or parameters changed between versions.
(I have to check ffmpeg version to use correct ffmpeg version/parameters under AVxCAT) 

ffmpeg -async 1 -framerate 25 -itsoffset 2.0 -i \PIPE\Webcam\Video -i \PIPE
\Webcam\Audio -c:v copy -c:a copy -map 0:0 -map 1:0 zmovie.avi
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.5.0 (GCC)
  configuration: --enable-gpl --disable-doc --cpu=i686 --enable-fontconfig --ena
ble-libfreetype --enable-libxvid --enable-libvpx --enable-libx264 --enable-libmp
3lame --enable-libopus --enable-libtheora --prefix='h:/tmp/ffmpeg' --disable-sta
tic --enable-shared --extra-libs=-lcx --extra-ldflags=-Zhigh-mem --extra-cflags=
'-isysroot k:/usr/include'
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Option framerate not found.

Without framerate, it works but it is played very fast (not real framerate) due to auto set to 25 which is too fast (accelerated video/audio)

But, from yous suggestion I did a new test changing parameters as needed and it work now well here with c270 using :
ffmpeg -async 1 -framerate 15 -itsoffset 2.0 -f mjpeg -i \PIPE\Webcam\Video
 -i \PIPE\Webcam\Audio -c:v copy -c:a copy -map 0:0 -map 1:0 zmovie.avi

note: mapping is not needed here because each input file only has one stream (video or audio), it is automatically mapped by ffmpeg. 
copy will copy frames as is without changes (this produces a big file) 

I have to set framerate to 15 to get normal speed and add -f mjpeg to use -framerate option.

The best command line with a resulting small video size:
ffmpeg -async 1 -framerate 15 -itsoffset 2.0 -f mjpeg -i \PIPE\Webcam\Video -i \PIPE\Webcam\Audio -q:v 3 -b:a 192k zmovie.avi

To remove the thread_queue_size message, I add one more parameter:
ffmpeg -async 1 -framerate 15 -itsoffset 2.0 -f mjpeg -i \PIPE\Webcam\Video -thread_queue_size 96 -i \PIPE\Webcam\Audio -q:v 3 -b:a 192k zmovie.avi

video quality set to a good value and audio set to CBR (converted into mp3) with a good 192K bitrate.

Thanks  ;)
Regards
Rémy 

logfile from a test using an experimental ffmpeg build (not available yet by its author):

Update: after adding -framerate 25 to the input stream just after -f mjpeg, It works too using the -framerate 25 setting after -async, having a correct 25 fps output.
ffmpeg -async 1 -framerate 25 -itsoffset 2.0 -f mjpeg -framerate 25 -i \PIPE\Webcam\Video -i \PIPE\Webcam\Audio -q:v 3 -b:a 192k zmovie.avi
(adding the -thread_queue_size may introduce some out of sync
 
« Last Edit: July 27, 2020, 02:49:27 pm by Remy »