windows 如何在RTMP流媒体中嵌入pic_timing SEI挂钟时间码?

mhd8tkvw  于 2023-11-21  发布在  Windows
关注(0)|答案(2)|浏览(265)

我需要将我的桌面流传输到AWS MediaLive服务,作为要求,我必须在流中包括挂钟时间码。AWS支持好心地通知我,对于hido264编码的流,我需要以“pic_timing SEI messages”的形式提供时间码。
我在Windows 10上通过RTMP协议使用FFmpeg进行流传输,所以我尝试在命令中添加use_wallclock_as_timestampscopyts标志。

  1. ffmpeg -f gdigrab -framerate 30 -offset_x 0 -offset_y 0 -video_size 1920x1080 -show_region 1 -use_wallclock_as_timestamps 1 -i desktop -vf scale=320:240 -c:v libx264 -c:a aac -profile:v main -level 3.1 -pix_fmt yuv420p -copyts -f flv rtmp://<ip>:1935/<app>/<stream>

字符串
但是,AWS MediaLive不会提取时间码。
我的问题是:

  • use_wallclock_as_timestamps标志是否确实根据需要将时间码创建为“pic_timing SEI消息”?
  • 如果没有,我该如何添加挂钟时间码作为“pic_timing SEI messages”?不一定是每一帧,每2或3秒就足够了。

我被难住了,我在FFmpeg文档中找不到答案。
谢谢你的帮忙。

i7uq4tfw

i7uq4tfw1#

对于“pic_timing SEI messages”支持,以下用于H.264/AVC的编码器 Package 器在ffmpeg中实现了这一点:

  1. h264_qsv
  2. h264_vaapi
  3. h264_nvenc
    您可以通过以下方式确认支持:
    (a).对于h264_vaapi编码器 Package 器(仅在Linux上可用):
  1. ffmpeg -h encoder=h264_vaapi
  2. Encoder h264_vaapi [H.264/AVC (VAAPI)]:
  3. General capabilities: delay hardware
  4. Threading capabilities: none
  5. Supported hardware devices: vaapi
  6. Supported pixel formats: vaapi_vld
  7. h264_vaapi AVOptions:
  8. -low_power <boolean> E..V....... Use low-power encoding mode (only available on some platforms; may not support all encoding features) (default false)
  9. -idr_interval <int> E..V....... Distance (in I-frames) between IDR frames (from 0 to INT_MAX) (default 0)
  10. -b_depth <int> E..V....... Maximum B-frame reference depth (from 1 to INT_MAX) (default 1)
  11. -rc_mode <int> E..V....... Set rate control mode (from 0 to 6) (default auto)
  12. auto 0 E..V....... Choose mode automatically based on other parameters
  13. CQP 1 E..V....... Constant-quality
  14. CBR 2 E..V....... Constant-bitrate
  15. VBR 3 E..V....... Variable-bitrate
  16. ICQ 4 E..V....... Intelligent constant-quality
  17. QVBR 5 E..V....... Quality-defined variable-bitrate
  18. AVBR 6 E..V....... Average variable-bitrate
  19. -qp <int> E..V....... Constant QP (for P-frames; scaled by qfactor/qoffset for I/B) (from 0 to 52) (default 0)
  20. -quality <int> E..V....... Set encode quality (trades off against speed, higher is faster) (from -1 to INT_MAX) (default -1)
  21. -coder <int> E..V....... Entropy coder type (from 0 to 1) (default cabac)
  22. cavlc 0 E..V.......
  23. cabac 1 E..V.......
  24. vlc 0 E..V.......
  25. ac 1 E..V.......
  26. -aud <boolean> E..V....... Include AUD (default false)
  27. -sei <flags> E..V....... Set SEI to include (default identifier+timing+recovery_point)
  28. identifier E..V....... Include encoder version identifier
  29. timing E..V....... Include timing parameters (buffering_period and pic_timing)
  30. recovery_point E..V....... Include recovery points where appropriate
  31. -profile <int> E..V....... Set profile (profile_idc and constraint_set*_flag) (from -99 to 65535) (default -99)
  32. constrained_baseline 578 E..V.......
  33. main 77 E..V.......
  34. high 100 E..V.......
  35. -level <int> E..V....... Set level (level_idc) (from -99 to 255) (default -99)
  36. 1 10 E..V.......
  37. 1.1 11 E..V.......
  38. 1.2 12 E..V.......
  39. 1.3 13 E..V.......
  40. 2 20 E..V.......
  41. 2.1 21 E..V.......
  42. 2.2 22 E..V.......
  43. 3 30 E..V.......
  44. 3.1 31 E..V.......
  45. 3.2 32 E..V.......
  46. 4 40 E..V.......
  47. 4.1 41 E..V.......
  48. 4.2 42 E..V.......
  49. 5 50 E..V.......
  50. 5.1 51 E..V.......
  51. 5.2 52 E..V.......
  52. 6 60 E..V.......
  53. 6.1 61 E..V.......
  54. 6.2 62 E..V.......

