nginx-rtmp-module icon indicating copy to clipboard operation
nginx-rtmp-module copied to clipboard

How to disable audio track for HLS?

Open mosic opened this issue 9 years ago • 6 comments

Sorry if this was answered before but I couldn't find anything in the documentation about it. I'm using nginx-rtmp to convert an RTSP video stream (without audio) to RTMP and HLS and would like for them to be video only too. The main reason is that declaring an audio track and not providing it in the stream breaks some players, like Android's ExoPlayer.

This is the command I'm using for ffmpeg:

ffmpeg -rtsp_transport tcp -i {rtsp_url} -c copy -an -f flv rtmp://localhost:1935/live/{stream_id}

The -an flag ensures that no audio is present, and it works correctly with the RTMP stream:

➜  ffmpeg git:(master) ./ffmpeg -i 'rtmp://media.evercam.io:1935/live/gpocam?token=qoSoGPwrzLlE0ITuMa2Id_VbCGRYYGAfGJlVZVm_LfAOCvW2SQwtZRsyh59CV_bqKhxqjSqIivemvuey4x5kujOAmLk3fDK8pI8otoAWEcY='
ffmpeg version N-76860-g72eaf72 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
  configuration: --enable-gnutls
  libavutil      55.  9.100 / 55.  9.100
  libavcodec     57. 16.100 / 57. 16.100
  libavformat    57. 19.100 / 57. 19.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 15.100 /  6. 15.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
Input #0, flv, from 'rtmp://media.evercam.io:1935/live/gpocam?token=qoSoGPwrzLlE0ITuMa2Id_VbCGRYYGAfGJlVZVm_LfAOCvW2SQwtZRsyh59CV_bqKhxqjSqIivemvuey4x5kujOAmLk3fDK8pI8otoAWEcY=':
  Metadata:
    Server          : NGINX RTMP (github.com/arut/nginx-rtmp-module)
    displayWidth    : 1920
    displayHeight   : 1080
    fps             : 25
    profile         : 
    level           : 
  Duration: 00:00:00.00, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709), 1920x1080, 25 fps, 25 tbr, 1k tbn, 50 tbc

But the HLS still contains an audio track:

➜  ffmpeg git:(master) ./ffmpeg -i https://media.evercam.io/live/gpocam/index.m3u8?token=qoSoGPwrzLlE0ITuMa2Id_VbCGRYYGAfGJlVZVm_LfAOCvW2SQwtZRsyh59CV_bqKhxqjSqIivemvuey4x5kujOAmLk3fDK8pI8otoAWEcY=
ffmpeg version N-76860-g72eaf72 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
  configuration: --enable-gnutls
  libavutil      55.  9.100 / 55.  9.100
  libavcodec     57. 16.100 / 57. 16.100
  libavformat    57. 19.100 / 57. 19.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 15.100 /  6. 15.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
[mpegts @ 0x34e0560] Could not find codec parameters for stream 1 (Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp): unspecified sample rate
Consider increasing the value for the 'analyzeduration' and 'probesize' options
[hls,applehttp @ 0x34d9860] Could not find codec parameters for stream 1 (Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp): unspecified sample rate
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, hls,applehttp, from 'https://media.evercam.io/live/gpocam/index.m3u8?token=qoSoGPwrzLlE0ITuMa2Id_VbCGRYYGAfGJlVZVm_LfAOCvW2SQwtZRsyh59CV_bqKhxqjSqIivemvuey4x5kujOAmLk3fDK8pI8otoAWEcY=':
  Duration: N/A, start: 36.750000, bitrate: N/A
  Program 0 
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1920x1080, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1: Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp

This is the RTMP configuration I'm using in nginx.conf:

rtmp {
    server {
        listen 1935;

        chunk_size 1024;
        buflen 10ms;
        notify_method get;

        application live {
            live on;
            hls on;
            hls_path /tmp/hls;
            hls_fragment_naming system;
            hls_nested on;
            hls_cleanup on;
            on_play http://127.0.0.1:4000/on_play;

            allow publish 127.0.0.1;
        }
    }
}

Any suggestions?

mosic avatar Nov 27 '15 04:11 mosic

This is bug. TS files are written with not filled audio header. So it's almost mp3, but "broken".

sergey-dryabzhinsky avatar Dec 17 '15 01:12 sergey-dryabzhinsky

Hi!

I have the same problem, but I use DASH in my ExoPlayer based application. How can I solve this problem?

In issue @ojw28 wrote:

Please just fix the source content to not include an audio stream if it doesn't contain any audio. If it's not your content, please ask whoever is producing the content to do this

vykulakov avatar Jan 29 '16 07:01 vykulakov

@vykulakov I solved the problem for my use case by adding a silent audio track to the stream using ffmpeg: http://stackoverflow.com/questions/12368151/adding-silent-audio-to-mov-in-ffmpeg

mosic avatar Jan 29 '16 11:01 mosic

Thank you, @mosic. After adding an audio null source to the stream, ExoPlayer starts to play this stream.

vykulakov avatar Feb 01 '16 08:02 vykulakov

Hi @sergey-dryabzhinsky do you fix this bug in your branch?

Classsic avatar May 06 '16 20:05 Classsic

No. AFAIK there's no fork with this issue fixed. It needs dynamic TS segment header and it's not implemented yet in rtmp modules.

misiek08 avatar May 06 '16 20:05 misiek08