如何制作带有视频的横幅广告,例如Animate CC,它遵守常见的尺寸限制(150kB)?
我发现你可以使用Javascript实现HTML5视频?也许是一个GIF?欢迎任何教程或指南。
答案 0 :(得分:7)
是的,有可能。 这是一个非常小的7K视频,在SO的大小限制内(6.6K压缩):
<!DOCTYPE html><html>
<meta charset="utf-8"><meta name="ad.size" content="width=320,height=100">
<body>
<script>
setTimeout( function(){
var v = document.querySelector( '#video' );
v.removeAttribute('loop'); /* Stop loop after 1 seconds (set below) */
v.addEventListener('ended', function(){
v.currentTime = 0.6; /* Rewind to 0.6 sec */
v.pause(); /* Stop video for IE 11 */
});
}, 1000 );
</script>
<video id="video" width="272" height="48" onclick='this.play()' autoplay loop src='data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAFg5tZGF0AAACsAYF//+s3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE0OCByMjY2NSBhMDFlMzM5IC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxNiAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTE2IGRlYmxvY2s9MTowOjAgYW5hbHlzZT0weDM6MHgxMzMgbWU9dW1oIHN1Ym1lPTEwIHBzeT0xIHBzeV9yZD0xLjAwOjAuMDAgbWl4ZWRfcmVmPTEgbWVfcmFuZ2U9MjQgY2hyb21hX21lPTEgdHJlbGxpcz0yIDh4OGRjdD0xIGNxbT0wIGRlYWR6b25lPTIxLDExIGZhc3RfcHNraXA9MSBjaHJvbWFfcXBfb2Zmc2V0PS0yIHRocmVhZHM9MSBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJ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AAAAABAAAAMAAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTcuMjQuMTAw'>
</body></html>
&#13;
最初的答案更为消极,但我们已经获得了更多的经验。
首先,动画GIF很糟糕。 非常效率低下。 当然,你可以获得150k,但颜色数量很少,而且有些英雄和有损compression。 根本不漂亮。
对于视频,它没有明确禁止,而是HTML5广告字ad may not contain HTML5视频文件。
但是,可以使用data uri或将视频重命名为.css
来规避它。
Google可能会在未来添加视频检测功能 - 如果您将其重命名为图像,它们已经检测到它 - 但是现在视频本身并不是拒绝的原因。
另一个问题是移动平台不会自动播放视频。 让它们点击播放很简单,但你可能想为图像占位符节省一些字节预算。
这留下了尺寸的主要问题。
对于video,common格式为MP4(H.264)。 从技术上讲,所有视频广告都可以压缩到150K,使用合适的工具只会降低质量,直到达到标记。 唯一的问题是质量是否可以接受。
音频,如果有的话,是更难的部分。 你需要像28kbps或更低的极端比特率才能吃掉太多的配额。 对于Google,音频也必须由用户启动。 因此,您可以选择自动播放没有音频,或点击播放,或编写音量开/关按钮。
这些是我用来烹饪141K demo ad的步骤,以及我后来发现的一些增强功能:
<html>
,meta ad.size,<body>
和视频代码。使用数据uri作为视频src。
.pause()
。这些步骤基于Avidemux 2.6.12的默认值。 我无法列出每个选项,因为有太多, 但由于x264编码器相当稳定,我不希望默认值发生变化。
我们也尝试了几次平均比特率,但CRF始终产生更好的结果。
设置交易编码时间,以获得更好的质量或更小的尺寸。 它可能并不明显,但单线程也增加了字节效率。 当你只有153,600个字节时,这些小位有帮助。
在一般编码中不建议调整B帧偏差,但适度增加确实有助于减少更多字节。
截至7-zip 16.02,Deflate是第二个最佳的视频压缩算法 - 优于bzip,lzma或ppmd。 Deflate64稍微好一些,但谷歌不支持。
答案 1 :(得分:1)
制作包含视频HTML5的横幅广告
HTML5视频标签演示,在视频顶部显示广告,消息,信息框/对话框 播放视频并等待8秒,此时会出现一个弹出消息/广告框,它会在18秒后消失!
// Get the Video Object
var v=document.getElementById("myvideo");
// Show the Adv Box i.e. the DIV
function show_adv() {
document.getElementById("my_ad").style.visibility="visible";
}
// Hide the Adv Box i.e. the DIV
function hide_adv() {
document.getElementById("my_ad").style.visibility="hidden";
}
// Execute this for each second when playing the Video
function catch_the_frame() {
var t;
t = Math.round(v.currentTime); // currentTime is float; Make it whole number to check
document.getElementById("seek_status").innerHTML="Current Time: " + t + " seconds"; // Show the current playing time in seconds
if ( t >= 8 && t <= 18) { // Target Second when we want to show the message/ad
show_adv(); // Show the message/ad
}else {
hide_adv(); // Show the message/ad
}
}
// Hide the video when page loaded
hide_adv();
// Handle the playing event
v.addEventListener('playing', function() {setInterval(catch_the_frame,500);}, false);
&#13;
#v_area{
float:left;
z-index: 99;
}
#my_ad {
position:absolute;
width:350px;
height:150px;
top: 10;
left: 10;
font-family: Arial;
font-size: 120%;
background-color:rgba(255,0,0,0.2);
z-index:100;
color: #ff0000;
}
#close a {
position:absolute;
top: 5;
left: 520;
z-index:100;
font-family: Arial;
font-size: 40%;
text-decoration: none;
}
.generic_txt{
font-family: Droid Sans,sans-serif;
font-size: 150%;
color: #0000ff;
}
.generic_txt_heading a {
font-family: Droid Sans,sans-serif;
font-size: 110%;
color: #00ff00;
text-decoration:none;
}
.generic_txt_heading2 {
font-family: Droid Sans,sans-serif;
font-size: 100%;
color: #0000ff;
text-decoration:none;
}
&#13;
<div id="v_area">
<div id="my_ad" style="visibility: hidden;">
How are you? I hope you are having a nice day. Cheers!
<p>Visit <a href="www.debugpoint.com">www.debugpoint.com</a> for more tutorials!
</p><div id="close" onclick="this.parentNode.parentNode.removeChild(this.parentNode); return false;">
<p></p><p><a href="#">[x]</a>
</p></div>
</div>
<div>
<video id="myvideo" controls="">
<source src="http://video.webmfiles.org/big-buck-bunny_trailer.webm">
Your browser doesn't support HTML5 video. Try a different browser instead.
</video>
</div>
</div>
&#13;
答案 2 :(得分:0)
用于实施视频,您可以使用html5视频标记
<video>
<source src="video here" type="video/videotype">
</video>
但并非所有浏览器都支持它。 .gif应该更容易实现,文件也更小。虽然它不提供播放/暂停等视频功能