字符串
对于VAAPI,必须将专用编解码器选项-sei:v +timing传递给h264_vaapi
(b).对于h264_qsv编码器 Package 器:

  1. ffmpeg -h encoder=h264_qsv
  2. Encoder h264_qsv [H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration)]:
  3. General capabilities: delay hybrid
  4. Threading capabilities: none
  5. Supported hardware devices: qsv qsv qsv
  6. Supported pixel formats: nv12 p010le qsv
  7. h264_qsv encoder AVOptions:
  8. -async_depth <int> E..V....... Maximum processing parallelism (from 1 to INT_MAX) (default 4)
  9. -avbr_accuracy <int> E..V....... Accuracy of the AVBR ratecontrol (from 0 to INT_MAX) (default 0)
  10. -avbr_convergence <int> E..V....... Convergence of the AVBR ratecontrol (from 0 to INT_MAX) (default 0)
  11. -preset <int> E..V....... (from 1 to 7) (default medium)
  12. veryfast 7 E..V.......
  13. faster 6 E..V.......
  14. fast 5 E..V.......
  15. medium 4 E..V.......
  16. slow 3 E..V.......
  17. slower 2 E..V.......
  18. veryslow 1 E..V.......
  19. -rdo <int> E..V....... Enable rate distortion optimization (from -1 to 1) (default -1)
  20. -max_frame_size <int> E..V....... Maximum encoded frame size in bytes (from -1 to 65535) (default -1)
  21. -max_slice_size <int> E..V....... Maximum encoded slice size in bytes (from -1 to 65535) (default -1)
  22. -bitrate_limit <int> E..V....... Toggle bitrate limitations (from -1 to 1) (default -1)
  23. -mbbrc <int> E..V....... MB level bitrate control (from -1 to 1) (default -1)
  24. -extbrc <int> E..V....... Extended bitrate control (from -1 to 1) (default -1)
  25. -adaptive_i <int> E..V....... Adaptive I-frame placement (from -1 to 1) (default -1)
  26. -adaptive_b <int> E..V....... Adaptive B-frame placement (from -1 to 1) (default -1)
  27. -b_strategy <int> E..V....... Strategy to choose between I/P/B-frames (from -1 to 1) (default -1)
  28. -forced_idr <boolean> E..V....... Forcing I frames as IDR frames (default false)
  29. -low_power <boolean> E..V....... enable low power mode(experimental: many limitations by mfx version, BRC modes, etc.) (default false)
  30. -cavlc <int> E..V....... Enable CAVLC (from 0 to 1) (default 0)
  31. -idr_interval <int> E..V....... Distance (in I-frames) between IDR frames (from 0 to INT_MAX) (default 0)
  32. -pic_timing_sei <int> E..V....... Insert picture timing SEI with pic_struct_syntax element (from 0 to 1) (default 1)
  33. -single_sei_nal_unit <int> E..V....... Put all the SEI messages into one NALU (from -1 to 1) (default -1)
  34. -max_dec_frame_buffering <int> E..V....... Maximum number of frames buffered in the DPB (from 0 to 65535) (default 0)
  35. -look_ahead <int> E..V....... Use VBR algorithm with look ahead (from 0 to 1) (default 0)
  36. -look_ahead_depth <int> E..V....... Depth of look ahead in number frames (from 0 to 100) (default 0)
  37. -look_ahead_downsampling <int> E..V....... Downscaling factor for the frames saved for the lookahead analysis (from 0 to 3) (default unknown)
  38. unknown 0 E..V.......
  39. auto 0 E..V.......
  40. off 1 E..V.......
  41. 2x 2 E..V.......
  42. 4x 3 E..V.......
  43. -int_ref_type <int> E..V....... Intra refresh type (from -1 to 65535) (default -1)
  44. none 0 E..V.......
  45. vertical 1 E..V.......
  46. -int_ref_cycle_size <int> E..V....... Number of frames in the intra refresh cycle (from -1 to 65535) (default -1)
  47. -int_ref_qp_delta <int> E..V....... QP difference for the refresh MBs (from -32768 to 32767) (default -32768)
  48. -recovery_point_sei <int> E..V....... Insert recovery point SEI messages (from -1 to 1) (default -1)
  49. -profile <int> E..V....... (from 0 to INT_MAX) (default unknown)
  50. unknown 0 E..V.......
  51. baseline 66 E..V.......
  52. main 77 E..V.......
  53. high 100 E..V.......
  54. -a53cc <int> E..V....... Use A53 Closed Captions (if available) (from 0 to 1) (default 1)
  55. -aud <int> E..V....... Insert the Access Unit Delimiter NAL (from 0 to 1) (default 0)
  56. -mfmode <int> E..V....... Multi-Frame Mode (from 0 to 2) (default auto)
  57. off 1 E..V.......
  58. auto 2 E..V.......
  59. -repeat_pps <boolean> E..V....... repeat pps for every frame (default false)


QSV编码器 Package 器需要设置专用编解码器选项-pic_timing_sei:v 1,这是默认值。通过将0传递给上述参数,可以覆盖此选项以禁用相同的选项。
(c).对于h264_nvenc,此选项为enabled by default

更新:

在HEVC方面,ffmpeg的hevc_nvenc Package 器通过私有编解码器选项-s12m_tc选项来支持它,该选项必须设置为1才能启用。这是因为正在进行的对实现HEVC的FFmpeg中增强RTMP的支持。

展开查看全部
llew8vvj

llew8vvj2#

要查看传入流是否有数据:
使用ffprobe -show_packets而不是-show_frames

  1. "side_data_list": [
  2. {
  3. "side_data_type": "Producer Reference Time",
  4. "wallclock": 104471944699,
  5. "wallclock(s)": "104471944699",
  6. "flags": 24
  7. }

字符串
要查看数据ffprobe需要一个小mod:
ffprobe.c:2364

  1. } else if (sd->type == AV_PKT_DATA_AFD && sd->size > 0) {
  2. print_int("active_format", *sd->data);
  3. } else if (sd->type == AV_PKT_DATA_PRFT && sd->size > 0) {
  4. const AVProducerReferenceTime *prop = (AVProducerReferenceTime *)sd->data;
  5. print_ts("wallclock",prop->wallclock);
  6. print_int("flags",prop->flags);


}

展开查看全部

相关问题