LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-05-2012, 08:48 AM   #1
paziulek
Member
 
Registered: Mar 2009
Location: N.C.
Distribution: "gentoo|debian|arch"
Posts: 106

Rep: Reputation: 11
Question ffmpeg - equivalent of mencoder's immediatemode=0


Hello,

I am able to capture audio and video from a Pinnacle Dazzle DVC100 using mencoder:

Code:
mencoder tv:// -tv driver=v4l2:width=720:height=480:norm=1:device=/dev/video0:forceaudio:alsa:adevice=hw.1:audiorate=44100:immediatemode=0 -ovc xvid -xvidencopts bitrate=800:me_quality=6 -oac mp3lame -lameopts cbr:br=128 -o out.avi
if I try to use ffmpeg, I get no sound:
Code:
 ffmpeg -y  -f video4linux2 -i /dev/video0 -f alsa -i hw:1,0 -aspect 16:9 -vcodec libx264 -cmp +chroma -b 400k -refs 1 -coder 0 -subq 1 -partitions +parti4x4+parti8x8+partp8x8 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -trellis 2 -sc_threshold 40 -acodec libfaac -ab 128k -ar 44100 -ac 1 -i_qfactor 0.71 -f mp4 -strict experimental aaa.mp4
tried ALSA and OSS ( /dev/audio and dsp ) device names, different codecs..... with no success.
The "immediatemode=0" is required to get audio out of DVC100 - for mencoder - is there an equivalent in ffmpeg?
Quote:
immediatemode=<bool>

A value of 0 means capture and buffer audio and video together (default for MEncoder). A value of 1 (default for MPlayer) means to do video capture only and let the audio go through a loopback cable from the TV card to the sound card.
ffmpeg latest git version: N-42170-g71e5a14 - tested also with 4-5 other, older versions incl 0.10.2

Thank you,

paziulek
 
Old 07-05-2012, 04:30 PM   #2
ShadowCat8
Member
 
Registered: Nov 2004
Location: San Bernardino, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 261

Rep: Reputation: 52
Greetings,

Not being too familiar with the DVC100 and it's peculiarities, I'm curious which actual sound devices *are* available on your system. Looking at the rc script for alsasound, I noted the following section:
Code:
...<snip>...
        # Kill processes holding open sound devices
        #
        # DEVS=`find /dev/ -follow -type c -maxdepth 1 -print 2>/dev/null | xargs ls -dils | grep "1*1[46]," | cut -d: -f2 | cut -d" " -f2; echo /proc/asound/dev/*`
        local ossdevs="/dev/admmidi* /dev/adsp* /dev/amidi* /dev/audio* /dev/dmfm* \
                        /dev/dmmidi* /dev/dsp* /dev/dspW* /dev/midi0* /dev/mixer* /dev/music \
                        /dev/patmgr* /dev/sequencer* /dev/sndstat"
        local alsadevs="/proc/asound/dev/* /dev/sound/* /dev/snd/*"
        fuser -k ${ossdevs} ${alsadevs} >/dev/null 2>/dev/null
