Skip to main content
Participant
August 18, 2013
Question

Packaging error 2 (The media contains invalid NALU length)

  • August 18, 2013
  • 0 replies
  • 647 views

Hi,

I am trying to publish live stream from Adobe Flash client that can be viewed on iOS device.  One known issue is that the Flash client does not support AAC audio encoder when it publishes a stream, but AAC is required for iOS viewing.  Thus I am using ffmpeg to transcode the audio to work around this issue.  The setup looks like following:

                                 Publish(h.264+Speex)      Pull               Re-Publish(h.264+AAC)

Flash Client Publisher -------------------> AMS -----> ffmpeg ---------------------> AMS

The command line I use for ffmpeg is like this:

ffmpeg -re -i rtmp://xxx.xxx.xxx.xxx/livepkgr/orgstream -c:v copy -c:a aac -strict -2 -f flv rtmp://xxx.xxx.xxx.xxx/livepkgr/livestream

This setup works perfectly if the original stream is published by Flash Media Live Encoder client.  However, if the stream is published by a web page using Flash ActionScript client, the iOS won't play the stream.  The root cause is that HLS module failed to generate the proper TS file. I get the following error in the Apache server log.

[Sat Aug 17 15:56:50 2013] [error] mod_hlshttp [500]: Packaging error 2 (The media contains invalid NALU length) when processing /hls-live/streams/livepkgr/events/_definst_/livestream/livestreamNum0.ts

I've tried various things to narrow down the possibilities regarding what could be wrong.  Here are some of my observations:

1) The problem has nothing to do with audio.  If I do audio streaming only, it works well.  So in various experiement, I simplified the problem by doing video stream only.  When using ffmpeg to transcoding, I used '-an' to disable audio stream.

2) If I use ffmpeg to save the stream into MP4 file first (say 1 minute long), and then publish that file, I got the same issue when iOS device is trying to retrieve content.  The MP4 file generated is fine though.  I can view it using VLC.

3) If I use ffmpeg to transcode H.264 to H.264 (i.e. Not to use the "copy" transcoder), it then will work.  However, because of the CPU usage constraints in my requirement, I cannot adopt this approach. Here is the command line that works:

ffmpeg -re -i rtmp://xxx.xxx.xxx.xxx/livepkgr/orgstream  -vcodec libx264 -b:v 1000k -c:a aac -strict -2 -f flv rtmp://xxx.xxx.xxx.xxx/livepkgr/livestream

4) In all those experiments, the m3u8 file are generated correctly.  In the stream directory I always saw meaningful size for f4f and f4x files.

5) The iOS client is able to view the original stream fine if the original stream is H.264 video only stream. (The 'orgstream', not the one republished by ffmpeg).

6) In all those experiements, a regular Flash viewer client is able to play the live stream with no issue.

Since I don't have access to source code to the Apache module for HLS (mod_hlshttp), I don't know how to proceed further. I appreciate any help from Adobe engineering team who have access to source code, and give me some hint what could go wrong.  I can also provide further information regarding the published stream, e.g. the generated MP4 if it can help.

Thanks and best regards,

Jason

Message was edited by: Json

This topic has been closed for replies.