How would I make a banner ad with video implemented in, for example, Animate CC which respects the common size limits (150kB)?
I found out you can implement a HTML5 video with Javascript? Perhaps a gif? Any tutorials or guides are welcome.
How would I make a banner ad with video implemented in, for example, Animate CC which respects the common size limits (150kB)?
I found out you can implement a HTML5 video with Javascript? Perhaps a gif? Any tutorials or guides are welcome.
Yes, it is possible. Here is a very small 7K video, within SO's size limit (6.6K zipped):
<!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//+s3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE0OCByMjY2NSBhMDFlMzM5IC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxNiAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTE2IGRlYmxvY2s9MTowOjAgYW5hbHlzZT0weDM6MHgxMzMgbWU9dW1oIHN1Ym1lPTEwIHBzeT0xIHBzeV9yZD0xLjAwOjAuMDAgbWl4ZWRfcmVmPTEgbWVfcmFuZ2U9MjQgY2hyb21hX21lPTEgdHJlbGxpcz0yIDh4OGRjdD0xIGNxbT0wIGRlYWR6b25lPTIxLDExIGZhc3RfcHNraXA9MSBjaHJvbWFfcXBfb2Zmc2V0PS0yIHRocmVhZHM9MSBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0x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AAABQAAAEaAAAAIAAAABQAAAAZAAABAgAAAJEAAAAxAAAAEAAAABMAAAAUc3RjbwAAAAAAAAABAAAAMAAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTcuMjQuMTAw'>
</body></html>
The original answer was more negative, but we have since gained more experience.
First, animated GIF is bad. It is very inefficient. You can get 150k, sure, but with very low colour count and some heroic and lossy compression. Not pretty at all.
As for video, it is not explicitly banned but HTML5 adsword ad may not contain HTML5 video files.
However it can be circumvented with data uri or by renaming the video to .css
.
Google may add video detection in the future - they already detects it if you rename it to an image - but for now video itself is not a reason of rejection.
Another issue is that mobile platforms do not autoplay video. It is simple to make them click-to-play, but you may want to spare some byte budget for the image placeholder.
That leaves the main problem of size.
For video, the common format is MP4 (H.264). Technically, all video ads can be compressed into 150K, with the right tools you just reduce the quality until it hits the mark. The only question is whether the quality will be acceptable.
Audio, if any, is the harder part. You need extreme bitrate like 28kbps or lower to not eat up too much quota. For Google, the audio must also be user-initiated. So you much choice to auto-plays without audio, or click to play, or script a volume on/off button.
These are the steps I took to cook up a 141K demo ad, plus some enhancements I discovered later:
<html>
, meta ad.size, <body>
, and the video tag. Use the data uri as video src.
.pause()
.The steps are based on Avidemux 2.6.12's defaults. I can't list every options because there are too many, but since x264 encoder is pretty stable I don't expect the defaults to change.
We also tried Average Bitrate a few times, but CRF consistently yields better result.
The settings trade encoding time for better quality or smaller size. It may not be obvious but single thread increase byte efficiency too. When you only have 153,600 bytes, these little bits helps.
Adjusting B-Frame Bias is not advised in general encoding, but a moderate increase really helps to shave more bytes off.
As of 7-zip 16.02, Deflate is the second best compression algorithm for video - better than bzip, lzma, or ppmd. Deflate64 is marginally better, but is not supported by Google.
Make a banner ads with video HTML5
HTML5 video tag demo with advertisement, message, information box/dialog on top of the video Play the video and wait till 8 seconds when a popup message/ad box will appear and it would go away at 18 sec!
Please refer here, Demo at here
// 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);
#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;
}
<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>
for implementing videos you can use the html5 video tag
<video>
<source src="video here" type="video/videotype">
</video>
but it's not supported in all browsers. A .gif should be much easier to implemented and the file is smaller as well. Although it does not offer video functions like play/pause
© 2022 - 2024 — McMap. All rights reserved.