So, do you have any devices at /dev/sound/* or /dev/snd/*? One of those may be the input point you need to use. But, from my experience, if ffmpeg is given an audio stream, it should put it into the output file unless you specifically say otherwise. (Another thought might be the "-newaudio" option for 'ffmpeg'?)

HTH. Let us know.
 
Old 07-05-2012, 07:11 PM   #3
paziulek
Member
 
Registered: Mar 2009
Location: N.C.
Distribution: "gentoo|debian|arch"
Posts: 106

Original Poster
Rep: Reputation: 11
hello,

Thank you for your reply,
this is what I got:

Quote:
# grep hw\: /tmp/alsa-info.txt.dIIhAgnC3Q
Card hw:0 'Audigy2'/'SB Audigy 2 ZS [SB0353] (rev.4, serial:0x10031102) at 0x4000, irq 24'
Card hw:1 'DVC100'/'Pinnacle Systems GmbH DVC100 at usb-0000:00:1d.7-8.2, high speed'
ALSA, OSS support is enabled: ( lsmod )
Code:
snd_seq_oss            22603  0 
snd_seq_midi_event      4572  3 snd_seq_midi,snd_seq_virmidi,snd_seq_oss
snd_seq                39698  9 snd_seq_midi,snd_emux_synth,snd_seq_virmidi,snd_seq_midi_emul,snd_seq_dummy,snd_seq_oss,snd_seq_midi_event
snd_pcm_oss            31587  0 
snd_mixer_oss          12350  1 snd_pcm_oss
snd_pcm                60132  4 snd_pcm_oss,snd_usb_audio,snd_emu10k1,snd_ac97_codec
snd_seq_device          4449  8 snd_seq_midi,snd_emu10k1_synth,snd_emux_synth,snd_seq_dummy,snd_seq_oss,snd_seq,snd_emu10k1,snd_rawmidi
snd                    44163  27 snd_emux_synth,snd_seq_virmidi,snd_seq_oss,snd_seq,snd_pcm_oss,snd_mixer_oss,snd_usb_audio,snd_usbmidi_lib,snd_emu10k1,snd_rawmidi,snd_ac97_codec,snd_pcm,snd_seq_device,snd_timer,snd_hwdep
ALSA devices:

# find /dev/snd/
/dev/snd/
/dev/snd/midiC0D3
/dev/snd/hwC0D2
/dev/snd/midiC0D2
/dev/snd/by-id
/dev/snd/by-id/usb-Pinnacle_Systems_GmbH_DVC100-01
/dev/snd/controlC1
/dev/snd/pcmC1D0c
/dev/snd/by-path
/dev/snd/by-path/pci-0000:00:1d.7-usb-0:8.2:1.1
/dev/snd/by-path/pci-0000:09:01.0
/dev/snd/controlC0
/dev/snd/pcmC0D0p
/dev/snd/pcmC0D2p
/dev/snd/pcmC0D0c
/dev/snd/pcmC0D1c
/dev/snd/pcmC0D2c
/dev/snd/pcmC0D3p
/dev/snd/pcmC0D4c
/dev/snd/midiC0D0
/dev/snd/pcmC0D4p
/dev/snd/midiC0D1
/dev/snd/hwC0D0
/dev/snd/seq
/dev/snd/timer


OSS devices:
/dev/dsp
/dev/dsp1
/dev/audio
/dev/audio1

and 2 mixers...

mencoder with options:
forceaudio : forces audio if v4l2 does not report any audio devices
and immediatemode
makes possible to capture audio with no problem.... from many pieces of hardware including the pinnacle 100

if I use ffmpeg, to capture just audio, from alsa or oss devices, it shows the right parameters for the input stream, but there is no sound:

# ffmpeg -y -f alsa -i hw:1,0 -acodec libmp3lame another_try.mp3
Code:
    Output #0, mp3, to 'another_try.mp3':
  Metadata:
    TSSE            : Lavf54.14.100
    Stream #0:0: Audio: mp3, 48000 Hz, stereo, s16
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le -> libmp3lame)
Press [q] to stop, [?] for help
size=     188kB time=00:00:11.97 bitrate= 128.4kbits/s    
video:0kB audio:188kB subtitle:0 global headers:0kB muxing overhead 0.105729%
and this is mencoder:
# mencoder tv:// -tv driver=v4l2:width=720:height=480:norm=1:device=/dev/video0:forceaudio:alsa:adevice=hw.1:audiorate=44100:immediatemode=0 -ovc xvid -xvidencopts bitrate=800:me_quality=6 -oac mp3lame -lameopts cbr:br=128 -o out.avi

Code:
[V] filefmt:9  fourcc:0x32595559  size:720x480  fps:29.970  ftime:=0.0334
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
xvid: using library version 1.3.2 (build xvid-1.3.2)
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
==========================================================================
Opening video decoder: [raw] RAW Uncompressed Video
Movie-Aspect is undefined - no prescaling applied.
videocodec: XviD (720x480 fourcc=44495658 [XVID])
xvid: par=0/0 (vga11), displayed=720x480, sampled=720x480
xvid: CBR Rate Control -- bitrate=800kbit/s
Selected video codec: [rawyuy2] vfm: raw (RAW YUY2)
==========================================================================
MP3 audio selected.
Forcing audio preload to 0, max pts correction to 0.
Pos:   0.0s      1f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
Writing header...
ODML: vprp aspect is 16384:10922.
Setting audio delay to 0.026s.
Writing header...
ODML: vprp aspect is 16384:10922.
Setting audio delay to 0.026s.
tested both outputs - ALSA and OSS with mplayer - both play good... but nothing "recorded" in ffmpeg...

still trying to get this to work.. for last 3 days... thanks for any suggestions, I am slowly running out of ideas :-[

EDIT:
output from arecord -l

# arecord -l
Code:
**** List of CAPTURE Hardware Devices ****
card 0: Audigy2 [SB Audigy 2 ZS [SB0353]], device 0: emu10k1 [ADC Capture/Standard PCM Playback]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Audigy2 [SB Audigy 2 ZS [SB0353]], device 1: emu10k1 mic [Mic Capture]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Audigy2 [SB Audigy 2 ZS [SB0353]], device 2: emu10k1 efx [Multichannel Capture/PT Playback]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Audigy2 [SB Audigy 2 ZS [SB0353]], device 4: p16v [p16v]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: DVC100 [DVC100], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Last edited by paziulek; 07-05-2012 at 07:18 PM. Reason: what?
 
Old 07-05-2012, 07:30 PM   #4
ShadowCat8
Member
 
Registered: Nov 2004
Location: San Bernardino, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 261

Rep: Reputation: 52
Well,

What about trying this:
Code:
ffmpeg -y -f alsa -i hw:1,-1,-1 -acodec libmp3lame another_try.mp3
That should grab *any* active ALSA-enabled audio stream from the DVC100 connection. And, if it works, the output should show you where the stream is coming from exactly. I got that idea from ffplay:
Quote:
Originally Posted by The ffplay man page
Code:
   alsa
       ALSA (Advanced Linux Sound Architecture) input device.

       To enable this input device during configuration you need libasound installed on your system.

       This device allows capturing from an ALSA device. The name of the device to capture has to be an ALSA card identifier.

       An ALSA identifier has the syntax:

               hw:<CARD>[,<DEV>[,<SUBDEV>]]

       where the DEV and SUBDEV components are optional.

       The three arguments (in order: CARD,DEV,SUBDEV) specify card number or identifier, device number and subdevice number (-1 means any).
HTH. Let us know.
 
Old 07-05-2012, 08:48 PM   #5
paziulek
Member
 
Registered: Mar 2009
Location: N.C.
Distribution: "gentoo|debian|arch"
Posts: 106

Original Poster
Rep: Reputation: 11
Thanks for the idea!

# ffplay -f alsa -i hw:-1

[alsa @ 0x15e4140] cannot open audio device hw:-1 (No such device)
hw:-1: Input/output error

same with hw:-1,-1 and hw:1,-1 .........

the same err for adding "any" to ffmpeg
although, ffplay starts "playing", but still no sound:

# ffplay -f alsa -i hw:1
Input #0, alsa, from 'hw:1':
Duration: N/A, start: 1341538864.930808, bitrate: N/A
Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s

I am looking into pulseaudio... recompiled ffmpeg with pulse support, but so far no luck... I am not giving up... more ideas PLZ!

THANKS AGAIN!
 
Old 07-05-2012, 10:07 PM   #6
paziulek
Member
 
Registered: Mar 2009
Location: N.C.
Distribution: "gentoo|debian|arch"
Posts: 106

Original Poster
Rep: Reputation: 11
this is kind of a "joke", but so far the only way of making ffmpeg encode audio and video is with the help of "mencoder":

Code:
mencoder tv:// -tv driver=v4l2:norm=1:device=/dev/video0:forceaudio:alsa:adevice=hw.1:audiorate=44100:immediatemode=0 -ovc copy -oac copy -o bridge | ffmpeg -y -i bridge -aspect 16:9 -vcodec libxvid -b 400k -acodec libmp3lame -ab 128k -ar 44100 -ac 2 aaa.mp4
I created a fifo: "bridge" and it is being fed with mencoder's output ( a simple copy for A/V ), the other side of fifo is read by ffmpeg, encoded and saved to aaa.mp4.

what a wild process... I am not calling this a "solution", just curious if this is going to work with ffserver - it should if the output will be the server's http....

still trying to find something "acceptable"

Mike
 
Old 07-06-2012, 12:01 PM   #7
ShadowCat8
Member
 
Registered: Nov 2004
Location: San Bernardino, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 261

Rep: Reputation: 52
Okay,

Then what about trying each point that ALSA sees from the DVC100 as a sound device, starting with the obvious ones? I find it hard to believe that ffmpeg can't grab the audio from this thing, but I *can easily* believe that it might take a weird "little trick" to get it. So, with that in mind, how about trying the following?
Code:
ffmpeg -y -f alsa -i /dev/snd/by-id/usb-Pinnacle_Systems_GmbH_DVC100-01 -acodec libmp3lame yet_another_try.mp3
HTH. Let us know.
 
Old 07-06-2012, 03:10 PM   #8
paziulek
Member
 
Registered: Mar 2009
Location: N.C.
Distribution: "gentoo|debian|arch"
Posts: 106

Original Poster
Rep: Reputation: 11
Hello ShadowCat8,

no go...
ALSA lib pcm.c:2212snd_pcm_open_noupdate) Unknown PCM /dev/snd/by-id/usb-Pinnacle_Systems_GmbH_DVC100-01
[alsa @ 0x24fa160] cannot open audio device /dev/snd/by-id/usb-Pinnacle_Systems_GmbH_DVC100-01 (No such file or directory)
/dev/snd/by-id/usb-Pinnacle_Systems_GmbH_DVC100-01: Input/output error

The mencoder / ffmpeg duo fails due to buffer underrun ( most likely ) when both are connected via FIFO.
I found this:
http://linux.die.net/man/1/bfr

it pre-buffers result from mencoder and pushes the data to ffmpeg, which then connects to ffserver:
Code:
 mencoder -really-quiet tv:// -tv driver=v4l2:norm=1:device=/dev/video0:forceaudio:alsa:adevice=hw.1udiorate=44100:immediatemode=0 -ovc copy -oac copy -o - | bfr -m 1 -i 50 -T 90 -b 50M  | ffmpeg -y -i - http://localhost:9999/feed1.ffm
so far I can get about 4 minutes of "live" A/V content via VLC player - than everything just stops with no err - probably another underrun or broken pipe.

...not giving up...

Last edited by paziulek; 07-06-2012 at 03:37 PM.
 
Old 07-09-2012, 12:40 PM   #9
ShadowCat8
Member
 
Registered: Nov 2004
Location: San Bernardino, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 261

Rep: Reputation: 52
Okay,

Then what about this... I see that by ALSA's standards, it found the 2 devices on the system. Let's test both of the PCM control points:
Code:
 ~ # ffmpeg -y -f alsa -i /dev/snd/pcmC1D0c -acodec libmp3lame yet_another_try.mp3
That *should* be the main PCM control device for the DVC100. Let's see what you get with that. If that doesn't get it, try:
Code:
 ~ # ffmpeg -y -f alsa -i /dev/snd/pcmC0D0c -acodec libmp3lame yet_another_try.mp3
Now, unless something got twisted around in the ALSA startup, that *should* be the Audigy card, but I'm thinking of thoroughness at this point of testing.

And, another thought occurs to me: Have you checked via alsamixer whether or not the input line from the DVC100 is actually playing and not muted? I *just* thought of that, so if that is the case, don't feel bad. But, it occurred to me that, by default, ALSA will mute any lines on startup that it doesn't directly recognize as being part of the standard configuration by it's saved state.

HTH. Let us know.

Last edited by ShadowCat8; 07-09-2012 at 12:42 PM.
 
Old 07-09-2012, 06:57 PM   #10
paziulek
Member
 
Registered: Mar 2009
Location: N.C.
Distribution: "gentoo|debian|arch"
Posts: 106

Original Poster
Rep: Reputation: 11
Hello ShadowCat8 and All!

This is the fourth day I am trying to find what is causing ffmpeg not to be able to capture audio from Pinnacle - v4l2...
mencoder has no issues, but I >>need<< to use ffmpeg along with ffserver
Although I could pipe output from mencoder to ffmpeg to ffserver via FIFO or 'bfr', but too much overhead, buffer underruns, etc....
Finally I ran 'v4lctl list' and I found out, that it is.... MUTED by default.

Code:
# v4lctl list 
attribute  | type   | current | default | comment
-----------+--------+---------+---------+-------------------------------------
norm       | choice | PAL-DK  | NTSC    | NTSC NTSC-M NTSC-M-JP NTSC-M-KR NTSC-443 PAL PAL-BG PAL-H PAL-I PAL-DK PAL-M PAL-N PAL-Nc PAL-60 SECAM SECAM-B SECAM-G SECAM-H SECAM-DK SECAM-L SECAM-Lc
input      | choice | Composi | Composi | Composite1 S-Video
bright     | int    |     128 |     128 | range is 0 => 255
contrast   | int    |      64 |      64 | range is 0 => 127
color      | int    |      64 |      64 | range is 0 => 127
hue        | int    |       0 |       0 | range is -128 => 127
volume     | int    |      31 |      31 | range is 0 => 31
mute       | bool   | on      | on      |
Chroma AGC | bool   | on      | on      |
It was not my suspicion, since:
1> alsamixer did not show MUTE, level was good
2> mencoder was able to capture without any problems, every time....
3> ffmpeg was able to capture audio ONLY if I did not include v4l2 to also get the video..... once v4l2 specified I had to re-initialize pinnacle or reboot the box ( I do it only when changing hardware or testing a kernel... and in a few other more or less odd situations, like this )

after running
# v4lctl volume mute off

ffmpeg started capturing audio and video...

Is there any way, to send a v4l2 cmd as a ffmpeg argument - similar to what mencoder does with forceaudio and immediatemode=0 or similar to 'v4lctl volume mute off' ?

Thank you for all your suggestions, input, your kindness, for being helpful!

Mike

ps: I cannot believe that this took me 4 days... it "sounds" like a bad joke


EDIT:

funny, I submitted this post before reading yours to the end... ShadowCat8.. and you did mention MUTE

Last edited by paziulek; 07-09-2012 at 07:22 PM. Reason: EDIT
 
Old 08-21-2013, 04:06 AM   #11
angoliroda
LQ Newbie
 
Registered: Aug 2013
Posts: 2

Rep: Reputation: Disabled
Please help with your solution

Hi Paziulek,

I am suffering from the same problem, it's just that in my case it's the NVidia soundcard that seems to be muted.
I would like to give a try and check following your method but I am a Linux newbie and I am not familiar with commands.
Could you pls help me as to what commands to be used to get the list to see if my soundcard (or the front mic I am trying to use) is actually muted?
Also the unmuting command would help.

Thx a lot,
Attila
 
Old 12-19-2016, 01:34 PM   #12
HarryBryant
LQ Newbie
 
Registered: Dec 2016
Posts: 2

Rep: Reputation: Disabled
Thanks for saving my day

Just a thank you from my side - this "intelligent mute" was my problem as well. I don't think I would have found that without this thread!

/Zane
 
Old 12-25-2016, 10:35 AM   #13
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
Try " -f alsa -i default ". Or " -f pulse -i default ".

Also hw:1,0 is a playback device, omit the ,0 if you want to capture. But mostly -i default works for me with the .asoundrc to be more specific.
 
Old 12-25-2016, 11:40 AM   #14
HarryBryant
LQ Newbie
 
Registered: Dec 2016
Posts: 2

Rep: Reputation: Disabled
The strange thing about the muting is that using mplayer to watch the video input will give me sound, while the recording with ffmpeg still does not have the sound.

This is how I check for the muting: I use a utility from video-for-linux (v4l). I call it like this from the command line:
v4l2ucp &
It gives me a GUI, where I can uncheck the mute.

I need to install this - the package is called v4l2ucp (Version 2.0.2-3) in my distro.

I keep this GUI open during my recording sessions. However, sometimes when I start a new recording, again there is no sound,
while the GUI still claims the sound is unmuted. In that case, I first mute and the unmute in the GUI (so basically click the "mute" box two times). This has worked fine until now - I'm tranferring old Hi8 und Digital8 tapes to my harddisk, and after the help here I have now successfully archived 20+ tapes before Xmas.

Note also that recording with ffmpeg only works if I watched video input using mplayer - not sure why it is like that, I think this will set the video input to S-Video.

/Zane
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mencoder / ffmpeg / mplayer available together ? stu7 Linux - Software 3 11-14-2009 08:02 AM
Help me in installing ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encod mitesh.ever Red Hat 5 05-16-2009 12:14 PM
ffmpeg mencoder and lavc keratos Ubuntu 2 05-17-2007 01:48 PM
ffmpeg mencoder transcode Lobais Linux - Software 3 01-09-2006 12:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration