ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
24.7k stars 5.28k forks source link

RTMP2RTC: Transcode AAC to Opus failed using GoPro Hero12 Black. #4090

Open bencyjiang opened 2 weeks ago

bencyjiang commented 2 weeks ago

SRS version: 5.0.210

srs.conf:

listen              1935;
max_connections     1000;
#srs_log_tank        file;
#srs_log_file        ./objs/srs.log;
daemon              on;
http_api {
    enabled         on;
    listen          1985;
}
http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}
rtc_server {
    enabled on;
    listen 8000; # UDP port
    #tcp {
    #    enabled on;
    #    listen: 8000;
    #}
    #protocol tcp;
    # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
    candidate $CANDIDATE;
}
vhost __defaultVhost__ {
    tcp_nodelay on;
    min_latency on;
    hls {
        enabled         on;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
    rtc {
        enabled     on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
        rtmp_to_rtc on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
        rtc_to_rtmp on;
        stun_timeout 5;
        #opus_bitrate 32000;
        #drop_for_pt 10;
    }

    play{
        gop_cache_max_frames 2500;
    }
}

Error message:

[2024-06-13 10:52:50.134][Error][8746][g95132d3][11] Prediction is not allowed in AAC-LC.(Resource temporarily unavailable)
[2024-06-13 10:52:50.134][Trace][8746][g95132d3] cleanup when unpublish
[2024-06-13 10:52:50.135][Trace][8746][g95132d3] cleanup when unpublish, created=1, deliver=1
[2024-06-13 10:52:50.135][Warn][8746][g95132d3][4] 1 frames left in the queue on closing
[2024-06-13 10:52:50.135][Trace][8746][g95132d3] TCP: before dispose resource(RtmpConn)(0x563858cd7cc0), conns=1, zombies=0, ign=0, inz=0, ind=0
[2024-06-13 10:52:50.135][Error][8746][g95132d3][4] serve error code=5011 : service cycle : rtmp: stream service : rtmp: receive thread : handle publish message : rtmp: consume message : rtmp: consume audio : bridger consume audio : recode error : decode and resample : submit to dec(-1094995529,Invalid data found when processing input)
thread [8746][g95132d3]: do_cycle() [src/app/srs_app_rtmp_conn.cpp:217][errno=4]
thread [8746][g95132d3]: service_cycle() [src/app/srs_app_rtmp_conn.cpp:414][errno=4]
thread [8746][g95132d3]: do_publishing() [src/app/srs_app_rtmp_conn.cpp:910][errno=11]
thread [8746][g95132d3]: consume() [src/app/srs_app_recv_thread.cpp:380][errno=11]
thread [8746][g95132d3]: handle_publish_message() [src/app/srs_app_rtmp_conn.cpp:1037][errno=11]
thread [8746][g95132d3]: process_publish_message() [src/app/srs_app_rtmp_conn.cpp:1058][errno=11]
thread [8746][g95132d3]: on_audio_imp() [src/app/srs_app_source.cpp:2223][errno=11]
thread [8746][g95132d3]: transcode() [src/app/srs_app_rtc_source.cpp:873][errno=11]
thread [8746][g95132d3]: transcode() [src/app/srs_app_rtc_codec.cpp:161][errno=11]
thread [8746][g95132d3]: decode_and_resample() [src/app/srs_app_rtc_codec.cpp:334][errno=11](Interrupted system call)

TRANS_BY_GPT4

bencyjiang commented 2 weeks ago

Stream from GoPro Hero12 Black using RTMP to an Nginx server, and then utilize FFmpeg to relay the stream to an SRS (Simple Real-time Streaming) server successfully.

ffmpeg -i rtmp://192.168.1.106:19350/live/abc -c copy -f flv rtmp://192.168.1.134:1935/live/abc
ffmpeg version 2021-08-01-git-1f58503013-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.3.0 (Rev5, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57.  3.100 / 57.  3.100
  libavcodec     59.  3.102 / 59.  3.102
  libavformat    59.  4.101 / 59.  4.101
  libavdevice    59.  0.100 / 59.  0.100
  libavfilter     8.  1.103 /  8.  1.103
  libswscale      6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Input #0, flv, from 'rtmp://192.168.1.106:19350/live/abc':
  Metadata:
    |RtmpSampleAccess: true
    Server          : NGINX HTTP-FLV (https://github.com/winshining/nginx-http-flv-module)
    displayWidth    : 1920
    displayHeight   : 1080
    fps             : 0
    profile         :
    level           :
  Duration: 00:00:00.00, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 2560 kb/s, 29.97 fps, 29.97 tbr, 1k tbn
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 131 kb/s
Output #0, flv, to 'rtmp://192.168.1.134:1935/live/abc':
  Metadata:
    |RtmpSampleAccess: true
    Server          : NGINX HTTP-FLV (https://github.com/winshining/nginx-http-flv-module)
    displayWidth    : 1920
    displayHeight   : 1080
    fps             : 0
    profile         :
    level           :
    encoder         : Lavf59.4.101
  Stream #0:0: Video: h264 (High) ([7][0][0][0] / 0x0007), yuvj420p(pc, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 2560 kb/s, 29.97 fps, 29.97 tbr, 1k tbn
  Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 48000 Hz, stereo, fltp, 131 kb/s

TRANS_BY_GPT4

suzp1984 commented 1 week ago

Error happened when transcode AAC to opus, so the original media sources are need to help target the problem. You can recored the rtmp stream to video file by this cmd: (use the original rtmp stream, not the stream transformed by nginx-rtmp-module.

ffmpeg -i rtmp://your_srs_server/live/abc -c copy -f flv video.flv

Post the recorded video file here, then I can check whether this issue can be reproduced or not.

bencyjiang commented 1 week ago

@suzp1984 Disable the RTMP to WebRTC conversion, and use only RTMP. ffmpeg -i rtmp://192.168.1.134:1935/live/abc -c copy -f flv video.flv

get file:

https://github.com/ossrs/srs/assets/10540128/75ad03d3-1260-4248-9b53-29bf454ae03b

TRANS_BY_GPT4

suzp1984 commented 1 week ago

@suzp1984 Disable the RTMP to WebRTC conversion, and use only RTMP. ffmpeg -i rtmp://192.168.1.134:1935/live/abc -c copy -f flv video.flv

get file:

video.mp4 TRANS_BY_GPT4

this video seems unable to download, above ffmpeg record a flv file, why this is a mp4 one.

bencyjiang commented 1 week ago

@suzp1984 I changed the file extension of "video.flv" to "video.mp4" because this platform does not allow the upload of FLV files. The original file is indeed a FLV file. I will send a compressed version of the file. video.zip

TRANS_BY_GPT4

suzp1984 commented 1 week ago

@suzp1984 I changed the file extension of "video.flv" to "video.mp4" because this platform does not allow the upload of FLV files. The original file is indeed a FLV file. I will send a compressed version of the file. video.zip

TRANS_BY_GPT4

I click the video.zip, it said Not found. I once used 3rd cloud storage service like google drive to share.

bencyjiang commented 1 week ago

video.zip

@suzp1984

suzp1984 commented 1 week ago

the video.zip can be download now, but I can't reproduce this problem by using the srs config at the top.

Here is my ffprobe output: ffprobe video.flv

ffprobe output > Input #0, flv, from 'video.flv': > Metadata: > |RtmpSampleAccess: true > creator : GoPro Hero > server : SRS/5.0.210(Bee) > server_version : 5.0.210 > encoder : Lavf59.4.101 > Duration: 00:00:19.89, start: 0.032000, bitrate: 2574 kb/s > Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 2560 kb/s, 29.97 fps, 29.97 tbr, 1k tbn > Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 131 kb/s

So the recorded flv can't reproduce it, so maybe a Gopro hardware needed to reproduce it.