Condivisione della tecnologia

In che modo le cuffie VR riproducono lo streaming 8K RTSP|RTMP con bassa latenza?

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

background tecnico

Quando stavamo realizzando lettori RTSP e RTMP per la piattaforma Unity, alcune aziende hanno avanzato tali requisiti tecnici, sperando di riprodurre streaming live panoramici RTSP|RTMP 8K e dati 8K sulle cuffie, cosa che ha proposto nuove idee per le cuffie e il lettore requisiti, discuteremo di come i dispositivi VR montati sulla testa riproducono dati in streaming 8K RTSP | RTMP da diversi aspetti:

1. Supporto al giocatore

  1. Compatibilità : Innanzitutto, il lettore RTSP|RTMP deve supportare lo streaming video con risoluzione 8K. Ciò significa che il lettore deve essere in grado di decodificare video 8K e riprodurli su un dispositivo di visualizzazione che supporti la risoluzione 8K. Inutile dire che lo supportiamo già.
  2. capacità di decodifica : il lettore deve disporre di potenti capacità di decodifica per gestire la grande quantità di dati nel flusso video 8K. Ciò di solito richiede che il lettore utilizzi algoritmi di decodifica efficienti e sfrutti appieno le funzioni di accelerazione hardware (come l'accelerazione GPU), che richiede che le cuffie supportino la decodifica hard 8K.

2. Requisiti di rete

  1. larghezza di banda : lo streaming video 8K richiede una larghezza di banda di rete estremamente elevata per supportare la trasmissione in tempo reale. Assicurati che la larghezza di banda della rete sia sufficientemente grande da evitare problemi come rallentamenti, ritardi o buffering durante la riproduzione. Se si tratta di un ambiente intranet, in pratica non preoccuparti dei problemi di larghezza di banda.
  2. stabilità : Anche la stabilità della connessione di rete è molto importante. Una connessione di rete instabile può causare l'interruzione dello streaming video o un peggioramento della qualità.

3. Requisiti hardware

  1. Processore e memoria: I visori VR riproducono flussi video 8K, che impongono requisiti molto elevati alle prestazioni dei visori VR. Ad esempio, quest3 è una buona scelta.

4. Passaggi di riproduzione

  1. Seleziona il lettore RTSP: Il nostro approccio consiste nell'utilizzare il lettore RTSP|RTMP nativo di Daniu Live SDK in modalità di decodifica rigida per richiamare i dati YUV o RGB decodificati all'unità. Va notato che a causa del flusso RTSP|RTMP 8K, la quantità di dati Dati molto grandi, soprattutto decodificati, è necessario ridurre le copie il meno possibile se le condizioni lo consentono.

Realizzazione tecnica

Questo articolo prende come esempio il modulo di riproduzione Unity3D RTSP|RTMP della piattaforma Android di Daniu Live SDK:

Inizia a giocare:

  1. /*
  2. * SmartPlayerAndroidMono.cs
  3. * Author: daniusdk.com
  4. * QQ:89030985
  5. */
  6. public void Play()
  7. {
  8. if (is_running)
  9. {
  10. Debug.Log("已经在播放。。");
  11. return;
  12. }
  13. //获取输入框的url
  14. string url = input_url_.text.Trim();
  15. if (!url.StartsWith("rtmp://") && !url.StartsWith("rtsp://"))
  16. {
  17. videoUrl = "rtsp://admin:[email protected]:554/h264/ch1/main/av_stream";
  18. }
  19. else
  20. {
  21. videoUrl = url;
  22. }
  23. OpenPlayer();
  24. if ( player_handle_ == 0 )
  25. return;
  26. NT_U3D_Set_Game_Object(player_handle_, game_object_);
  27. /* ++ 播放前参数配置可加在此处 ++ */
  28. int is_using_tcp = 0; //TCP/UDP模式设置
  29. NT_U3D_SetRTSPTcpMode(player_handle_, is_using_tcp);
  30. int is_report = 0;
  31. int report_interval = 1;
  32. NT_U3D_SetReportDownloadSpeed(player_handle_, is_report, report_interval); //下载速度回调
  33. NT_U3D_SetBuffer(player_handle_, play_buffer_time_); //设置buffer time
  34. NT_U3D_SetPlayerLowLatencyMode(player_handle_, is_low_latency_ ? 1 : 0); //设置是否启用低延迟模式
  35. NT_U3D_SetMute(player_handle_, is_mute_ ? 1 : 0); //是否启动播放的时候静音
  36. NT_U3D_SetAudioVolume(player_handle_, cur_audio_volume_); //设置播放音量
  37. NT_U3D_SetVideoDecoderMode(player_handle_, is_hw_decode_ ? 1 : 0); //设置H.264软硬解模式
  38. NT_U3D_SetVideoHevcDecoderMode(player_handle_, is_hw_decode_ ? 1 : 0); //设置H.265软硬解模式
  39. int is_output = 1;
  40. int disable_use_image_planes = 0;
  41. bool is_supports_texture_format = SystemInfo.SupportsTextureFormat(TextureFormat.RG16);
  42. Debug.Log("is_supports_texture_format: " + is_supports_texture_format);
  43. int is_supported_multiple_format = is_supports_texture_format? 1:0;
  44. int max_images = 3;
  45. int buffer_pool_max_size = 0;
  46. NT_U3D_SetImageReaderOutput(player_handle_, is_output, disable_use_image_planes, is_supported_multiple_format, max_images, buffer_pool_max_size); //硬解码image reader
  47. int is_fast_startup = 1;
  48. NT_U3D_SetFastStartup(player_handle_, is_fast_startup); //设置快速启动模式
  49. int rtsp_timeout = 10;
  50. NT_U3D_SetRTSPTimeout(player_handle_, rtsp_timeout); //设置RTSP超时时间
  51. int is_auto_switch_tcp_udp = 1;
  52. NT_U3D_SetRTSPAutoSwitchTcpUdp(player_handle_, is_auto_switch_tcp_udp); //设置TCP/UDP模式自动切换
  53. int is_audiotrack = 1;
  54. NT_U3D_SetAudioOutputType(player_handle_, is_audiotrack); //设置音频输出模式: if 0: 自动选择; if with 1: audiotrack模式
  55. NT_U3D_SetUrl(player_handle_, videoUrl);
  56. /* -- 播放前参数配置可加在此处 -- */
  57. int flag = NT_U3D_StartPlay(player_handle_);
  58. if (flag == DANIULIVE_RETURN_OK)
  59. {
  60. is_need_get_frame_ = true;
  61. Debug.Log("播放成功");
  62. }
  63. else
  64. {
  65. is_need_get_frame_ = false;
  66. Debug.LogError("播放失败");
  67. }
  68. is_running = true;
  69. }

La corrispondente implementazione di OpenPlayer() è la seguente:

  1. private void OpenPlayer()
  2. {
  3. if ( java_obj_cur_activity_ == null )
  4. {
  5. Debug.LogError("getApplicationContext is null");
  6. return;
  7. }
  8. player_handle_ = NT_U3D_Open();
  9. if (player_handle_ != 0)
  10. Debug.Log("open success");
  11. else
  12. Debug.LogError("open fail");
  13. }

Giocatore vicino:

  1. private void ClosePlayer()
  2. {
  3. is_need_get_frame_ = false;
  4. is_need_init_texture_ = false;
  5. int flag = NT_U3D_StopPlay(player_handle_);
  6. if (flag == DANIULIVE_RETURN_OK)
  7. {
  8. Debug.Log("停止成功");
  9. }
  10. else
  11. {
  12. Debug.LogError("停止失败");
  13. }
  14. flag = NT_U3D_Close(player_handle_);
  15. if (flag == DANIULIVE_RETURN_OK)
  16. {
  17. Debug.Log("关闭成功");
  18. }
  19. else
  20. {
  21. Debug.LogError("关闭失败");
  22. }
  23. player_handle_ = 0;
  24. NT_U3D_UnInit();
  25. is_running = false;
  26. video_format_ = VideoFrame.FORMAT_UNKNOWN;
  27. video_width_ = 0;
  28. video_height_ = 0;
  29. }

Aggiorna i dati di aggiornamento:

  1. private void Update()
  2. {
  3. if (!is_need_get_frame_)
  4. return;
  5. if (player_handle_ == 0)
  6. return;
  7. AndroidJavaObject u3d_video_frame_obj = NT_U3D_GetVideoFrame(player_handle_);
  8. if (u3d_video_frame_obj == null)
  9. {
  10. return;
  11. }
  12. VideoFrame converted_video_frame = ConvertToVideoFrame(u3d_video_frame_obj);
  13. if (converted_video_frame == null)
  14. {
  15. u3d_video_frame_obj.Call("release");
  16. u3d_video_frame_obj = null;
  17. return;
  18. }
  19. if (!is_need_init_texture_)
  20. {
  21. if (converted_video_frame.format_ != video_format_)
  22. {
  23. is_need_init_texture_ = true;
  24. }
  25. else if (converted_video_frame.width_ != video_width_
  26. || converted_video_frame.height_ != video_height_
  27. || converted_video_frame.stride0_ != y_row_bytes_
  28. || converted_video_frame.stride1_ != u_row_bytes_
  29. || converted_video_frame.stride2_ != v_row_bytes_)
  30. {
  31. is_need_init_texture_ = true;
  32. }
  33. }
  34. if (is_need_init_texture_)
  35. {
  36. if (InitYUVTexture(converted_video_frame))
  37. {
  38. is_need_init_texture_ = false;
  39. }
  40. }
  41. UpdateYUVTexture(converted_video_frame);
  42. converted_video_frame.java_frame_obj_ = null;
  43. converted_video_frame = null;
  44. u3d_video_frame_obj.Call("release");
  45. u3d_video_frame_obj = null;
  46. }

Riassumere

Se un visore VR deve riprodurre flussi 8K RTSP o RTSP, ha requisiti hardware e di rete molto elevati, quindi potrebbe incontrare alcune sfide nelle applicazioni pratiche. Attraverso test effettivi, le cuffie quest3, combinate con il nostro lettore RTSP|RTMP, possono raggiungere un ritardo di livello di millisecondo nella riproduzione di dati video 8K in Unity per soddisfare scenari di utilizzo con requisiti in tempo reale molto elevati come il controllo del bilanciamento. Gli sviluppatori interessati possono discuterne con me individualmente.