datarhei / restreamer

The Restreamer is a complete streaming server solution for self-hosting. It has a visually appealing user interface and no ongoing license costs. Upload your live stream to YouTube, Twitch, Facebook, Vimeo, or other streaming solutions like Wowza. Receive video data from OBS and publish it with the RTMP and SRT server.
https://docs.datarhei.com/restreamer/
Apache License 2.0
3.78k stars 438 forks source link

add PCM to AAC transcoding #11

Closed fridge closed 6 years ago

fridge commented 8 years ago

Hi,

I run it on digitalocean vps for 5$, and video works great , but I have no sound ,

I have source with audio: PCM MU-LAW (mlaw) mono 800Hz bits per sample: 16

Can you help me? Is possible, add some transcoding or something?

svenerbeck commented 8 years ago

Hey fridge Yes this is a problem we discussed here.

We are working on a new backend and this will be an upcoming part in on of our next versions. But currently it is nott possible. You can try this with our Restreamer-Edge (https://github.com/datarhei/restreamer-edge) concept with activated transcoding. But do not foget: transcoding requires high CPU load.

fridge commented 8 years ago

Video transcoding is expensive , but I believe that the audio does not take a lot of resources.

Can you give me a hint how to modify profiles ffmpeg for my purposes?

it seems to me that I should modify the file live.json , and add the appropriate audio transcoding options.

it is the right way?

I try something like this:

{ ... "ffmpeg": { "options": { .... "native_h264_soundless_aac": [ "-f lavfi", "-i aevalsrc=0", "-vcodec copy", "-acodec aac", "-map 0:0", "-map 1:0", "-shortest", "-map_metadata -1", "-metadata application=datarhei/Restreamer", "-metadata server=NGINX-RTMP", "-f flv" ], ...,

but without success

svenerbeck commented 8 years ago

Yes, it is possible by changing the live.json. You have modify the "native_h264" and not the "h264_soundless_aac" profile because it is just selected if your stream has no audio. Your stream has audio with a "wrong" codec.

  1. Create a new live.json in /mnt/live.json with the upcoming modification:

    "ffmpeg": {
       "options": {
           "native_h264": [
               "-vcodec copy",
               "-acodec aac",
               "-f flv"
           ],
          .....
  2. Exec the container with "docker run ... -v /mnt/live.json:/restreamer/conf/live.json ....

Hope this work.

Keep on streaming Sven

AdySan commented 7 years ago

@svenerbeck wow, this took me a while to digest, but glad to report, audio is working for me. Thanks for the tips!

AdySan commented 7 years ago

@svenerbeck so, this hack works fine for a few hours, then nginx RTMP process crashed. Something to do with HLS.

 [Nginxrtmp]
[26-06-2017 16:04:58.922] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:58 [error] 34#0: *99 hls: force fragment split: -4695.648 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]
[26-06-2017 16:04:58.922] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:58 [error] 34#0: *99 hls: force fragment split: 4695.808 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]
[26-06-2017 16:04:59.043] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:59 [error] 34#0: *99 hls: force fragment split: -4695.808 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]
[26-06-2017 16:04:59.044] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:59 [error] 34#0: *99 hls: force fragment split: 4695.928 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]
[26-06-2017 16:04:59.116] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:59 [error] 34#0: *99 hls: force fragment split: -4695.928 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]
[26-06-2017 16:04:59.117] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:59 [error] 34#0: *99 hls: force fragment split: 4696.008 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]
[26-06-2017 16:04:59.321] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:59 [error] 34#0: *99 hls: force fragment split: -4696.008 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]
[26-06-2017 16:04:59.323] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:59 [error] 34#0: *99 hls: force fragment split: 4696.208 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]
[26-06-2017 16:04:59.435] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:59 [error] 34#0: *99 hls: force fragment split: -4696.208 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]
[26-06-2017 16:04:59.436] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:59 [error] 34#0: *99 hls: force fragment split: 4696.328 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]
[26-06-2017 16:04:59.517] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:59 [error] 34#0: *99 hls: force fragment split: -4696.328 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]
[26-06-2017 16:04:59.518] [ERROR] The NGINX RTMP process created an error output: 2017/06/26 14:04:59 [error] 34#0: *99 hls: force fragment split: 4696.408 sec, , client: 127.0.0.1, server: 0.0.0.0:1935
 [Nginxrtmp]

I looked up and seems like a known issue with nginx rtmp module?

https://github.com/arut/nginx-rtmp-module/issues/346 https://github.com/arut/nginx-rtmp-module/issues/568

Any pointers how to debug this further? One simple solution maybe to restart the container every few hours, but that doesn't solve the real issue