cychiang / webcamstudio

Automatically exported from code.google.com/p/webcamstudio
GNU General Public License v3.0
1 stars 0 forks source link

PCI Video Capture Card with multiple input sources - How to select the source? #115

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Installed webcamstudio from apt-get command
2. Rum webcamstudio from application menu
3. Select video source

What is the expected output?
Stream from source 2

What do you see instead?
Stream from source 1

The Operating system you are using (Linux, Windows etc)?
Linux Ubuntu 12.04

What version of WebcamStudio are you using?
0.64 (511)

What version of Java are you using?
java 1.6.0_31
OpenJDK Runtime Environment

What is your Webcamera vendor, model and version?
CCTV surveillance camera

Hi, i'm using a Cinergy 600 TV PCI device for grabbing images from my camera.
The problem is that my card has 2 different source. TV source (for TV cable) 
and composite source (for external video devices).

When i select the device in Webcam Studio, the TV source is selected by 
default, and i cannot select the second video source (composite).

I tried with VLC. With source=1 i can stream normally from the composite video 
input.

I'm using Webcam studio because i want to stream to UStream.

How can i select a different video source from the same video device?
Thanks

Original issue reported on code.google.com by nicola.s...@gmail.com on 26 Jul 2014 at 11:00

GoogleCodeExporter commented 9 years ago
Hi Nicola,
 we have to understand how the Cinergy 600 inputs are seen by Ubuntu.
Usually WebcamStudio takes all the /dev/videox devices from the system and show 
them in the webcams list.
How many /dev/videox devices do you have in the system?
What is the detailed name you select from VLC in the Capture Device list?
You also use an outdated WebcamStudio build. I know that for Ubuntu 12.04 that 
one is the latest buildin the PPA, but it will be interesting testing a fresh 
Ubuntu 14.04 install with the latest WS 0.65 build 557.
Let me know.
Thanks.
karl

Original comment by soylent...@gmail.com on 28 Jul 2014 at 2:50

GoogleCodeExporter commented 9 years ago
Hi, I updated my system to Ubuntu 14.04 and WebcamStudio 0.65 build 557

About your question, i have 2 video device in the system.
"ls /dev/video*" gave me "/dev/video0" and "/dev/video1".

From the "Video devices info" of your application i get:
- /dev/video0 => Terratec Cinergy 600 TV - V4L2 - Output
- /dev/video1 => WSVideoDevice (0x000) (1) - V4L2 - Input

The problem with WebcamStudio is the same, when i select the video device 
(/dev/video0), the TV source is applied by default and I cannot switch to the 
Video-In source.

For now, the only workaround i found is this:
http://forums.fedoraforum.org/showpost.php?p=1295815&postcount=2
but is not very useful, i need to launch this script every time.

But maybe, this can help you to understand the problem.

The fact is that video4linux driver is on input "0" by default and I have to 
switch to input "1" manually, every time i select the source.

From the log of your application i found
-------------------
CommandVideo: gst-launch-0.10 v4l2src device=/dev/video0 ! videorate | 
video/x-...
-------------------

As i can see from the v4l2src manual, there is the option for select the proper 
source, like this
--------------------
input-src=composite 
--------------------
maybe this can help you to understand

Also... in the output section, why i cannot see the "Ustream" button?
I found a video on YouTube with the tutorial to use UStream, but on my computer 
there isn't the proper button as output choice.

Thanks
Nicola

Original comment by nicola.s...@gmail.com on 30 Jul 2014 at 6:07

GoogleCodeExporter commented 9 years ago
Hi Nicola,
 thanks for the useful and detailed informations:
I also found this article that maybe helps :

https://vilimpoc.org/blog/2012/10/05/capturing-video-converting-hi8-using-avconv
-with-conexantbrooktree-878-tuner-card/

About the input-src=composite gst-launch option, i can't found proper 
documentation to understand how to use it ...
I try the classical way to put it after the v4l2src device=/dev/video0 
input-src=composite ... but Gstreamer 0.10 or 1.0 fire an error saying:

no property "input-src" in element "v4l2src0"

and running a:

$ gst-inspect-0.10 v4l2src

or 

$ gst-inspect-1.0 v4l2src

the element "input-src" doesn't appear on the list of available options ...

I will try to find a solution, but i think that the script is the only way to 
select the proper input at this very moment ...

About Ustream, you have to download the sample ustream.fme.example.xml file 
from here:

https://drive.google.com/folderview?id=0BxkZ_wh6t7jbSFdIaDNvUTJ2LXc&usp=sharing

