After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 615681 - [mpeg[pt]sdemux] do not support AAC LATM Stream type
[mpeg[pt]sdemux] do not support AAC LATM Stream type
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 0.10.23
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 516926 (view as bug list)
Depends on: 615740
Blocks:
 
 
Reported: 2010-04-13 20:37 UTC by Danilo Freire
Modified: 2011-05-20 18:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to add new stream type in the MPEG demux. (1.56 KB, patch)
2010-04-13 20:37 UTC, Danilo Freire
needs-work Details | Review
SBTVD Transport Stream sample file (776.00 KB, text/texmacs)
2010-04-13 21:04 UTC, Danilo Freire
  Details
make distinction between LATM/LOAS and ADTS AAC syntaxes (1.56 KB, patch)
2011-05-17 20:44 UTC, Rafael Diniz
none Details | Review
Patch handles with the distinction more properly (2.04 KB, patch)
2011-05-17 21:07 UTC, Rafael Diniz
reviewed Details | Review
Hopefully this patch correctly adds LATM/LOAS support (2.58 KB, patch)
2011-05-19 17:25 UTC, Rafael Diniz
committed Details | Review

Description Danilo Freire 2010-04-13 20:37:27 UTC
Created attachment 158644 [details] [review]
Patch to add new stream type in the MPEG demux.

The mpegdemux plugin do not identify the stream type of audio AAC-LATM (encapsulated in LATM container).

The format has the stream type of 0x11.

I created a little patch (attached) that identify this AAC stream type, and handles it as a AAC-ADTS (0x0f stream type) format.

This stream type (0x11) is defined in ISO 13818-1, and it is used by the SBTVD TV System (Brazilian Digital TV Standard).
Comment 1 Tim-Philipp Müller 2010-04-13 20:49:31 UTC
Any chance you could also make a short sample available, for our collection?
Comment 2 Danilo Freire 2010-04-13 21:04:40 UTC
Created attachment 158646 [details]
SBTVD Transport Stream sample file
Comment 3 Danilo Freire 2010-04-13 21:08:29 UTC
The attached sample file was acquired capturing the TV signal from the air.

You can try to play the stream using this pipeline:

gst-launch-0.10 filesrc location=dump.ts ! mpegtsdemux name=demux program-number=59224 ! queue  ! h264parse ! ffdec_h264 ! ffmpegcolorspace ! xvimagesink demux. ! queue ! faad ! alsasink

However, seems that the FAAD plugin do not handle well the AAC-LATM format. So, you can save the audio output in one file:

gst-launch-0.10 filesrc location=dump.ts ! mpegtsdemux name=demux program-number=59224 ! queue  ! h264parse ! ffdec_h264 ! ffmpegcolorspace ! xvimagesink demux. ! queue ! filesink location=audio.aac

And play this audio file in the Mplayer (which uses the FAAD decoder, btw).
Comment 4 Sebastian Dröge (slomo) 2010-04-14 04:58:00 UTC
Comment on attachment 158644 [details] [review]
Patch to add new stream type in the MPEG demux.

The caps for both AAC versions should be different then
Comment 5 Danilo Freire 2010-04-14 12:36:41 UTC
I agree, but the FAAD plugin for example has as its sink caps audio/mpeg version{1 ,4}; and the ffdec_aac audio/mpeg version 4 rate[] channels[].

Resuming, what should be added in the src caps of the mpegdemux? 

My suggestion:
transport{adts,latm}?

Also, looking at the FAAD plugin sourcecode, seems that it just look for the ADTS syncword (not the LATM) syncword. I will create a new bug report related to the LATM support of the FAAD plugin.
Comment 6 Danilo Freire 2010-04-14 13:12:00 UTC
A little correction in one of my previous posts. The LATM aac output file can be played by the VLC player, not the MPlayer :) sorry.

I just opened a bug about this FAAD limitation:

https://bugzilla.gnome.org/show_bug.cgi?id=615740
Comment 7 Thadeu Lima de Souza Cascardo 2011-03-15 16:08:55 UTC
I've got to make AAC LATM support from FFMPEG working with gst-ffmpeg and mpegtsdemux using a very similar patch to this one in mpegtsdemus.

