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

网站模板加后台做电商如何起步

网站模板加后台,做电商如何起步,wordpress 官方主题 有哪些,网页美工基础目录 1、播放异常比对 2、视频编码检查 2.1、正常视频解析 2.2、海康视频解析 2.3、比对工具 3、转码 3.1、maven依赖 3.2、实现代码 4、验证 在前面的文章(海康威视-按时间下载录像文件_海康威视 sdk 下载录像 大小0-CSDN博客)中,通…

目录

1、播放异常比对

2、视频编码检查

2.1、正常视频解析

2.2、海康视频解析

2.3、比对工具

3、转码

3.1、maven依赖

3.2、实现代码

4、验证


在前面的文章(海康威视-按时间下载录像文件_海康威视 sdk 下载录像 大小0-CSDN博客)中,通过按时间段下载指定的录像视频。

在实际的播放中,VLC工具可以播放,而放到浏览器中则无法播放

1、播放异常比对

海康视频播放错误:

出现 206 返回码,则视频下载完成,无法播放

普通视频播放正常:

虽然出现206,但播放正常。

所以考虑到,可能是通过设备网络SDK下载的视频编码存在问题

2、视频编码检查

使用ffprobe工具进行视频的详细内容检查

ffprobe.exe  -v quiet -print_format json -show_format -show_streams 3.mp4

2.1、正常视频解析

{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High",
            "codec_type": "video",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 960,
            "height": 720,
            "coded_width": 960,
            "coded_height": 720,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 2,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "4:3",
            "pix_fmt": "yuv420p",
            "level": 31,
            "color_range": "tv",
            "color_space": "bt470bg",
            "color_transfer": "smpte170m",
            "color_primaries": "bt470bg",
            "chroma_location": "left",
            "field_order": "progressive",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "id": "0x1",
            "r_frame_rate": "25/1",
            "avg_frame_rate": "25/1",
            "time_base": "1/90000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 22518000,
            "duration": "250.200000",
            "bit_rate": "645258",
            "bits_per_raw_sample": "8",
            "nb_frames": "6255",
            "extradata_size": 48,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "language": "und",
                "handler_name": "VideoHandler",
                "vendor_id": "[0][0][0][0]",
                "encoder": "Lavc58.134.100 libwz264"
            }
        },
        {
            "index": 1,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",
            "sample_fmt": "fltp",
            "sample_rate": "44100",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "id": "0x2",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/44100",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 11032761,
            "duration": "250.175986",
            "bit_rate": "128311",
            "nb_frames": "10776",
            "extradata_size": 2,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "language": "und",
                "handler_name": "SoundHandler",
                "vendor_id": "[0][0][0][0]"
            }
        }
    ],
    "format": {
        "filename": ".\\2319539678.mp4",
        "nb_streams": 2,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "250.200000",
        "size": "24396491",
        "bit_rate": "780063",
        "probe_score": 100,
        "tags": {
            "major_brand": "isom",
            "minor_version": "512",
            "compatible_brands": "isomiso2avc1mp41",
            "encoder": "Lavf58.76.100",
            "comment": "zy-libx264,vid:2319539678"
        }
    }
}

2.2、海康视频解析

{
    "streams": [
        {
            "index": 0,
            "codec_name": "hevc",
            "codec_long_name": "H.265 / HEVC (High Efficiency Video Coding)",
            "profile": "Main",
            "codec_type": "video",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "width": 2560,
            "height": 1440,
            "coded_width": 2560,
            "coded_height": 1440,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 0,
            "pix_fmt": "yuv420p",
            "level": 153,
            "color_range": "tv",
            "chroma_location": "left",
            "refs": 1,
            "id": "0x1e0",
            "r_frame_rate": "25/1",
            "avg_frame_rate": "25/1",
            "time_base": "1/90000",
            "start_pts": 7612160776,
            "start_time": "84579.564178",
            "duration_ts": 899820,
            "duration": "9.998000",
            "extradata_size": 88,
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            }
        },
        {
            "index": 1,
            "codec_name": "pcm_alaw",
            "codec_long_name": "PCM A-law / G.711 A-law",
            "codec_type": "audio",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "sample_fmt": "s16",
            "sample_rate": "8000",
            "channels": 1,
            "channel_layout": "mono",
            "bits_per_sample": 8,
            "id": "0x1c0",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/90000",
            "start_pts": 7612153756,
            "start_time": "84579.486178",
            "duration_ts": 900000,
            "duration": "10.000000",
            "bit_rate": "64000",
            "disposition": {
                "default": 0,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            }
        }
    ],
    "format": {
        "filename": ".\\3.mp4",
        "nb_streams": 2,
        "nb_programs": 0,
        "format_name": "mpeg",
        "format_long_name": "MPEG-PS (MPEG-2 Program Stream)",
        "start_time": "84579.486178",
        "duration": "10.076000",
        "size": "3798048",
        "bit_rate": "3015520",
        "probe_score": 52
    }
}

2.3、比对工具

使用BCompare 比对工具,检查两个json的差异性。共有三处主要的不同

左边为正常视频、右边为海康视频

第一处:

