You are not logged in.

#1 2013-01-07 17:36:30

plenus
Member
Registered: 2012-04-19
Posts: 25

Can't encode to AC3 while playing - libavcodec or mplayer problem?

I have a setup where my receiver can decode only AC3 from a SPDIF cable. So, whenever I want to play something with more the 2 channels of audio, I must encode it to AC3 and then send the stream to a coaxial cable.

That arrangement used to work just fine, but lately it has just broken. I can't encode to AC3 on the fly, either by sending mpllayer output to the Alsa utils' a52 filter (1) or using the mplayer lavcac3enc filter (2). Both complain about the format of the audio stream.

1) hometheater is an alsa device that uses libavcodec to encode a stream to AC3 and then send it to spdif;

# cat .asoundrc
pcm.a52encode {
        type a52
        format S16_LE
        channels 6
        rate 48000
        bitrate 448
        card "Intel"
}

pcm.hometheater {
        type plug
        slave.pcm "a52encode"
        slave.channels 6
}

$ mplayer -ao alsa:device=alsa:device=hometheater -channels 6 space_battle.wav
MPlayer SVN-r35421-4.7.2 (C) 2000-2012 MPlayer Team
199 audio & 415 video codecs
Playing space_battle.wav.
libavformat version 54.36.100 (internal)
Audio only file format detected.
Load subtitles in ./
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 6 ch, s16le, 4233.6 kbit/100.00% (ratio: 529200->529200)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
[ac3_fixed @ 0x1015300]Specified sample format s16 is invalid or not supported
[AO_ALSA] Unable to set hw-parameters: Invalid argument
Failed to initialize audio driver 'alsa:device=alsa:device=hometheater'
Could not open/initialize audio device -> no sound.

2) Now, a version using mplayer to encode to AC3 and directly send the stream to spdif

$ mplayer -ao alsa:device=iec958=Intel -channels 6 -af lavcac3enc space_battle.wav
MPlayer SVN-r35421-4.7.2 (C) 2000-2012 MPlayer Team
199 audio & 415 video codecs
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing space_battle.wav.
libavformat version 54.36.100 (internal)
Audio only file format detected.
Load subtitles in ./
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 6 ch, s16le, 4233.6 kbit/100.00% (ratio: 529200->529200)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
libavcodec version 54.71.100 (internal)
[ac3_fixed @ 0x1015300]Specified sample format s16 is invalid or not supported
Couldn't open codec ac3, br=448000.
[libaf] Reinitialization did not work, audio filter 'lavcac3enc' returned error code -2
Error at audio filter chain pre-init!

3) When testing with speaker-test, the alsa filter works, and I can hear of separate channels from the AC3 encoded stream on my hometheater. So, the libavcodec seems to be working, but somehow mplayer doesn't set the format correctly anymore?

$ speaker-test -Dhometheater -c6 -twav

speaker-test 1.0.26

Playback device is hometheater
Stream parameters are 48000Hz, S16_LE, 6 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 3072 to 1047552
Period size range from 1536 to 1536
Using max buffer size 1047552
Periods = 4
was set period_size = 1536
was set buffer_size = 1047552
0 - Front Left
4 - Center
1 - Front Right
3 - Rear Right
2 - Rear Left
5 - LFE

Any ideas?

Offline

#2 2013-02-18 02:56:26

udakak
Member
Registered: 2013-02-18
Posts: 1

Re: Can't encode to AC3 while playing - libavcodec or mplayer problem?

I seem to have a similar problem...
With mplayer I get pretty much the same error messages, but I also get them using speaker-test:

$ speaker-test 

speaker-test 1.0.26

Wiedergabe-Gerät ist default
Stream-Parameter sind 48000 Hz, S16_LE, 1 Kanäle
Verwende 16 Oktaven rosa Rauschen
Rate ist 48000 Hz (angefordert: 48000 Hz)
Puffergröße von 3072 bis 261120
Periodengröße von 1536 bis 1536
Verwende maximale Puffergröße 261120
Perioden = 4
[ac3_fixed @ 0x18daf20] Specified sample format s16 is invalid or not supported
Fehler beim Setzen der Hardware-Parameter: Das Argument ist ungültig
Fehler beim Setzen der Hardware-Parameter: Das Argument ist ungültig

sorry, most of it is in german, but the error message is the same one mplayer gives me.
since I'm getting the error with speaker-test too I don't think mplayer is the problem...

hopefully someone can help us

Offline

#3 2013-03-18 21:16:03

shamot
Member
Registered: 2013-03-18
Posts: 3

Re: Can't encode to AC3 while playing - libavcodec or mplayer problem?

I had similar issue. I found that latest ffmpeg 1:1.1.3-1 has some issue with libavcodec which is required by a52 plugin. I was unable to use a52 sink with newest libavcodec. It always failed with message:

Specified sample format s16 is invalid or not supported

I downgraded ffmpeg to previous version and it works just fine. I had to downgrade x264 as well because of library dependency. Ffmpeg package is currently marked as out-dated, I hope new package will fix this issue.

Offline

#4 2013-03-22 03:14:52

plenus
Member
Registered: 2012-04-19
Posts: 25

Re: Can't encode to AC3 while playing - libavcodec or mplayer problem?

shamot wrote:

I downgraded ffmpeg to previous version and it works just fine. I had to downgrade x264 as well because of library dependency. Ffmpeg package is currently marked as out-dated, I hope new package will fix this issue.

How can you downgrade those packages? Would you hint at the steps?

Offline

#5 2013-03-22 04:23:50

cookies
Member
Registered: 2013-01-17
Posts: 253

Re: Can't encode to AC3 while playing - libavcodec or mplayer problem?

Offline

#6 2013-03-22 08:48:47

shamot
Member
Registered: 2013-03-18
Posts: 3

Re: Can't encode to AC3 while playing - libavcodec or mplayer problem?

plenus wrote:
shamot wrote:

I downgraded ffmpeg to previous version and it works just fine. I had to downgrade x264 as well because of library dependency. Ffmpeg package is currently marked as out-dated, I hope new package will fix this issue.

How can you downgrade those packages? Would you hint at the steps?

I had both ffmpeg and x264 in my package cache in /var/cache/pacman/pkg. I just run pacman -U /path/to/package as suggested on wiki above.

Offline

Board footer

Powered by FluxBB