Open it with gedit and edit the xxxx parts:
...
<output>
  <rtmp>
    <url>rtmp://1.xxxxxxxxx.fme.ustream.tv/ustreamVideo/xxxxxxxxx</url>
    <stream>xxxxxxxxxxSecretKeyxxxxxxxxxxxx</stream>
  </rtmp>
</output>
...

with your ustream settings.
Once done save the file as "ustream.xml" and then drag it with the mouse from 
the folder into the "Output" panel of a running WebcamStudio. A new button 
appears.
If you right click on it you can change settings too.

As soon as i find something about the input-src, i will let you know.
Thanks.
karl.

Original comment by soylent...@gmail.com on 31 Jul 2014 at 4:00

GoogleCodeExporter commented 9 years ago
Hi Nicola,
 the only solution i found so far is to use ffmpeg (... not AVconv shipped by Ubuntu) in a CustomSource.wss file format.

1) Install ffmpeg from this repository:

$ sudo apt-add-repository ppa:mc3man/trusty-media
$ sudo apt-get update
$ sudo apt-get install ffmpeg gstreamer0.10-ffmpeg

2) Download this file:

https://drive.google.com/file/d/0BxkZ_wh6t7jbWXR0Qi1xOWFjRVU/edit?usp=sharing

In this file you can put your custom command-lines following the specifications 
of WebcamStudio (@TAG). 
Please read the instructions.
I edited it with the lines:

...
video=ffmpeg -v 0 -an -f video4linux2 -channel 1 -s @CWIDTHx@CHEIGHT -r @RATE 
-i /dev/video0 -f rawvideo -pix_fmt rgb24 -s @CWIDTHx@CHEIGHT -r @RATE 
tcp://127.0.0.1:@VPORT

#audio=avconv -v 0
...

Where "channel" specify the input channel. If 1 doesn't work try to change the 
number.

3) Open WebcamStudio and drag this file to the Sources Desktop of WebcamStudio.
The new Stream-Panel will appears.

4) Try to play it.

In all forums that i read most of the people use:

$ v4l2-ctl --device=0 --set-input 1

Before capturing.

Almost nothing about the use of "input-src" option in Gst-launch, i can see 
some pipelines maded with that, but in old posts ...

Let me know.
Have a good day.
karl.

Original comment by soylent...@gmail.com on 31 Jul 2014 at 5:16

GoogleCodeExporter commented 9 years ago
Hi Karl,

I very appreciate your help. The informations you provided helped me a lot with 
my problem.

Ustream
-----------
For UStream is all good, I edited the xml file you gave me and the stream 
starts without problems.

Video Source
-----------
After installed FFMPEG, as you suggested, I tried the WSS file you gave me.
This file works like a charm, I don't have to do anything before or after the 
stream has started. The proper source is selected automatically without my 
intervention.

I think that the parameter "-channel 1" is where the magic happens.

So, very thanks for your help and willingness.

I have a last question, sorry to bother you.

Audio Source
-----------
Because my video capture card is not a webcam, the audio is not integrated and 
it originates from another source.
On the same Terratec card, there is a Line-In audio source where I connected an 
environmental microphone.

From Webcamstudio, I selected an "AudioSource" with the Cinergy device, without 
enablig a video source.
The streams starts but there is no audio. 

So i tried a more manually way. Using "arecord -l" I successfully identified 
the correct device, and i made this command:

ffmpeg \
  -f alsa \
  -i hw:2,0 \
  -ar 44100 \
  -ab 48k \
  -f flv "rtmp://1.11835359.fme.ustream.tv/ustreamVideo/xxxxxxxxxx/yyyyyyyyyyyyyyy"

and it seems to work.

Now I have a question to you.
How can i edit the .wss file, the one You gave me, to integrate the audio 
source?

I tried to replicate the audio command using only the "audio=" line (i put a # 
in front of the "video=" line) but it does not work.
I drag the wss file into the source box, in Webcamstudio, and i starts the 
stream.
The UStream feed starts correctly. There is a black box (of course, without 
video source) but there is no audio

Thanks again for your help
Nicola

 But 

Original comment by nicola.s...@gmail.com on 31 Jul 2014 at 8:01

GoogleCodeExporter commented 9 years ago
Hi Nicola,
 Thanks for the feedback.
Please try to edit your .wss file like this:

...
video=ffmpeg -loglevel panic -an -f video4linux2 -channel 1 -s @CWIDTHx@CHEIGHT 
-r @RATE -i /dev/video0 -f rawvideo -pix_fmt rgb24 -s @CWIDTHx@CHEIGHT -r @RATE 
tcp://127.0.0.1:@VPORT

