Jump to content


Photo

AAC to AC3 transcoding

gstreamer1.0 av-receiver

  • Please log in to reply
24 replies to this topic

#1 mx3L

  • Senior Member
  • 616 posts

+79
Good

Posted 15 August 2015 - 21:44

Many AV-receivers cannot decode AAC streams when AAC passthrough is supported. This means that it's not possible to hear multichannel AAC.

To improve this situation I've created simple aactranscode gstreamer plugin which transcodes AAC to AC3 and passes it to dvbaudiosink.

 

There is no dowmixing so you've all channels in AC3 as in AAC, however price is degraded quality, since AAC and AC3 are both lossy codecs

 

How it works:

- aactranscode is sink bin which consist's of connected aac decoder, audioconvert, audioresample, ac3encoder and dvbaudiosink elements.

- aactranscode accepts only AAC caps, which means that it's selected only for AAC audio, however rank of aactranscode is lower then dvbaudiosink, so dvbaudiosink has to also not add AAC caps for aactranscode to be selected

- dvbaudiosink knows when to not include AAC caps by reading /etc/gstreamer/aactranscode file, if it contains ac3 or eac3 then AAC caps are not added

- aactranscode knows what kind of transcoding to use by reading /etc/gstreamer/aactranscode file, if it contains eac3 then AAC to E-AC3 transcoding is used else it's AAC to AC3

 

Dependencies: gstreamer1.0, gstreamer1.0-libav, (it's not possible to use gstreamer-0.10 since it's missing ac3 encoding element)

 

Installation:

1. 0001-added-aactranscode-plugin.patch is for gst-1.0 branch of gst-plugin-dvbmediasink

2. 0001-added-AAC-transcoding-support-to-AC3-EAC3.patch is for master branch of openpli-enigma2

 

3. update your machine config in openpli-oe-core:

This is mine for vusolose:

diff --git a/conf/machine/include/vuxxo2.inc b/conf/machine/include/vuxxo2.inc
index 6004c5a..c1efa1a 100644
--- a/conf/machine/include/vuxxo2.inc
+++ b/conf/machine/include/vuxxo2.inc
@@ -10,7 +10,8 @@ KERNEL_MODULE_AUTOLOAD += "xfs"

 MACHINE_EXTRA_RRECOMMENDS = " \
        vuplus-shutdown \
-       gst-plugin-dvbmediasink \
+       gstreamer1.0-libav \
+       gstreamer1.0-plugin-dvbmediasink \
        ntfs-3g \
 "

@@ -24,7 +25,8 @@ EXTRA_IMAGEDEPENDS += "\
 TARGET_ARCH = "mipsel"
 DEFAULTTUNE = "mips32el"

-DVBMEDIASINK_CONFIG = "--with-wmv --with-pcm --with-eac3"
+GST_VERSION = "1.0"
+DVBMEDIASINK_CONFIG = "--with-wmv --with-pcm --with-eac3 --with-aactranscode"

 PREFERRED_VERSION_linux-${MACHINE} = "3.13.5"

4. update gstreamer1.0-plugin-dvbmediasink recipe or use bbappend with added line

diff --git a/meta-openpli/recipes-multimedia/gstreamer/gstreamer1.0-plugin-dvbmediasink.bb b/meta-openpli/recipes-multimedia/gstreamer/gstreamer1.0-plugin-dvbmediasink.bb
index 57d7b35..b2b2e83 100644
--- a/meta-openpli/recipes-multimedia/gstreamer/gstreamer1.0-plugin-dvbmediasink.bb
+++ b/meta-openpli/recipes-multimedia/gstreamer/gstreamer1.0-plugin-dvbmediasink.bb
@@ -21,6 +21,7 @@ PKGV = "${GSTVERSION}+git${GITPKGV}"
 inherit autotools pkgconfig
 
 FILES_${PN} = "${libdir}/gstreamer-${GSTVERSION}/*.so*"
+FILES_${PN} += "${sysconfdir}/gstreamer/aactranscode"
 FILES_${PN}-dev += "${libdir}/gstreamer-${GSTVERSION}/*.la"
 FILES_${PN}-staticdev += "${libdir}/gstreamer-${GSTVERSION}/*.a"
 FILES_${PN}-dbg += "${libdir}/gstreamer-${GSTVERSION}/.debug"

