Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#3728 closed defect (invalid)

v4l TV Sound Problem: Silent Sound In Captured File

Reported by: llarevo Owned by:
Priority: normal Component: avdevice
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

When capturing from v4l, sound is silent in resulting file.

ffmpeg -y -f alsa -i hw:1 -f video4linux2 -i /dev/video0 -aspect 4/3 -format vob -target pal-dvd out.mpg

ffmpeg version 1.2.6 Copyright (c) 2000-2014 the FFmpeg developers
  built on Mar  5 2014 08:21:01 with gcc 4.8.2 (GCC) 20131212 (Red Hat 4.8.2-7)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-frei0r --enable-gnutls --enable-libass --enable-libcelt --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[alsa @ 0xb82ce0] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:0':
  Duration: N/A, start: 1403183466.432025, bitrate: 1536 kb/s
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
(... many errors, see BUG 1570)
frame=   35 fps= 25 q=4.4 Lsize=    1282kB time=00:00:01.40 bitrate=7487.4kbits/s    
video:1180kB audio:77kB subtitle:0 global headers:0kB muxing overhead 2.000036%
Received signal 2: terminating.

It seems, that ffmpeg changes the mute-level of the sound device somehow. I played around with "arecord -D plughw:SAA7134 -f cd | aplay" and alsamixer. Doing this I found out, that Line 2 on card 2 is the input-device with the TV-Sound on my TV-card. 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.

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 amixer -c 1 sset 'Line',2 100%,100% unmute cap). When ffmpeg records, the change of the input source has no effect.

Below you find the complete command lines. mplayer, tvtime and mencoder work without these problems.

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-sound-device 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]

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 finishing the above ffmpeg-command, the resulting mpeg is silent and the input changed:

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

I asked for help on this error about one year ago in ffmpeg-users: https://lists.ffmpeg.org/pipermail/ffmpeg-user/2013-March/014217.html

Change History (8)

comment:1 Changed 5 years ago by llarevo

  • Keywords v4l sound mute added

comment:2 Changed 5 years ago by cehoyos

  • Keywords v4l2 added; v4l sound mute removed

Is the problem reproducible with current FFmpeg git head?

comment:3 Changed 5 years ago by llarevo

  • Keywords v4l sound mute added; v4l2 removed

With current GIT I have a problem with alsa.

Minimum configuration

/usr/local/bin/ffmpeg -f alsa -i hw:1 -f video4linux2 -i /dev/video0 -aspect 4/3 -f vob -target pal-dvd out.mpg
ffmpeg version N-64078-g47c8d1e Copyright (c) 2000-2014 the FFmpeg developers
  built on Jun 19 2014 16:32:27 with gcc 4.8.2 (GCC) 20131212 (Red Hat 4.8.2-7)
  configuration: --prefix=/usr/local --enable-ffplay --enable-libv4l2
  libavutil      52. 89.100 / 52. 89.100
  libavcodec     55. 67.100 / 55. 67.100
  libavformat    55. 44.100 / 55. 44.100
  libavdevice    55. 13.101 / 55. 13.101
  libavfilter     4.  8.100 /  4.  8.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
Unknown input format: 'alsa'

Similar compile options as ffmpeg in fedora-package:

/usr/local/bin/ffmpeg -f alsa -i hw:1 -f video4linux2 -i /dev/video0 -aspect 4/3 -format vob -target pal-dvd out.mpg
ffmpeg version N-64078-g47c8d1e Copyright (c) 2000-2014 the FFmpeg developers
  built on Jun 19 2014 17:20:25 with gcc 4.8.2 (GCC) 20131212 (Red Hat 4.8.2-7)
  configuration: --prefix=/usr/local --bindir=/usr/local/bin --datadir=/usr/local/share/ffmpeg --incdir=/usr/local/include/ffmpeg --libdir=/usr/local/lib64 --mandir=/usr/local/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-frei0r --enable-gnutls --enable-libass --enable-libcelt --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/local/lib64 --enable-runtime-cpudetect
  libavutil      52. 89.100 / 52. 89.100
  libavcodec     55. 67.100 / 55. 67.100
  libavformat    55. 44.100 / 55. 44.100
  libavdevice    55. 13.101 / 55. 13.101
  libavfilter     4.  8.100 /  4.  8.100
  libavresample   1.  3.  0 /  1.  3.  0
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
Unknown input format: 'alsa'

Maybe I messed up the compiling procedure. In this case please give me some advice. Then I can do some further testing on request.

comment:4 Changed 5 years ago by cehoyos

  • Keywords v4l sound mute removed

Install the package alsa-lib-devel and recompile.

comment:5 Changed 5 years ago by cehoyos

If -f v4l2 -i /dev/video0 is not necessary to reproduce your problem, please remove it, it only leads to confusion.

comment:6 Changed 5 years ago by llarevo

Everything OK. After creating a test script, and using the git-verion of ffmpeg everything worked.

Sorry for this erroneous bugreport.

cehoyos: thanks a lot for guiding me again through the testing process!

comment:7 Changed 5 years ago by llarevo

  • Resolution set to worksforme
  • Status changed from new to closed

comment:8 Changed 5 years ago by Timothy_Gu

  • Resolution changed from worksforme to invalid
Note: See TracTickets for help on using tickets.