【已解决】【TuyaOS SDK】【gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf_0.0.4.zip】本地存储模块如何完成自定义的格式和逻辑?

IPC/NVR/可视门铃等具备多媒体能力的设备,扫地机/AGV等机器人设备


vincent
Posts: 12

[TuyaOS-3.9.5]咨询一下,因为我们产品已有自己的音视频逻辑,同时对接到涂鸦云,那么:

  1. 回放的播放列表是我们CVR板端存储的MP4文件;
  2. 通过相册接口可以实现缩略图、下载、下载后播放的功能,但是实现不了回放功能;
    请问:
  3. 使用MP4格式,而非涂鸦加密后的media格式,在APP playback调用会出问题吗?
  4. 请问是否有相应途径可以完成自定义回放列表的上传和播放吗?
  5. 有相关的demo参考吗?
  6. 在公版涂鸦智能上如何测试相册功能。

摘抄tuyaos开发说明(https://developer.tuya.com/cn/docs/iot- ... 1q62z79dla):
本地存储模块是否支持自定义的格式和逻辑?
涂鸦提供了标准化的存储实现,如果开发者需要有自定义的存储逻辑,如不同的目录结构、不同的文件大小和格式、不同的文件读写方案等,可以选择不启用该模块,使用自有的存储方案程序。但是需要按照标准协议对接录像回放、下载等功能。

Last edited by vincent on 2024年 Sep 2日 16:26, edited 4 times in total.

Tags:
User avatar
Passat
Posts: 55

Re: 本地存储模块如何完成自定义的格式和逻辑?

  1. 不支持在相册功能中做实时回放。
  2. MP4格式存储可以进行APP 回放,需要按照私有格式的交互顺序,返回给APP相应的数据即可。
  3. 当前的demo中,已经有和APP的回放请求处理逻辑。参考 ty_sdk_media_callback.c 中 TUYA_IPC_p2p_event_cb 的实现。
    APP进入回放时,依次向设备端下发
    ① MEDIA_STREAM_PLAYBACK_QUERY_MONTH_SIMPLIFY 查询某月内哪天存在录像,结果填入 p->day (哪天有录像,就在哪位置1)。
    ② MEDIA_STREAM_PLAYBACK_QUERY_DAY_TS 查询某天的所有录像片段的起止时间,结果填入 pquery->alarm_arr 。
    ③ MEDIA_STREAM_PLAYBACK_START_TS 开始执行回放,即从指定时间找到音视频帧数据,依次把之后的音视频数据按照要求的格式填入结构体并调用接口发送,参考 TUYA_APP_ss_pb_get_video_encrypt_cb、TUYA_APP_ss_pb_get_audio_encrypt_cb的实现,即获取到的音视频帧数据通过以上两个接口发送。
    ④ 其他命令 MEDIA_STREAM_PLAYBACK_STOP、MEDIA_STREAM_PLAYBACK_SET_SPEED、MEDIA_STREAM_PLAYBACK_RESUME、MEDIA_STREAM_PLAYBACK_PAUSE 按照逻辑需要实现即可。

以上流程如果使用非涂鸦存储的格式回放,是可以实现的,但可能需要大量的调试

vincent
Posts: 12

Re: 【求助】【TuyaOS SDK】【gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf_0.0.4.zip】本地存储模块如何完成自定义的格式和逻辑?

我知道了,晚点用这种办法实现一下,谢谢。

vincent
Posts: 12

Re: 【急急 求助】【TuyaOS SDK】【gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf_0.0.4.zip】本地存储模块如何完成自定义的格式和逻辑?

我看了下,往tuya_ipc_media_playback_send_video_frame和tuya_ipc_media_playback_send_audio_frame里面送数据应该就可以了,但是这两个接口的client参数,我不知道如何获取,看了下相关的api接口没有找到获取client的方法。

OPERATE_RET tuya_ipc_media_playback_send_video_frame(IN CONST UINT_T client, IN CONST MEDIA_VIDEO_FRAME_T *p_video_frame);

vincent
Posts: 12

Re: 【急 求助】【TuyaOS SDK】【gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf_0.0.4.zip】本地存储模块如何完成自定义的格式和逻辑?

我已经完成3-1 3-2的步骤,目前卡在3-3这里。

User avatar
Passat
Posts: 55

Re: 【急 求助】【TuyaOS SDK】【gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf_0.0.4.zip】本地存储模块如何完成自定义的格式和逻辑?

可以使用 tuya_ipc_ss_pb_start 中第一个参数作为 client 的值

vincent
Posts: 12

Re: 【急 求助】【TuyaOS SDK】【gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf_0.0.4.zip】本地存储模块如何完成自定义的格式和逻辑?

下午好,我按照你说的方式调用,但是sdk直接出现内存错误SIGSEGV,下面是相关的日志,在p2p_cmd_recv中出现的。
0240901/1725148800/1725169013.mp4]
[INFO] media_playback_release_ffmpeg(Line 242): media_playback_release_ffmpeg
[INFO] media_playback(Line 354): media_playback_open_file_ffmpeg [0][2][/mnt/sdcard//media/01/20240901/1725148800/1725168953.mp4]
[09-01 19:00:19 ty D][tuya_ipc_p2p.c:2943] recv session[65537] high cmd[7] low cmd[4] len[8] req_id[1966206]
[09-01 19:00:19 ty D][tuya_imm_service_log.c:764] trigger upload timer....
[09-01 19:00:19 ty W][tuya_ipc_p2p.c:1675] session[65537] audio already open
[09-01 19:00:19 ty D][ty_sdk_media_callback.c:128] p2p rev event cb=[44]
[09-01 19:00:19 ty D][ty_sdk_media_callback.c:527] PB idx:0 unmute
[09-01 19:00:19 ty E][tuya_ipc_ss_pb.c:1120] curr pb 0 not inited.
[09-01 19:00:19 ty D][tuya_imm_service_log.c:414] upload timer trigger....
[09-01 19:00:19 ty D][tuya_imm_service_log.c:437] start send.
[09-01 19:00:19 ty D][mqc_app.c:891] Send MQTT Msg.P:312 N:44723 Q:0
[09-01 19:00:19 ty D][tuya_svc_mqtt_client.c:427] packet id: 42
[09-01 19:00:19 ty D][tuya_ipc_p2p.c:4793] session detect run
[09-01 19:00:19 ty D][tuya_ipc_p2p.c:4771] session[65537] detect WaitCnt[4] SendCnt[0] RecvCnt[0]
MpiAdapterEncode 19:00:19-961 {ma_encode_buffer_i:1023} mpp_buffer_import fail:0xfffffffc!
wifi state = 0
MpiAdapterEncode 19:00:19-993 {ma_encode_buffer_i:1023} mpp_buffer_import fail:0xfffffffc!
MpiAdapterEncode 19:00:20-080 {ma_encode_buffer_i:1023} mpp_buffer_import fail:0xfffffffc!
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/sdcard//media/01/20240901/1725148800/1725168953.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:01:00.30, start: 0.000000, bitrate: 4483 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(yuvj420p) (pc, bt709), 1920x1080, 4179 kb/s, 24.88 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 16000 Hz, stereo, fltp, 160 kb/s (default)
Metadata:
handler_name : SoundHandler
[INFO] media_playback(Line 359): media_playback_open_file_ffmpeg
[WARNING] process_video_packet(Line 176): Video Frame:start_tick[0] pts_us[0] pts_ms[0] fps[24] client[0]
[INFO] fill_video_frame(Line 121): video_codec[5], video_frame_type[1], width[1920], height[1080], fps[24], buf_len[4147200]
--Type <RET> for more, q to quit, c to continue without paging--

Thread 149 "p2p_cmd_recv" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 1527]