Now you can build your image.

 

 

By default is AAC transcoding turned off. You can turn it on by setting Setup/System/AV settings/AAC transcode to AC3/E-AC3. In case you don't use patch for enigma2 you can turn on AAC transcoding like this:

echo -n "ac3" > /etc/gstreamer/aactranscode

For now I tested it on vusolosev2 connected via HDMI to AV receiver, cpu usage is around 10%, works good. On et4x00 it's 97% and sound was choppy, so you need fast receiver.

Attached Files


Edited by mx3L, 15 August 2015 - 21:47.


Re: AAC to AC3 transcoding #2 MastaG

  • Senior Member
  • 1,531 posts

+118
Excellent

Posted 16 August 2015 - 19:47

Thanks a lot for your work.
I'll include this in my next test build.

So if I read your first paragraph, it seems there are dvb channels featuring multi-channel audio in aac format?
And because aac multi channel audio is not very common for av receivers, we transcode it into ac3 (Dolby digital) right?

Re: AAC to AC3 transcoding #3 adri

  • Senior Member
  • 373 posts

+5
Neutral

Posted 16 August 2015 - 21:27

Why not just decode to PCM?

For software decoding/transcoding, this consumes a lot less resources and cpu.

Any receiver I know of, can accept multi-channel PCM at 48khz or higher.



Re: AAC to AC3 transcoding #4 mx3L

  • Senior Member
  • 616 posts

+79
Good

Posted 17 August 2015 - 06:08

@MastaG

Thanks,

This is only ment for gstreamer services so no support for dvb channels.

Yes, as far as I know AAC decoding is not very common amongst AV receivers but AC3 is.

 

@adri

 

Any receiver I know of, can accept multi-channel PCM at 48khz or higher.

Yes that's true, but also your stb has to have support for outputing multichannel-pcm via HDMI.

 

multichannel-pcm is possible for vusolosev2:

 

It worked for AC3,  when I played DTS or multichannel AAC I could here only stereo.

I also tried to use multichannel-pcm + decoding AAC to RAW and then there was no sound.

With AAC transcoding to AC3 now I can hear all channels for multichannel AAC.


Edited by mx3L, 17 August 2015 - 06:09.


Re: AAC to AC3 transcoding #5 kurben

  • Senior Member
  • 41 posts

+3
Neutral

Posted 2 September 2015 - 18:06

Could this be made as a Plugin?

It would be great for us that have a SoloSe V2 to have the option of converting to PCM multichannel.



Re: AAC to AC3 transcoding #6 mx3L

  • Senior Member
  • 616 posts

+79
Good

Posted 2 September 2015 - 20:13

If you mean possibility to convert AAC to AC3 it's already here, but it breaks playback of HLS streams, so it's not very usable in this state. I will post here fixed version soon.

 

If you mean outputting multichannel-pcm via HDMI, then you can enable it in vusolosev2 like this:

echo -n "enable" > /proc/stb/audio/multichannel_pcm

But it looks to be working only for multichannel AC3



Re: AAC to AC3 transcoding #7 Erik Slagter

  • PLi® Core member
  • 46,969 posts

+542
Excellent

Posted 5 September 2015 - 18:31

I don't think you will ever get this in sync with video.


* Wavefrontier T90 with 28E/23E/19E/13E via SCR switches 2 x 2 x 6 user bands
I don't read PM -> if you have something to ask or to report, do it in the forum so others can benefit. I don't take freelance jobs.
Ik lees geen PM -> als je iets te vragen of te melden hebt, doe het op het forum, zodat anderen er ook wat aan hebben.


Re: AAC to AC3 transcoding #8 pieterg

  • PLi® Core member
  • 32,766 posts

+245
Excellent

Posted 8 September 2015 - 07:32

Yes, as long as you preserve pts

Re: AAC to AC3 transcoding #9 mx3L

  • Senior Member
  • 616 posts

+79
Good

Posted 8 September 2015 - 18:43

Updated aactranscode patch:

 

- bin's elements are created only when transcoding is enabled

- aactranscode is not dependent on removal of AAC caps in dvbaudiosink -> removed all changes made in dvbaudiosink