The solution requires a patch applied to ffmpeg (already upstream), a fix in gst-ffmpeg already in this bug (https://bugzilla.gnome.org/show_bug.cgi?id=643591). It also needs support for AAC_LATM in gst-ffmpeg codecmap. This, however, requires that we agree between plugins what to use for caps, so auto-plugging will work.

I like the idea of using "transport={adts,latm}" or whatever aacparse uses. However, how should we proceed with the many plugins in different modules (gst-plugins-bad and gst-ffmpeg)?
Comment 8 Danilo Freire 2011-03-17 15:13:28 UTC
We have provided a proposal patch for faad plugin (https://bugzilla.gnome.org/show_bug.cgi?id=615740). But it was not accepted yet, therefore, I think that faad plugin do not handle LATM correctly yet.

I think that the best option is to define "transport={adts,latm}", and aacparse could handle it, together with faad and ffmpeg plugins.

This thread is a little "cold" right know, I really don't know if something was done related to this issue.

BR
[]s
Comment 9 Thadeu Lima de Souza Cascardo 2011-03-17 17:46:38 UTC
I have tried the proposed patch while trying to get some sound. But it didn't work for the samples I had. I have even tried some patches in the faad element myself before and after trying yours. However, with not much of a success.

But with the new ffmpeg and the patches I've suggested, it's been working for me without any problems. I'd recommend you try ffmpeg with my patch (latest git will do), gst-ffmpeg with the other patch I proposed, a patch into mpegdemux so it will create a pad with whatever caps you like and a similar patch to gst-ffmpeg to use the CODEC_ID_AAC_LATM to map to a compatible caps (do it in both gst_ffmpeg_codecid_to_caps and gst_ff_aud_caps_new).

If it works for you, than I'd be glad to discuss more what caps we should use and if there's any need to change the faad plugin so it will not autoplug into the pipeline when LATM is used.

Right now, with this setup, there's no need to use aacparse. It can be improved for sure to support LATM. But right now, it's not needed for a working pipeline.

Regards,
Cascardo.
Comment 10 Danilo Freire 2011-03-17 19:36:21 UTC
That's great. I'll try your patches, and I think that they will work for me. (you are right, our patch isnt working anymore with lastest gstreamer versions... we are trying to figure out why...)

regards
[]s
Comment 11 Rafael Diniz 2011-04-12 21:07:09 UTC
Can anyone post a set of patches that makes the playback of a SBTVD TS (H.264 + LATM/LOAS AAC) works?
I applied the proposed patches but I could never get audio from it, not even using the ffdec_aac_latm component.

Best regards,
Rafael Diniz
Comment 12 Rafael Diniz 2011-05-17 20:44:10 UTC
Created attachment 187991 [details] [review]
make distinction between LATM/LOAS and ADTS AAC syntaxes

This patch makes a distinction between the different AAC possible syntaxes: ADTS and LATM/LOAS.
LATM/LOAS is the AAC syntax used by the ISDB-Tb Digital Television standard, used in all South America and other contries.
Comment 13 Rafael Diniz 2011-05-17 21:07:02 UTC
Created attachment 187993 [details] [review]
Patch handles with the distinction more properly
Comment 14 Sebastian Dröge (slomo) 2011-05-18 11:34:19 UTC
Why "latmloas"? Isn't it just latm or are there differences? Also a patch to handle it in aacparse would be nice to have in a separate bug, but other than that this patch looks ok.
Comment 15 Rafael Diniz 2011-05-18 14:38:27 UTC
There is difference.
If you take a look at the ISO 14496-3 you will see that the LATM encapsulation goes inside the LOAS sync format. It's possible to have only LATM, but there is no practical use for this configuration.
So the correct is latmloas, as in the patch.
Comment 16 Rafael Diniz 2011-05-19 16:35:27 UTC
Looking at other frameworks may be the simpler option is to use loas as "stream-format" for LATM/LOAS AAC and just latm for LATM only AAC.
There is the possibility to use LATM alone, but not LOAS without LATM, so I think I'll use LOAS for everything that refers to LATM/LOAS AAC and let LATM be used if/when we support this AAC syntax alone.

What you people think?
Comment 17 Sebastian Dröge (slomo) 2011-05-19 17:01:24 UTC
*** Bug 516926 has been marked as a duplicate of this bug. ***
Comment 18 Sebastian Dröge (slomo) 2011-05-19 17:03:07 UTC
Review of attachment 187993 [details] [review]:

Yes, use loas only then.

::: gst/mpegdemux/gstmpegdefs.h
@@ +161,3 @@
 /* later extensions */
+#define ST_AUDIO_AAC_ADTS               0x0f
+#define ST_AUDIO_AAC_LATM               0x11

Is this always LATM/LOAS or can it be plain LATM too?

::: gst/mpegdemux/gstmpegdemux.c
@@ +355,3 @@
       template = klass->audio_template;
       name = g_strdup_printf ("audio_%02x", id);
       caps = gst_caps_new_simple ("audio/mpeg",

Shouldn't this get a different stream-format in the caps too here?
Comment 19 Rafael Diniz 2011-05-19 17:25:36 UTC
Created attachment 188156 [details] [review]
Hopefully this patch correctly adds LATM/LOAS support
Comment 20 Rafael Diniz 2011-05-19 17:26:14 UTC
That is always LATM/LOAS.
Comment 21 Sebastian Dröge (slomo) 2011-05-20 08:00:36 UTC
commit 83b5b296390838a2e151097e4665b9334cfff1fc
Author: Rafael Diniz <rafael@riseup.net>
Date:   Fri May 20 09:58:50 2011 +0200

    mpeg[pt]sdemux: Add support for AAC LATM/LOAS streams
    
    Fixes bug #615681.



Now support for this is only missing in aacparse and the decoders :)
Comment 22 Rafael Diniz 2011-05-20 18:01:33 UTC
great!

I think the most important module to be aware of this support is the ffdec_aac_latm that is the only piece of software that does support latm/loas inside gstreamer right now.
There is a patch that implements latm/loas support for faad2, but the it was not applied yet.