[FFmpeg-user] v4l TV Sound Problem

llarevo at gmx.net llarevo at gmx.net
Sun Mar 24 14:10:11 CET 2013


Hello, 

I cannot capture sound from my analog TV-Card, because the audio-input
setting is always messed up after starting ffmpeg. I played around a bit
with "arecord -D plughw:SAA7134 -f cd | aplay" and alsamixer. Doing this
I found out, that Line 2 on card 2 is the input with the TV-Sound. I can
set this input via amixer -c 1 sset 'Line',2 100%,100% unmute cap

After starting ffmpeg the Capture-Input is always set back to Video 0.
The odd thing is, that even with re-setting the capture input back to
Line 2 via amixer, the resulting mpeg is completely silent. It doesn't
record the sound after changing the input source back to the correct
Line 2. Why doesn't ffmpeg record tv sound even after correcting the
input setting?

When  "arecord -D plughw:SAA7134 -f cd | aplay" is running, I hear
immediately the selected source. It's either silent (Video 0, via amixer
-c 1 sset 'Video',0 100%,100% unmute cap) or the tv sound (Line 2, via
via amixer -c 1 sset 'Line',2 100%,100% unmute cap). When ffmpeg
records, the change of the input source has no effect.

What must I consider for capturing the TV-Sound with ffmpeg? Is there a
way to set the input of a soundcard directly via ffmepg?

Below you find the complete command lines. Any help is very appreciated.
mplayer, tvtime and mencoder work without these problems.

Thanks for any help!

Felix


Detailed Infos

Select and configure v4l-Source

v4lctl -c /dev/video0 setchannel E6
v4lctl -c /dev/video0 setnorm PAL-BG
v4lctl -c /dev/video0 setinput 0
v4lctl -c /dev/video0 setattr mute off
v4lctl -c /dev/video0 volume 15
v4lctl -c /dev/video0 setattr automute off
v4lctl -c /dev/video0 setattr "audio mode" stereo
v4lctl -c /dev/video0 show
norm: PAL-BG
input: Television
audio mode: stereo
bright: 128
contrast: 68
color: 64
hue: 0
volume: 15
mute: off
Mirror: off
Invert: off
y offset odd field: 0
y offset even field: 0
automute: off

Make TV-Card audible:

arecord -D plughw:SAA7134 -f cd | aplay

I made some experiments with alsa-mixer, from these I know, that Line 2
is the correct capture source in my case. I switch to Line 2 Input:

amixer -c 1 sset 'Line',2 100%,100% unmute cap

That succeeds, I hear the TV-sound and the input is set properly:

amixer -c1
Simple mixer control 'Line',1
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [off]
  Front Right: 20 [100%] Capture [off]
Simple mixer control 'Line',2
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [on]       <!------ OK
  Front Right: 20 [100%] Capture [on]      <!------ OK
Simple mixer control 'Video',0
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [off]
  Front Right: 20 [100%] Capture [off]

Then I stop the arecord/aplay to free the device for ffmpeg. Capture
input changed (what I do not understand): 

amixer -c1
Simple mixer control 'Line',1
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [off]
  Front Right: 20 [100%] Capture [off]
Simple mixer control 'Line',2
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [off]
  Front Right: 20 [100%] Capture [off]
Simple mixer control 'Video',0
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [on]      <!------ wrong
  Front Right: 20 [100%] Capture [on]     <!------ wrong

So I set the capture input new:
amixer -c 1 sset 'Line',2 100%,100% unmute cap

amixer -c1
Simple mixer control 'Line',1
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [off]
  Front Right: 20 [100%] Capture [off]
Simple mixer control 'Line',2
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [on]       <!------ OK
  Front Right: 20 [100%] Capture [on]      <!------ OK
Simple mixer control 'Video',0
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [off]
  Front Right: 20 [100%] Capture [off]

I start the capture

ffmpeg -loglevel debug -f alsa -i hw:SAA7134 -f video4linux2
-i /dev/video0 -flags +ilme+ildct -aspect 4/3 -target pal-dvd -y
test.mpg

After calling ffmpeg, the input changed again:

amixer -c1
Simple mixer control 'Line',1
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [off]
  Front Right: 20 [100%] Capture [off]
Simple mixer control 'Line',2
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [off]
  Front Right: 20 [100%] Capture [off]
Simple mixer control 'Video',0
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [on]      <!------ wrong
  Front Right: 20 [100%] Capture [on]     <!------ wrong

So I set the input source new:
amixer -c 1 sset 'Line',2 100%,100% unmute cap

Now the Input is correct
 amixer -c1
Simple mixer control 'Line',1
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [off]
  Front Right: 20 [100%] Capture [off]
Simple mixer control 'Line',2
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [on]       <!------ OK
  Front Right: 20 [100%] Capture [on]      <!------ OK
Simple mixer control 'Video',0
  Capabilities: volume cswitch
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 20
  Front Left: 20 [100%] Capture [off]
  Front Right: 20 [100%] Capture [off]

The capture runs, but the resulting mpeg is still complete silent,
although the setting should be OK now. The input change has no effect.





More information about the ffmpeg-user mailing list