audio=ffmpeg -loglevel panic -f alsa -i hw:2,0 -ar 44100 -ac 2 -f s16be 
tcp://127.0.0.1:@APORT
...

In this way I think you can grab the audio-input as well.
Let me know and don't worry, you don't bother me at all.
Your Testings makes WebcamStudio better !!!
Have a good weekend.
karl

Original comment by soylent...@gmail.com on 1 Aug 2014 at 11:56

GoogleCodeExporter commented 9 years ago
Good news Karl!

Everything seems to work.
Here is the final version of the .wss file: http://pastebin.com/PsN0xDaD where 
both audio and video sources are streamed at the same time.

I don't why the audio source, from the Terratec card, switched to hw:1,0, but 
it is not a real problem.
I hope it doesn't do this change at every boot.

The video stream ALONE works good (the fps are a bit short, 6~10fps).
The audio stream ALONE works good.

I'm facing a nasty problem now.. my bandwith is not enough to stream both audio 
and video at top quality.
So.. I need to adjust the bitrate of both sources to stay in my little upload 
bandwidth.

I know that this problem is not strictly related to your application, but maybe 
you can help me on this issue.

I don't care if the video is a bit laggy, but the sound need to be at least 
continuous (even if a low quality).
For now, if I stream both a/v source with the current configuration, the sound 
is very discontinuous and the track seems to be corrupted.

I read the FFMPEG documentation about the bitrate parameters, but all my tests 
edigint the .wss file have failed.

This page particularly: 
http://trac.ffmpeg.org/wiki/Limiting%20the%20output%20bitrate shows how to use 
the bitrate argument, but I think i don't understand properly how to use that.

Thanks again for all your help.
Nicola

Original comment by nicola.s...@gmail.com on 1 Aug 2014 at 7:20

GoogleCodeExporter commented 9 years ago
Hi Nicola,
 i'm very happy that the .wss file works ok. :)
Because the first issue seems solved, if for you is not a problem, we can 
continue the discussion via mail (soylent.tv@gmail.com) or in the G+ community:

https://plus.google.com/communities/110329269823088092206

I prefer the community because maybe helps others guys with the same questions.
Anyway you don't have to change the ffmpeg lines in .wss because there is used 
a standard format to talk to WebcamStudio.

About the Audio I forgot to tell you that the frequency we put in the .wss line 
(44100) is ok if you previously select "44100" in WebcamStudio at the top bar.
WS starts with an audio sample rate of 22050 by default. If so change the line 
in the .wss file related to audio:

audio=ffmpeg -loglevel panic -f alsa -i hw:1,0 -ar 22050 -ac 2 -f s16be 
tcp://127.0.0.1:@APORT

To let the .wss Audio sample rate automatically follow the WebcamStudio chosen 
Audio rate you can use the follow line instead:

audio=ffmpeg -loglevel panic -f alsa -i hw:1,0 -ar @FREQ -ac 2 -f s16be 
tcp://127.0.0.1:@APORT

Then you have to check if the .wss is played without problems inside WS.
Once you start the .wss stream (without Ustream output), check if the fps drops 
down (look at the bottom status bar of WS) and activating the audio output 
("Audio" button on the Outputs) ear if the sound is Ok.
If the fps are not stable, try to lower the WS mixer resolution:

1) Go in the "mixer" tab at the left of WS
2) Select a lower resolution
3) Click Apply/Reset
4) Click Apply to streams

I firstly start with 320x240 at 25 fps.
Usually Audio is played Ok, but if the fps drops, you will ear interruptions ...

Remember that when you want to start broadcasting to ustream is better to 
deactivate the local audio of WS if you selected it before for testing ...

About the bitrate you have to change the settings of Ustream output.
Right Click on the "ustream" button when this is not active and select settings.
At first try to put lower bitrate:

Video Data rate: 300
Audio Data rate: 96

Try different settings to match your bandwidth.

Another thing is that if you start the streaming and you don't need to use WS 
commands, if you minimize the window the CPU usages will be less intensive.

Some services like JustinTV needs audio rate set to 44100 min, otherwise the 
stream is not accepted.

Thanks Nicola.
Have a good weekend.
karl. 

Original comment by soylent...@gmail.com on 2 Aug 2014 at 6:22

GoogleCodeExporter commented 9 years ago
Thank you for your help Karl.

As you suggested, i wrote a new topic in the G+ community

Have a good weekend too
Nicola

Original comment by nicola.s...@gmail.com on 2 Aug 2014 at 2:40

GoogleCodeExporter commented 9 years ago

Original comment by soylent...@gmail.com on 28 Aug 2014 at 3:20