[gst-devel] MPEG-2 TS Muxing

Julien Moutte julien at moutte.net
Thu Mar 26 10:08:32 CET 2009


Hi,

flutsmux is running the prepare_aac function only if the incoming AAC
data is RAW AAC with an AudioSpecificConfig buffer set on the caps as
codec_data.

So if your faac encoder generates raw AAC with a codec data this
function will be called. If it generates AAC with ADTS headers it won't
be called.

This muxer works just fine and we are using it in various environments.

I think you need to investigate the AAC encoder to see what it generates
exactly.

Best regards,

Julien Moutte,
FLUENDO S.A.

Kshitij Gupta wrote:
> Hi,
>   I was able to solve the problem in the follwing way.  The aac
> encoder must produce an adts output stream for this way to work,
> 1. Modify the mpegtsmux_aac.c to not insert adts header on it's own
> 
> GstBuffer * flutsmux_prepare_aac (GstBuffer * buf, FluTsPadData * data,
>     FluTsMux * mux)
> {
>   //guint8 * adts_header = g_malloc0 (7);
>   //GstBuffer * out_buf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buf) + 7);
>   GstBuffer * out_buf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buf));
>   gsize out_offset = 0;
>   guint8 rate_idx = 0, channels = 0, obj_type = 0;
> 
>   GST_DEBUG_OBJECT (mux, "Preparing AAC buffer for output");
> 
>   /* We want the same metadata */
>   gst_buffer_copy_metadata (out_buf, buf, GST_BUFFER_COPY_ALL);
> 
> #if 0
>   /* Generate ADTS header */
>   obj_type = (GST_READ_UINT8 (GST_BUFFER_DATA (data->codec_data)) & 0xC) >> 2;
>   obj_type++;
>   rate_idx = (GST_READ_UINT8 (GST_BUFFER_DATA (data->codec_data)) & 0x3) << 1;
>   rate_idx |=
>       (GST_READ_UINT8 (GST_BUFFER_DATA (data->codec_data) + 1) & 0x80) >> 7;
>   channels =
>       (GST_READ_UINT8 (GST_BUFFER_DATA (data->codec_data) + 1) & 0x78) >> 3;
>   GST_DEBUG_OBJECT (mux, "Rate index %u, channels %u, object type %u", rate_idx,
>       channels, obj_type);
>   /* Sync point over a full byte */
>   adts_header[0] = 0xFF;
>   /* Sync point continued over first 4 bits + static 4 bits
>    * (ID, layer, protection)*/
>   adts_header[1] = 0xF1;
>   /* Object type over first 2 bits */
>   adts_header[2] = obj_type << 6;
>   /* rate index over next 4 bits */
>   adts_header[2] |= (rate_idx << 2);
>   /* channels over last 2 bits */
>   adts_header[2] |= (channels & 0x4) >> 2;
>   /* channels continued over next 2 bits + 4 bits at zero */
>   adts_header[3] = (channels & 0x3) << 6;
>   /* frame size over last 2 bits */
>   adts_header[3] |= (GST_BUFFER_SIZE (out_buf) & 0x1800) >> 11;
>   /* frame size continued over full byte */
>   adts_header[4] = (GST_BUFFER_SIZE (out_buf) & 0x1FF8) >> 3;
>   /* frame size continued first 3 bits */
>   adts_header[5] = (GST_BUFFER_SIZE (out_buf) & 0x7) << 5;
>   /* buffer fullness (0x7FF for VBR) over 5 last bits*/
>   adts_header[5] |= 0x1F;
>   /* buffer fullness (0x7FF for VBR) continued over 6 first bits + 2 zeros for
>    * number of raw data blocks */
>   adts_header[6] = 0xFC;
>   /* Insert ADTS header */
>   memcpy (GST_BUFFER_DATA (out_buf) + out_offset, adts_header, 7);
>   g_free (adts_header);
>   out_offset += 7;
> #endif
> 
>   /* Now copy complete frame */
>   //memcpy (GST_BUFFER_DATA (out_buf) + out_offset, GST_BUFFER_DATA
> (buf), GST_BUFFER_SIZE (buf));
>   memcpy (GST_BUFFER_DATA (out_buf) , GST_BUFFER_DATA (buf),
> GST_BUFFER_SIZE (buf));
> 
>   return out_buf;
> }
> 
> The above code snippet is from flumpegtsmux_aac.c which is exactly
> same as  mpegtsmux_aac.c except the variable names etc.
> 
> regards
> Kshitij
> 
> On Fri, Mar 20, 2009 at 8:54 AM, yangsb <yangsb05 at gmail.com> wrote:
>> I meet the same problem as you.
>> Also , I tried the tsmuxer in gst-plugin-bad-0.10.9 ,but still no audio.
>> Hope to get some advice.
>> Thanks
>> Best regards.
>>
>>
>> Kshitij Gupta-2 wrote:
>>> Hi,
>>>    I am trying a similar gst pipeline to transcode a file in mp2ts file
>>> format with h264 and aac as codecs. Using the following pipeline
>>>
>>> gst-launch -v filesrc location=/home/kgupta/testflv/limca.flv ! decodebin
>>> name=d ! queue ! videorate ! ffmpegcolorspace ! videoscale !
>>> video/x-raw-yuv,height=144,width=176,framerate=\(fraction\)15/1 !
>>> ffenc_h264
>>> ! flutsmux name=mux ! filesink location=limca_aac_h264_faacadts.ts d. !
>>> queue ! audioconvert ! audioresample ! audio/x-raw-int, endianness=1234,
>>> signed=\(boolean\)true, width=\(int\)16, depth=\(int\)16,
>>> rate=\(int\)16000,channels=\(int\)1 ! faac bitrate=16000 ! mux.
>>>
>>> Now I am trying to play this file with vlc.  The video plays good but no
>>> audio.  Are there some obvious mistakes in my approach ??
>>>
>>> I am using the following versions
>>> gst-fluendo-mpegmux-0.10.4
>>> libtsmux-0.3.0
>>>
>>> Thanx
>>> Kshitij
>>>
>>> On Fri, May 30, 2008 at 2:34 PM, Peter Maersk-Moller <
>>> peter at maersk-moller.net> wrote:
>>>
>>>> Just a little remark for others wanting to test or hack. This command
>>>> will get you the lot.
>>>>
>>>>   svn co https://core.fluendo.com/gstreamer/svn/trunk
>>>>
>>>> Thanks
>>>>
>>>> Peter Maersk-Moller
>>>>
>>>> Julien Moutte wrote:
>>>>> Fluendo has a MPEG TS muxer. We recently introduced support M2TS 192.
>>>>> https://core.fluendo.com/gstreamer/svn/trunk/gst-fluendo-mpegmux/
>>>>>
>>>>> Best regards,
>>>>>
>>>>> Julien Moutte,
>>>>> FLUENDO S.A.
>>>>>
>>>>> Peter Maersk-Moller wrote:
>>>>>> Hi
>>>>>>
>>>>>> Trying to see if I can get gstreamer to encode a a/v source into a
>>>>>> H.264/aac MPEG-2 TS stream. A/V encoding seems to work well, but the
>>>> TS
>>>>>> encoding part seems not to be supported.
>>>>>>
>>>>>> I'm looking into copy some code from VLC to create a TS mux plugin,
>>>> but
>>>>>> would like to ask first,  if anyone else is working on something like
>>>>>> that ? As I see it, we need to convert the two ES streams into to PES
>>>>>> packet stream into a TS packet stream, which then could use either a
>>>> UDP
>>>>>> output plugin, a http server plugin (when finished) or a RTSP server
>>>>>> plugin (if planned). So ES in PES in TS is needed. ES in PES in TS in
>>>>>> RTP seems not to be widely used, so thsi is skipped.
>>>>>>
>>>>>> However, we would also need to create PAT and PMT to make the stream
>>>>>> useful for many applications (such as Set Top Boxes not quite as
>>>> clever
>>>>>> as Mplayer).
>>>>>>
>>>>>> Best regards
>>>>>>
>>>>>> Peter Maersk-Moller
>>>>>>
>>>>>>
>>>> -------------------------------------------------------------------------
>>>>>> This SF.net email is sponsored by: Microsoft
>>>>>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>>>>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>>>>>> _______________________________________________
>>>>>> gstreamer-devel mailing list
>>>>>> gstreamer-devel at lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>>>
>>>> -------------------------------------------------------------------------
>>>> This SF.net email is sponsored by: Microsoft
>>>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>>>> _______________________________________________
>>>> gstreamer-devel mailing list
>>>> gstreamer-devel at lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>>>
>>> -------------------------------------------------------------------------
>>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>>> challenge
>>> Build the coolest Linux based applications with Moblin SDK & win great
>>> prizes
>>> Grand prize is a trip for two to an Open Source event anywhere in the
>>> world
>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>> _______________________________________________
>>> gstreamer-devel mailing list
>>> gstreamer-devel at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>>
>>>
>> --
>> View this message in context: http://www.nabble.com/MPEG-2-TS-Muxing-tp17485498p22613710.html
>> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
>> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
>> software that enables intelligent coding and step-through debugging.
>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>>
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel




More information about the gstreamer-devel mailing list