zoukankan      html  css  js  c++  java
  • 抖音视频去水印

    实现思路


    首先需要在抖音复制一个视频链接,【癞蛤蟆想吃天鹅肉。%表白 %每帧都是表情包 https://v.douyin.com/Jpjr22a/ 复制此链接,打开抖音搜索,直接观看视频!】

    复制其中的视频链接进行访问,会跳转到如下界面

    可以看到复制链接打开后域名由www.v.douyin.com 变成了 www.iesdouyin.com ,可见其发生了重定向

    F12查看一下这个页面,发现有一个video标签,把src链接复制出来看一下

    果然是获取到了视频!!

    既然获取到了视频,接下来也就是去水印的问题了,看一下这个链接
    https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0300ff50000bvjhii2m4tg2rat9l3l0&ratio=720p&line=0

    有没有感觉这个playwn 的wx有点像water mask的简写呢,去掉试一下

    我顶! 还真获取到了!!!
    这样的话我们就可以直接获取 https://v.douyin.com/Jpjr22a/ 这个链接重定向后页面的body,然后使用正则匹配到带水印的视频链接,再把链接中的playwn替换成play,就搞定啦


    还有一种方式


    直接访问分享的链接,我们在重定向后的页面打开NetWork,然后刷新一下

    可以看到发送了一个ajax请求,item_ids应该是视频的id,点击查看响应的是一个json,复制到格式化工具中得到的是:

    {
    	"status_code": 0,
    	"item_list": [{
    		"video_labels": null,
    		"video_text": null,
    		"is_live_replay": false,
    		"music": {
    			"title": "@悠创作的原声",
    			"cover_hd": {
    				"uri": "tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947",
    				"url_list": ["https://p3-dy-ipv6.byteimg.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_1080x1080.jpeg?from=4010531038", "https://p6.douyinpic.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_1080x1080.jpeg?from=4010531038", "https://p9.douyinpic.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_1080x1080.jpeg?from=4010531038"]
    			},
    			"cover_large": {
    				"uri": "tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947",
    				"url_list": ["https://p3-dy-ipv6.byteimg.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_1080x1080.jpeg?from=4010531038", "https://p6.douyinpic.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_1080x1080.jpeg?from=4010531038", "https://p9.douyinpic.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_1080x1080.jpeg?from=4010531038"]
    			},
    			"cover_thumb": {
    				"uri": "tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947",
    				"url_list": ["https://p3-dy-ipv6.byteimg.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_168x168.webp?from=4010531038", "https://p29-dy.byteimg.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_168x168.webp?from=4010531038", "https://p9.douyinpic.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_168x168.webp?from=4010531038", "https://p3-dy-ipv6.byteimg.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_168x168.jpeg?from=4010531038"]
    			},
    			"play_url": {
    				"uri": "https://sf3-cdn-tos.douyinstatic.com/obj/ies-music/6908003385950505735.mp3",
    				"url_list": ["https://sf3-cdn-tos.douyinstatic.com/obj/ies-music/6908003385950505735.mp3", "https://sf6-cdn-tos.douyinstatic.com/obj/ies-music/6908003385950505735.mp3"]
    			},
    			"duration": 9,
    			"status": 1,
    			"id": 6908003431412174000,
    			"mid": "6908003431412173575",
    			"author": "悠",
    			"cover_medium": {
    				"uri": "tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947",
    				"url_list": ["https://p9-dy.byteimg.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_720x720.jpeg?from=4010531038", "https://p1-dy-ipv6.byteimg.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_720x720.jpeg?from=4010531038", "https://p3.douyinpic.com/img/tos-cn-i-0813/f055619f58ac43a2bf24e91c8369f947~c5_720x720.jpeg?from=4010531038"]
    			},
    			"position": null
    		},
    		"desc": "癞蛤蟆想吃天鹅肉。#表白 #每帧都是表情包",
    		"share_info": {
    			"share_weibo_desc": "#在抖音,记录美好生活#癞蛤蟆想吃天鹅肉。#表白 #每帧都是表情包",
    			"share_desc": "在抖音,记录美好生活",
    			"share_title": "癞蛤蟆想吃天鹅肉。#表白 #每帧都是表情包"
    		},
    		"geofencing": null,
    		"forward_id": "0",
    		"aweme_id": "6910519894912109827",
    		"text_extra": [{
    			"end": 12,
    			"type": 1,
    			"hashtag_name": "表白",
    			"hashtag_id": 1553309084406785,
    			"start": 9
    		}, {
    			"type": 1,
    			"hashtag_name": "每帧都是表情包",
    			"hashtag_id": 1589464115430413,
    			"start": 13,
    			"end": 21
    		}],
    		"duration": 6129,
    		"risk_infos": {
    			"warn": false,
    			"type": 0,
    			"content": ""
    		},
    		"label_top_text": null,
    		"group_id": 6910519894912110000,
    		"cha_list": [{
    			"cha_name": "表白",
    			"desc": "",
    			"user_count": 0,
    			"connect_music": null,
    			"type": 0,
    			"view_count": 0,
    			"hash_tag_profile": "",
    			"cid": "1553309084406785",
    			"is_commerce": false
    		}],
    		"share_url": "https://www.iesdouyin.com/share/video/6910519894912109827/?region=&mid=6908003431412173575&u_code=48&titleType=title&did=0&iid=0",
    		"comment_list": null,
    		"author_user_id": 2049117125355886,
    		"long_video": null,
    		"promotions": null,
    		"is_preview": 0,
    		"create_time": 1608980812,
    		"author": {
    			"geofencing": null,
    			"policy_version": null,
    			"type_label": null,
    			"nickname": "表情分享站",
    			"signature": "表情分享,谢谢关注!
    取图+微信公众号:表情窝",
    			"avatar_larger": {
    				"url_list": ["https://p3-dy-ipv6.byteimg.com/aweme/1080x1080/3170f000be146459d1113.jpeg?from=4010531038", "https://p9.douyinpic.com/aweme/1080x1080/3170f000be146459d1113.jpeg?from=4010531038", "https://p1-dy-ipv6.byteimg.com/aweme/1080x1080/3170f000be146459d1113.jpeg?from=4010531038"],
    				"uri": "3170f000be146459d1113"
    			},
    			"avatar_medium": {
    				"url_list": ["https://p3.douyinpic.com/aweme/720x720/3170f000be146459d1113.jpeg?from=4010531038", "https://p29-dy.byteimg.com/aweme/720x720/3170f000be146459d1113.jpeg?from=4010531038", "https://p9-dy.byteimg.com/aweme/720x720/3170f000be146459d1113.jpeg?from=4010531038"],
    				"uri": "3170f000be146459d1113"
    			},
    			"followers_detail": null,
    			"platform_sync_info": null,
    			"uid": "2049117125355886",
    			"short_id": "3636122949",
    			"avatar_thumb": {
    				"uri": "3170f000be146459d1113",
    				"url_list": ["https://p29-dy.byteimg.com/aweme/100x100/3170f000be146459d1113.jpeg?from=4010531038", "https://p3-dy-ipv6.byteimg.com/aweme/100x100/3170f000be146459d1113.jpeg?from=4010531038", "https://p9.douyinpic.com/aweme/100x100/3170f000be146459d1113.jpeg?from=4010531038"]
    			},
    			"unique_id": "biaoqing2020"
    		},
    		"video": {
    			"play_addr": {
    				"uri": "v0300ff50000bvjhii2m4tg2rat9l3l0",
    				"url_list": ["https://aweme.snssdk.com/aweme/v1/playwm/?video_id=v0300ff50000bvjhii2m4tg2rat9l3l0&ratio=720p&line=0"]
    			},
    			"height": 1920,
    			"origin_cover": {
    				"uri": "tos-cn-p-0015/1081c181f5034a0181e7e2c2b04f6b16_1608980813",
    				"url_list": ["https://p29-dy.byteimg.com/tos-cn-p-0015/1081c181f5034a0181e7e2c2b04f6b16_1608980813~tplv-dy-360p.jpeg?from=2563711402", "https://p3-dy-ipv6.byteimg.com/tos-cn-p-0015/1081c181f5034a0181e7e2c2b04f6b16_1608980813~tplv-dy-360p.jpeg?from=2563711402", "https://p9-dy.byteimg.com/tos-cn-p-0015/1081c181f5034a0181e7e2c2b04f6b16_1608980813~tplv-dy-360p.jpeg?from=2563711402"]
    			},
    			"has_watermark": true,
    			"bit_rate": null,
    			"vid": "v0300ff50000bvjhii2m4tg2rat9l3l0",
    			"cover": {
    				"uri": "tos-cn-p-0015/476ad9b3b1c043249f138133784b7bec",
    				"url_list": ["https://p5-dy-ipv6.byteimg.com/img/tos-cn-p-0015/476ad9b3b1c043249f138133784b7bec~c5_300x400.jpeg?from=2563711402_large", "https://p9.douyinpic.com/img/tos-cn-p-0015/476ad9b3b1c043249f138133784b7bec~c5_300x400.jpeg?from=2563711402_large", "https://p6-dy-ipv6.byteimg.com/img/tos-cn-p-0015/476ad9b3b1c043249f138133784b7bec~c5_300x400.jpeg?from=2563711402_large"]
    			},
    			"width": 1080,
    			"dynamic_cover": {
    				"uri": "tos-cn-p-0015/e10109578ccb43fbb4c54e2e9bdb7afc_1608980814",
    				"url_list": ["https://p5-dy-ipv6.byteimg.com/obj/tos-cn-p-0015/e10109578ccb43fbb4c54e2e9bdb7afc_1608980814?from=2563711402_large", "https://p29.douyinpic.com/obj/tos-cn-p-0015/e10109578ccb43fbb4c54e2e9bdb7afc_1608980814?from=2563711402_large", "https://p9-dy.byteimg.com/obj/tos-cn-p-0015/e10109578ccb43fbb4c54e2e9bdb7afc_1608980814?from=2563711402_large"]
    			},
    			"ratio": "720p",
    			"duration": 6129
    		},
    		"statistics": {
    			"digg_count": 61422,
    			"play_count": 0,
    			"aweme_id": "6910519894912109827",
    			"comment_count": 14082
    		},
    		"aweme_type": 4,
    		"image_infos": null
    	}],
    	"extra": {
    		"now": 1610525887000,
    		"logid": "20210113161807010015034211500632E2"
    	}
    }
    

    可以看到数据还是挺丰富的,视频的地址是在item_list下video.play_addr.url_list中,复制下这个地址用浏览器访问一下果然得到了视频

    不过这个视频也是带水印的,把视频链接中的playwn改成play就可以啦

    思路总结

    1.访问客户端分享文本中的链接,从重定向后的url中提取视频id,https://www.iesdouyin.com/share/video/后的数字就是视频id。
    2.访问https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=视频id获取有关该视频的json字符串。
    3.从得到的json字符串中提取视频播放地址,在item_list下video.play_addr.url_list中。
    4.将视频地址中的playwm替换为play。
    5.使用移动端的user-agent访问替换后的视频地址即可得到无抖音水印的视频。

    需要的核心代码同学可以在下方留言,另外附上一张自己做的去水印的小程序

    此文章参考思路:https://www.cnblogs.com/xyz-s/p/13634757.html

  • 相关阅读:
    java学习day02---Spring Boot综合运用---活动模块
    java学习day01---GC
    课程学习总结报告
    结合中断上下文切换和进程上下文切换分析Linux内核的一般执行过程
    深入理解系统调用
    基于mykernel 2.0编写一个操作系统内核
    超码 候选码 主码 替换码 数据库 定义
    如何评测软件工程知识技能水平?
    创新产品的需求分析:未来的图书会是什么样子?
    案例分析:设计模式与代码的结构特性(桥接模式)
  • 原文地址:https://www.cnblogs.com/xuchangqi1/p/14296928.html
Copyright © 2011-2022 走看看