vincent
Posts: 12

Re: 【急 求助】【TuyaOS SDK】【gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf_0.0.4.zip】本地存储模块如何完成自定义的格式和逻辑?

也有说报buf_len太大的

[INFO] media_playback(Line 359): media_playback_open_file_ffmpeg
wifi state = 0
[WARNING] process_video_packet(Line 176): Video Frame:start_tick[0] pts_us[0] pts_ms[0] fps[24] client[0]
[INFO] fill_video_frame(Line 121): video_codec[5], video_frame_type[1], width[1920], height[1080], fps[24], buf_len[4147200]
[09-01 18:56:13 ty E][tuya_ipc_p2p.c:1039] frame len too big[4147200]
[09-01 18:56:13 ty D][tuya_ipc_p2p.c:5354] pb video send error
[INFO] remote_control_send_atc(Line 1866): OK

另外我在调用完tuya_ipc_media_playback_send_audio_frame需不需要我来释放video_frame.p_video_buf,我尝试释放和不释放都解决不了内存错误的问题
AVFrame *frame = av_frame_alloc();
avcodec_send_packet(video_dec_ctx, packet);
while (avcodec_receive_frame(video_dec_ctx, frame) == 0) {
//uint32_t pts_in_ms = frame->pts * av_q2d(video_dec_ctx->time_base) * 1000;
CVR_WARN("Video Frame:start_tick[%d] pts_us[%ld] pts_ms[%ld] fps[%d] client[%d]\n", ffmpeg->start_tick, ffmpeg->pts_us, ffmpeg->pts_ms, fps, client);
if(client >= 0){
if(frame->pict_type == AV_PICTURE_TYPE_I){
MEDIA_VIDEO_FRAME_T video_frame = {0};
fill_video_frame(&video_frame, frame, TUYA_CODEC_VIDEO_YUV420, TUYA_VIDEO_FRAME_IFRAME, fps, ffmpeg->pts_us, ffmpeg->pts_ms);
if(video_frame.p_video_buf){
tuya_ipc_media_playback_send_video_frame(client, &video_frame);
if(video_frame.p_video_buf){
free(video_frame.p_video_buf);
video_frame.p_video_buf = NULL;
}
}
}else if(frame->pict_type == AV_PICTURE_TYPE_P){

Code: Select all

                  MEDIA_VIDEO_FRAME_T video_frame = {0};
                  fill_video_frame(&video_frame, frame, TUYA_CODEC_VIDEO_YUV420, TUYA_VIDEO_FRAME_PBFRAME, fps, ffmpeg->pts_us, ffmpeg->pts_ms);
                  if(video_frame.p_video_buf){
                      tuya_ipc_media_playback_send_video_frame(client, &video_frame);
                      if(video_frame.p_video_buf){
                              free(video_frame.p_video_buf);
                              video_frame.p_video_buf = NULL;
                      }
                  }
          }
      }
vincent
Posts: 12

Re: 【急 求助】【TuyaOS SDK】【gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf_0.0.4.zip】本地存储模块如何完成自定义的格式和逻辑?

[WARNING] process_video_packet(Line 205): Video Frame:start_tick[2748920] pts_us[648000] pts_ms[648] fps[24] client[0]
[09-02 15:18:17 ty E][tuya_ipc_p2p.c:1039] frame len too big[3110400]
[09-02 15:18:17 ty D][tuya_ipc_p2p.c:5354] pb video send error
[INFO] process_audio_packet(Line 173): Audio Frame:start_tick[2748920] pts_in_us[684000] pts_in_ms[684] client[0]
[WARNING] process_video_packet(Line 205): Video Frame:start_tick[2748920] pts_us[684000] pts_ms[684] fps[24] client[0]
[09-02 15:18:17 ty E][tuya_ipc_p2p.c:1039] frame len too big[3110400]
[09-02 15:18:17 ty D][tuya_ipc_p2p.c:5354] pb video send error
[INFO] process_audio_packet(Line 173): Audio Frame:start_tick[2748920] pts_in_us[720000] pts_in_ms[720] client[0]
[WARNING] process_video_packet(Line 205): Video Frame:start_tick[2748920] pts_us[720000] pts_ms[720] fps[24] client[0]
[09-02 15:18:17 ty E][tuya_ipc_p2p.c:1039] frame len too big[3110400]
[09-02 15:18:17 ty D][tuya_ipc_p2p.c:5354] pb video send error
[INFO] process_audio_packet(Line 173): Audio Frame:start_tick[2748920] pts_in_us[756000] pts_in_ms[756] client[0]
[WARNING] process_video_packet(Line 205): Video Frame:start_tick[2748920] pts_us[756000] pts_ms[756] fps[24] client[0]
[09-02 15:18:17 ty E][tuya_ipc_p2p.c:1039] frame len too big[3110400]
[09-02 15:18:17 ty D][tuya_ipc_p2p.c:5354] pb video send error
[INFO] process_audio_packet(Line 173): Audio Frame:start_tick[2748920] pts_in_us[792000] pts_in_ms[792] client[0]
[WARNING] process_video_packet(Line 205): Video Frame:start_tick[2748920] pts_us[792000] pts_ms[792] fps[24] client[0]
[09-02 15:18:17 ty E][tuya_ipc_p2p.c:1039] frame len too big[3110400]
[09-02 15:18:17 ty D][tuya_ipc_p2p.c:5354] pb video send error

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/sdcard//media/01/20240902/1725268127/1725268128.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Duration: 00:01:00.24, start: 0.000000, bitrate: 4467 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(yuvj420p) (pc, bt709), 1920x1080, 4164 kb/s, 24.90 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 16000 Hz, stereo, fltp, 160 kb/s (default)
Metadata:
handler_name : SoundHandler

vincent
Posts: 12

Re: 【急 求助】【TuyaOS SDK】【gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf_0.0.4.zip】本地存储模块如何完成自定义的格式和逻辑?

现在问题:日志打印我写入数据太大,这个限制大小是多大?我记得之前和我说码率是5Mbps的限制
frame len too big[3110400]
[09-02 15:18:15 ty D][tuya_ipc_p2p.c:5354] pb video send error

Post Reply