- aactranscode is now main audiosink for AAC(rank higher then dvbaudiosink), it will be selected for AAC, but when transcoding is turned off, it will stop when going to READY state and dvbaudiosink will be selected

- always respond to caps query with AAC caps, don't delegate this to aacdecoder

- replaced avdec_aac with faad aac decoder -> fixed negotiation issues with MPEG2-AAC audio

Attached Files



Re: AAC to AC3 transcoding #10 mx3L

  • Senior Member
  • 616 posts

+79
Good

Posted 8 September 2015 - 18:45

I don't think you will ever get this in sync with video.

I don't have AV sync issues, at least on vusolose



Re: AAC to AC3 transcoding #11 MastaG

  • Senior Member
  • 1,531 posts

+118
Excellent

Posted 8 September 2015 - 23:13

Doesn't your v2 patch require changes to gstdvbaudiosink.c, like the first version?

Re: AAC to AC3 transcoding #12 mx3L

  • Senior Member
  • 616 posts

+79
Good

Posted 9 September 2015 - 12:08

No it doesn't as mentioned above:

 

- aactranscode is not dependent on removal of AAC caps in dvbaudiosink -> removed all changes made in dvbaudiosink



Re: AAC to AC3 transcoding #13 Erik Slagter

  • PLi® Core member
  • 46,969 posts

+542
Excellent

Posted 9 September 2015 - 14:28

 

I don't think you will ever get this in sync with video.

I don't have AV sync issues, at least on vusolose

I guess it works as pieterg says, the timestamps are retained. In that case there shouldn't be sync issues.


* Wavefrontier T90 with 28E/23E/19E/13E via SCR switches 2 x 2 x 6 user bands
I don't read PM -> if you have something to ask or to report, do it in the forum so others can benefit. I don't take freelance jobs.
Ik lees geen PM -> als je iets te vragen of te melden hebt, doe het op het forum, zodat anderen er ook wat aan hebben.


Re: AAC to AC3 transcoding #14 kurben

  • Senior Member
  • 41 posts

+3
Neutral

Posted 9 September 2015 - 15:08

Is it possible to install this patch seperatly or do I need to compile a new image in order to test?



Re: AAC to AC3 transcoding #15 mx3L

  • Senior Member
  • 616 posts

+79
Good

Posted 9 September 2015 - 15:28

you need to build only dvbmediasink, then you can enable transcoding like this:

echo -n "ac3" > /etc/gstreamer/aactranscode

Perhaps it would be better to not to include aactranscode in dvbmediasink, but make it as standalone plugin, so anybody can easily install it and remove it without touching dvbmediasink. I will look into it.



Re: AAC to AC3 transcoding #16 littlesat

  • PLi® Core member
  • 57,408 posts

+708
Excellent

Posted 9 September 2015 - 15:32

Why do you need soft transcode of AAC in the first place???


WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W


Re: AAC to AC3 transcoding #17 Rob van der Does

  • Senior Member
  • 7,766 posts

+184
Excellent

Posted 9 September 2015 - 16:29

Guido, that has been fully explained in post #1......

Re: AAC to AC3 transcoding #18 littlesat

  • PLi® Core member
  • 57,408 posts

+708
Excellent

Posted 9 September 2015 - 17:10

Aaaaah.... so basically a driver issue were we're trying to work-a-round.... :(


WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W


Re: AAC to AC3 transcoding #19 Rob van der Does

  • Senior Member
  • 7,766 posts

+184
Excellent

Posted 9 September 2015 - 17:43

Did you really try to read post #1?
It's about amps; most of them don't support AAC.

Re: AAC to AC3 transcoding #20 MastaG

  • Senior Member
  • 1,531 posts

+118
Excellent

Posted 10 September 2015 - 16:18

mx3L thank you for the v2 patch, I didn't read the changes because I was answering from my mobile phone.

I'm now baking new images for myself.

I'll give it a try tonight and report back.

However the most powerful receiver I own features a singlecore 701MHz mips cpu, I don't know whether this is powerful enough.

 

Another question.

There are some DVB services which feature ac3+ audio.

Not all receivers support this in their drivers due to licensing issues.

However ffmpeg can decode it.

Would it be possible to enhance your patch to pick up this stream from the dvb audio-pid and transcode it into pcm for example?




3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users