海康转码后的格式 MPEG-H Part2/HEVC(H.265)(hevc)

第二处:

第三处:

3、转码

通过上图的对比,优先考虑将海康视频转码为H.264 格式

3.1、maven依赖

<dependency><groupId>ws.schild</groupId><artifactId>jave-core</artifactId><version>2.4.5</version></dependency><!--    核心包--><dependency><groupId>ws.schild</groupId><artifactId>jave-native-win64</artifactId><version>2.4.5</version></dependency><!--   这个是在windows环境下的jar,使用不同的环境,会调用不同的jar文件--><dependency><groupId>ws.schild</groupId><artifactId>jave-native-linux64</artifactId><version>2.4.5</version></dependency><!--   这个是在linux环境下的jar-->

3.2、实现代码

public static void convertH264() throws EncoderException {//源视频位置File file = new File("G:\\video\\ffmpeg\\3.mp4");//目标视频位置File file1 = new File("G:\\video\\ffmpeg\\4.mp4");// 创建转码器AudioAttributes audio = new AudioAttributes();//指定编码audio.setCodec("aac");audio.setBitRate(new Integer(128000));//通道audio.setChannels(new Integer(2));audio.setSamplingRate(new Integer(44100));VideoAttributes video = new VideoAttributes();//设置编解码器video.setCodec("h264");video.setX264Profile(VideoAttributes.X264_PROFILE.BASELINE);video.setBitRate(new Integer(1024*1024 * 2));//设置帧率video.setFrameRate(new Integer(25));//设置大小//video.setSize(new VideoSize(2560, 1440));EncodingAttributes attrs = new EncodingAttributes();//格式attrs.setFormat("mp4");//attrs.setAudioAttributes(audio);attrs.setVideoAttributes(video);// 进行转码Encoder encoder = new Encoder();encoder.encode(new MultimediaObject(file), file1, attrs);}

根据实际需要设置转码中是否需要音频,

调整视频清晰度:通过设置 video.setBitRate 大小,实际测试值为1024*1024*4=4M大小较清晰。

但是转码时间较长,10秒的3.7M视频 需要7秒转换完成,最终大小4.3M

4、验证

转码后视频可以通过浏览器播放。对应的视频详情如下

{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "Constrained Baseline",
            "codec_type": "video",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 2560,
            "height": 1440,
            "coded_width": 2560,
            "coded_height": 1440,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 0,
            "pix_fmt": "yuv420p",
            "level": 50,
            "chroma_location": "left",
            "field_order": "progressive",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "id": "0x1",
            "r_frame_rate": "25/1",
            "avg_frame_rate": "25/1",
            "time_base": "1/12800",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 128000,
            "duration": "10.000000",
            "bit_rate": "3599484",
            "bits_per_raw_sample": "8",
            "nb_frames": "250",
            "extradata_size": 39,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "language": "und",
                "handler_name": "VideoHandler",
                "vendor_id": "[0][0][0][0]"
            }
        }
    ],
    "format": {
        "filename": ".\\4.mp4",
        "nb_streams": 1,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "10.000000",
        "size": "4501211",
        "bit_rate": "3600968",
        "probe_score": 100,
        "tags": {
            "major_brand": "isom",
            "minor_version": "512",
            "compatible_brands": "isomiso2avc1mp41",
            "encoder": "Lavf58.20.100"
        }
    }
}

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

相关文章:

  • 湖南做网站的公司有哪些搜索引擎是什么
  • flash网站管理系统seo优化排名易下拉用法
  • 永年网站建设友链互换平台推荐
  • 企业网站的设计公司网络广告营销的典型案例
  • 高校思政主题网站建设的意义关键词歌词任然
  • 哪里做网站比较快2345网址导航下载桌面
  • 广州建设委员会官方网站凡科建站下载
  • 全球做网站的公司排名百度一下你就知道官网
  • 小企业网站价格免费发链接的网站
  • 买了空间和域名 怎么做网站哪家公司网站做得好
  • 网站备案是否关闭衡阳网站建设公司
  • 遂昌建设局网站个人怎么做网站
  • 软件开发和网站建设网络营销的未来6个发展趋势
  • 做网站一年多少钱免费seo网站推广
  • 智通人才网东莞最新招聘信息官网seo是如何做优化的
  • 个人做跨境电商网站百度地图导航手机版免费下载
  • 阿里云注册网站之后怎么做网站百度联盟是什么
  • 动画制作视频河南网站排名优化
  • 网站关键词怎么做排名掌门一对一辅导官网
  • 现在什么网站做推广比较好网页设计需要学什么
  • 个人购物网站 怎么建网络营销包括
  • 有没有做鸭的网站工作室招聘广州网站优化工具
  • 深圳营销外深圳网络营销公司seo和sem的联系
  • 专业的网站制作公司哪家好竞价专员是做什么的
  • 海南省建设厅网站百度seo霸屏软件
  • 淄博张店做网站的公司爱站小工具圣经
  • wordpress w3seo优化自学
  • 临沂手机建站模板微信seo排名优化软件
  • 网站管理员怎么做板块建设艺人百度指数排行榜
  • 如何创建企业网站网络舆情处置的五个步骤