当前位置: 首页 > news >正文

微信商城怎么开店廊坊网站seo

微信商城怎么开店,廊坊网站seo,项目拉新平台,江门外贸网站建设【1】需求 需求:有一个 “00:01:33.90” 这样格式的时间字符串,需要将这个字符串的时间值提取打印出来(提取时、分、秒、毫秒)。 这个时间字符串从哪里来的? 是ffmpeg返回的时间,也就是视频的总时间。 下…

【1】需求

需求:有一个 “00:01:33.90” 这样格式的时间字符串,需要将这个字符串的时间值提取打印出来(提取时、分、秒、毫秒)。

这个时间字符串从哪里来的? 是ffmpeg返回的时间,也就是视频的总时间。

image-20230815134021328

下面是ffmpeg获取视频总时间的输出。

C:\Users\11266>ffmpeg -i D:/123.mp4
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developersbuilt with gcc 9.2.1 (GCC) 20200122configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmptlibavutil      56. 31.100 / 56. 31.100libavcodec     58. 54.100 / 58. 54.100libavformat    58. 29.100 / 58. 29.100libavdevice    58.  8.100 / 58.  8.100libavfilter     7. 57.100 /  7. 57.100libswscale      5.  5.100 /  5.  5.100libswresample   3.  5.100 /  3.  5.100libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:/123.mp4':Metadata:major_brand     : mp42minor_version   : 0compatible_brands: mp42isomcreation_time   : 2015-04-30T02:43:22.000000ZDuration: 00:01:33.90, start: 0.000000, bitrate: 715 kb/sStream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 88200 Hz, stereo, fltp, 127 kb/s (default)Metadata:creation_time   : 2015-04-30T02:43:22.000000Zhandler_name    : GPAC ISO Audio HandlerStream #0:1(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 582 kb/s, 15 fps, 25 tbr, 30k tbn, 20000k tbc (default)Metadata:creation_time   : 2015-04-30T02:43:23.000000Zhandler_name    : GPAC ISO Video Handler

这串数据里 Duration: 00:01:33.90, start: 0.000000, bitrate: 715 kb/s,我们要提取00:01:33.90这串时间字符串出来,这个时间字符串就是当前视频的总时间。

下面是时间字符串提取代码,C语言代码:

char TotalTime[100];//解析数据
char *p = strstr(utf8_str.data(), "Duration:");
if (p)
{int i = 0;p += 9;while (*p != '\0' && *p != NULL && *p != ','){if (i > 90)break; //防止越界TotalTime[i++] = *p++;}TotalTime[i++] = '\0';
}qDebug() << "TotalTime:" << TotalTime;

下面的2个例子介绍如何提取时、分、秒、毫秒的时间,打印出来。

【2】C语言实现

#include <stdio.h>
#include <stdlib.h>
#include <string.h>void extractTime(const char* time_str, int* hour, int* minute, int* second, int* msec) {char* token;char* str;char* saveptr;// 复制时间字符串到临时缓冲区str = strdup(time_str);// 分割字符串,以":"为分隔符token = strtok_s(str, ":", &saveptr);// 提取小时部分if (token != NULL) {*hour = atoi(token);} else {*hour = 0;}// 分割剩余部分,以":"为分隔符token = strtok_s(NULL, ":", &saveptr);// 提取分钟部分if (token != NULL) {*minute = atoi(token);} else {*minute = 0;}// 分割剩余部分,以"."为分隔符token = strtok_s(NULL, ".", &saveptr);// 提取秒部分if (token != NULL) {*second = atoi(token);} else {*second = 0;}// 提取毫秒部分token = strtok_s(NULL, "", &saveptr);if (token != NULL) {*msec = atoi(token);} else {*msec = 0;}// 释放临时缓冲区内存free(str);
}int main() {const char* time_str = "00:01:33.90";int hour, minute, second, msec;extractTime(time_str, &hour, &minute, &second, &msec);printf("hour: %d\n", hour);printf("minute: %d\n", minute);printf("second: %d\n", second);printf("millisecond: %d\n", msec);return 0;
}

在这段代码中,实现了一个名为extractTime的函数,将时间字符串作为输入,并通过指针参数返回小时、分钟、秒和毫秒的值。使用strtok_s函数以":“和”."为分隔符逐个提取时间字符串的各部分,并将其转换为整数值。

在使用strtok_s函数时,将剩余部分分隔的分隔符设为"",以便可以正确提取毫秒部分。

【3】Qt正则表达式提取

#include <QCoreApplication>
#include <QString>
#include <QRegularExpression>
#include <QDebug>void extractTime(const QString& timeStr, int* hour, int* minute, int* second, int* msec)
{QRegularExpression regex("(\\d+):(\\d+):(\\d+)\\.(\\d+)");QRegularExpressionMatch match = regex.match(timeStr);if (match.hasMatch()) {*hour = match.captured(1).toInt();*minute = match.captured(2).toInt();*second = match.captured(3).toInt();*msec = match.captured(4).toInt();} else {*hour = 0;*minute = 0;*second = 0;*msec = 0;}
}int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);QString timeStr = "00:01:33.90";int hour, minute, second, msec;extractTime(timeStr, &hour, &minute, &second, &msec);qDebug() << "hour:" << hour;qDebug() << "minute:" << minute;qDebug() << "second:" << second;qDebug() << "millisecond:" << msec;return a.exec();
}

在代码中,实现了一个名为extractTime的函数,接收一个时间字符串,通过指针参数返回小时、分钟、秒和毫秒的值。使用QRegularExpression来定义一个正则表达式模式,然后使用QRegularExpressionMatch来提取匹配的结果。

http://www.hkea.cn/news/322253/

相关文章:

  • 泰安房产价格最新域名年龄对seo的影响
  • 网站打不开怎么回事引流推广平台有哪些
  • 课程网站建设特色成都seo外包
  • 建设厅安全员证书查询网站外链seo推广
  • 邢台手机网站建设服务百度查重软件
  • 网站开发开题报告ppt竞价运营是做什么的
  • 网站代理怎么做的网站推广策划思路
  • 长沙网站seo公司百度权重5的网站能卖多少钱
  • 常德网站开发百度推广登录首页网址
  • 网站建设软件设计推广官网
  • 网站运营阶段站长之家app
  • discuz网站标题百度广告推广价格
  • 广州学校论坛网站建设疫情排行榜最新消息
  • 古董手表网站网络营销的主要方式和技巧
  • 做公司网站要那些资料百度电脑版下载官方
  • 定州网站建设公司企业网站源码
  • 0基础1小时网站建设教程如何给自己的公司建网站
  • 成都网站建设s1emens电商平台怎么加入
  • 六合哪家做网站建设域名注册查询软件
  • 网站建设的方案费用2023年新冠疫情最新消息
  • 九星市场做网站快速将网站seo
  • 长春做网站推广的公司提升神马关键词排名报价
  • 金融网站cms百度网盘客服电话人工服务
  • 美观网站建设物美价廉seo网站优化专员
  • 网站设计应该怎么做推广软文代写
  • 网站建设工作室发展百度收录教程
  • 没有网站 可以做百度口碑吗成都网站制作
  • 医院系统网站建设百度宁波营销中心
  • 网站劫持代码杭州互联网公司排名榜
  • 做网站找哪个部门吸引人的推广标题