<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	     xmlns:dc="http://purl.org/dc/elements/1.1/"
	   xmlns:atom="http://www.w3.org/2005/Atom"
	     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>YouTube &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/youtube/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Thu, 16 Apr 2026 07:12:38 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>YouTube &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[Downloading 360 Videos from YouTube (and playback in Linux)]]></title>
		<link>https://shkspr.mobi/blog/2021/01/downloading-360-videos-from-youtube-and-playback-in-linux/</link>
					<comments>https://shkspr.mobi/blog/2021/01/downloading-360-videos-from-youtube-and-playback-in-linux/#respond</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Mon, 18 Jan 2021 16:56:11 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[360]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[vlc]]></category>
		<category><![CDATA[YouTube]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=37786</guid>

					<description><![CDATA[Inspired by this conversation on Mastodon  YouTube hosts 360 videos. Here&#039;s one of mine, wandering through the Houses of Parliament. You can drag the video to see all around.    If you let YouTube-DL download the &#34;best&#34; version, you&#039;ll end up with a video which looks like this:    Each lens&#039; view has been horizontally stretched, and then stitched into an over/under view. This is in Google&#039;s…]]></description>
										<content:encoded><![CDATA[<p>Inspired by <a href="https://retro.social/@ajroach42/105543202951711845">this conversation on Mastodon</a></p>

<p>YouTube hosts <a href="https://shkspr.mobi/blog/2017/11/review-poweradd-360-camera/">360 videos</a>. Here's one of mine, wandering through the Houses of Parliament. You can drag the video to see all around.</p>

<iframe title="360 Test - Parliament" width="620" height="349" src="https://www.youtube.com/embed/UXNXnEzJD6w?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe>

<p>If you let YouTube-DL download the "best" version, you'll end up with a video which looks like this:</p>

<img src="https://shkspr.mobi/blog/wp-content/uploads/2021/01/Over-Under.jpg" alt="An over-under video." width="1024" height="512" class="aligncenter size-full wp-image-37789">

<p>Each lens' view has been horizontally stretched, and then stitched into an over/under view. This is in <a href="https://youtube-eng.googleblog.com/2017/03/improving-vr-videos.html">Google's Equi-angular Cubemap</a> format. Grim!</p>

<p>There are two options available to you to get the equirectangular version needed to playback easily on Linux</p>

<h2 id="easy-way"><a href="https://shkspr.mobi/blog/2021/01/downloading-360-videos-from-youtube-and-playback-in-linux/#easy-way">Easy Way</a></h2>

<p>Running <code>youtube-dl -F https://www.youtube.com/watch?v=...</code> will show you all the formats available.</p>

<pre><code class="language-bash">136          mp4        1280x720   720s 2325k , avc1.4d401f, 30fps, video only, 24.94MiB
248          webm       1920x960   1080s 2375k , vp9, 30fps, video only, 25.53MiB
137          mp4        1920x960   1080s 4127k , avc1.640028, 30fps, video only, 41.92MiB
18           mp4        640x360    360s  705k , avc1.42001E, 30fps, mp4a.40.2@ 96k (44100Hz), 7.63MiB
22           mp4        1280x720   720s 2514k , avc1.64001F, 30fps, mp4a.40.2@192k (44100Hz) (best)
</code></pre>

<p>I found that <code>-f 22</code> worked. And there's a way to test that!</p>

<p>If you run <code>ffmpeg -hide_banner -i filename.mp4</code> then you should see this in the metadata:</p>

<pre><code class="language-_">Side data:
   stereo3d: 2D
   spherical: equirectangular (0.000000/0.000000/0.000000) 
</code></pre>

<p>That's the magic which tells a video player that this is a spherical / 360 video.</p>

<p>If you play back the video in, say, the default Linux video player, it will look like this:</p>

<img src="https://shkspr.mobi/blog/wp-content/uploads/2021/01/Spherical-video.jpg" alt="A distorted video." width="1024" height="554" class="aligncenter size-full wp-image-37788">

<p>It's a weird view out of both lenses simultaneously. Yeuch!</p>

<p>But if you play it using <a href="https://www.videolan.org/vlc/releases/3.0.0.html">VLC version 3 or above</a>, you'll be able to drag the video around.</p>

<p>There is a downside. This only gets the 720p version.  If we want the full resolution version, we need a bit more trickery.</p>

<h2 id="hard-way"><a href="https://shkspr.mobi/blog/2021/01/downloading-360-videos-from-youtube-and-playback-in-linux/#hard-way">Hard Way</a></h2>

<p>There's <a href="https://github.com/ytdl-org/youtube-dl/issues/15267">a bug in YouTube which means YouTube-DL sometimes gets served up slightly weird formats</a>. The fix is to pass a blank user agent:</p>

<pre><code class="language-bash">youtube-dl --user-agent "" ...
</code></pre>

<p>Now, when you download the video, you'll get the full resolution copy in equirectangular format. HORRAY! But without the correct metadata. BOO!</p>

<p>This is because <code>ffmpeg</code> strips out Side data. <em>*sigh*</em></p>

<p>So, run this:</p>

<pre><code class="language-bash">youtube-dl --user-agent "" -k https://www.youtube.com/watch?v=...
</code></pre>

<p>That tells YouTube-DL to <code>k</code>eep the original video and audio separate. They need to be <a href="https://stackoverflow.com/questions/44760588/preserving-side-data-information-for-360-video-transcoding-using-ffmpeg/48147865#48147865">merged with the standard compliance mode to unofficial </a>.</p>

<pre><code class="language-bash">ffmpeg -i video.mp4 -i audio.m4a -c:v copy -strict unofficial spherical.mp4
</code></pre>

<p>Phew! Easy when you know how, eh?</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=37786&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2021/01/downloading-360-videos-from-youtube-and-playback-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Convert WebVTT to a Transcript using Python]]></title>
		<link>https://shkspr.mobi/blog/2018/09/convert-webvtt-to-a-transcript-using-python/</link>
					<comments>https://shkspr.mobi/blog/2018/09/convert-webvtt-to-a-transcript-using-python/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Mon, 10 Sep 2018 11:05:23 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[emfcamp]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[subtitles]]></category>
		<category><![CDATA[YouTube]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=30341</guid>

					<description><![CDATA[I want to convert YouTube&#039;s auto-generated subtitles into a plain transcript. Why is this so hard?  This blog post gives a more detailed explanation than my answer to this StackOverflow question.  Here&#039;s what the subtitles look like when you view a video:   And here&#039;s what the code which generates those subtitles looks like:  00:00:00.930 --&#62; 00:00:03.080 align:start position:0% …]]></description>
										<content:encoded><![CDATA[<p>I want to convert YouTube's auto-generated subtitles into a plain transcript. Why is this so hard?</p>

<p>This blog post gives a more detailed explanation than my answer to <a href="https://stackoverflow.com/questions/51784232/how-do-i-convert-the-webvtt-format-to-plain-text">this StackOverflow question</a>.</p>

<p>Here's what the subtitles look like when you view a video:
<img src="https://shkspr.mobi/blog/wp-content/uploads/2018/09/YouTube-showing-subtitles.jpg" alt="YouTube showing subtitles." width="600" height="338" class="aligncenter size-full wp-image-30343"></p>

<p>And here's what the code which generates those subtitles looks like:</p>

<pre><code class="language-_">00:00:00.930 --&gt; 00:00:03.080 align:start position:0%

and&lt;00:00:01.230&gt;&lt;c&gt; now&lt;/c&gt;&lt;00:00:01.439&gt;&lt;c&gt; can&lt;/c&gt;&lt;00:00:01.709&gt;&lt;c&gt; we&lt;/c&gt;&lt;00:00:01.800&gt;&lt;c&gt; have&lt;/c&gt;&lt;c.colorCCCCCC&gt;&lt;00:00:01.920&gt;&lt;c&gt; a&lt;/c&gt;&lt;/c&gt;&lt;c.colorE5E5E5&gt;&lt;00:00:01.979&gt;&lt;c&gt; round&lt;/c&gt;&lt;00:00:02.370&gt;&lt;c&gt; of&lt;/c&gt;&lt;00:00:02.460&gt;&lt;c&gt; applause&lt;/c&gt;&lt;/c&gt;

00:00:03.080 --&gt; 00:00:03.090 align:start position:0%
and now can we have&lt;c.colorCCCCCC&gt; a&lt;/c&gt;&lt;c.colorE5E5E5&gt; round of applause
 &lt;/c&gt;

00:00:03.090 --&gt; 00:00:04.849 align:start position:0%
and now can we have&lt;c.colorCCCCCC&gt; a&lt;/c&gt;&lt;c.colorE5E5E5&gt; round of applause
for&lt;/c&gt;&lt;c.colorCCCCCC&gt;&lt;00:00:03.120&gt;&lt;c&gt; Terrence&lt;/c&gt;&lt;00:00:03.629&gt;&lt;c&gt; Edwards&lt;/c&gt;&lt;00:00:03.899&gt;&lt;c&gt; and&lt;/c&gt;&lt;00:00:04.170&gt;&lt;c&gt; his&lt;/c&gt;&lt;/c&gt;&lt;c.colorE5E5E5&gt;&lt;00:00:04.200&gt;&lt;c&gt; talk&lt;/c&gt;&lt;00:00:04.529&gt;&lt;c&gt; the&lt;/c&gt;&lt;/c&gt;

00:00:04.849 --&gt; 00:00:04.859 align:start position:0%
for&lt;c.colorCCCCCC&gt; Terrence Edwards and his&lt;/c&gt;&lt;c.colorE5E5E5&gt; talk the
 &lt;/c&gt;
</code></pre>

<p>WTF? You're looking at <a href="https://www.w3.org/TR/webvtt1/">WebVTT</a> - Web Video Text Tracks Format - this allows words to be displayed as they're said. Each sentence and word is given a time-code and a position, colours are also possible to identify multiple speakers.  It's great for subtitles, but it is lousy if all you want to do is read a transcript.</p>

<p>So, how do we convert the above to something like:</p>

<blockquote><p>and now can we have a round of applause for Terrence Edwards and his talk the connected house of horrors</p></blockquote>

<h2 id="python-the-quick-and-dirty-way"><a href="https://shkspr.mobi/blog/2018/09/convert-webvtt-to-a-transcript-using-python/#python-the-quick-and-dirty-way">Python - the quick and dirty way</a></h2>

<p>Using the <a href="https://webvtt-py.readthedocs.io">open source WebVTT-PY</a> Python library, we can directly get the raw text of each line of the subtitles</p>

<pre><code class="language-python">import webvtt
vtt = webvtt.read('subtitles-en.vtt')

vtt[0].text
' \nand now can we have a round of applause'
vtt[1].text
'and now can we have a round of applause\n '
vtt[2].text
'and now can we have a round of applause\nfor Terrence Edwards and his talk the'
vtt[3].text
'for Terrence Edwards and his talk the\n '
vtt[4].text
'for Terrence Edwards and his talk the\nconnected house of horrors good'
vtt[5].text
'connected house of horrors good\n '
vtt[6].text
'connected house of horrors good\nafternoon'
</code></pre>

<p>Manually looking through the text, we can see that the 2nd element has the first complete sentence, then the 6th. Starting at 2, we can increment by 4 and grab elements 6, 10, 14, etc to build up a transcript. Does that work?</p>

<p>Yes! This is what happens if we <a href="https://docs.python.org/3/library/functions.html?highlight=slice#slice">slice the array</a>:</p>

<pre><code class="language-python">sub = vtt[2::4]

sub[0].text
'and now can we have a round of applause\nfor Terrence Edwards and his talk the'
sub[1].text
'connected house of horrors good\nafternoon'
sub[2].text
'AMF thank you so much for for coming\nhere my name is Terrence Eaton I need to'
sub[3].text
'tell you three things about this talk so\nthe first thing is that this does'
</code></pre>

<p>But are we sure that will work for all the subtitles? Or even for the entirety of this subtitle file?</p>

<h2 id="python-the-hard-way"><a href="https://shkspr.mobi/blog/2018/09/convert-webvtt-to-a-transcript-using-python/#python-the-hard-way">Python the hard way</a></h2>

<p>Let's take a look again at the first 4 subtitle entries.</p>

<pre><code class="language-_">vtt[0].text
' \nand now can we have a round of applause'
vtt[1].text
'and now can we have a round of applause\n '
vtt[2].text
'and now can we have a round of applause\nfor Terrence Edwards and his talk the'
vtt[3].text
'for Terrence Edwards and his talk the\n '
vtt[4].text
'for Terrence Edwards and his talk the\nconnected house of horrors good'
</code></pre>

<p>We can split those double lines using</p>

<pre><code class="language-_">vtt[2].text.splitlines()
['and now can we have a round of applause', 'for Terrence Edwards and his talk the']
</code></pre>

<p>Let's create a new array. Add all the lines split by <code>\n</code>.</p>

<pre><code class="language-python">lines = []
for line in vtt:
    lines.extend(line.text.strip().splitlines())
</code></pre>

<p>Which gives us:</p>

<pre><code class="language-_">&gt;&gt;&gt; lines[0]
'and now can we have a round of applause'
&gt;&gt;&gt; lines[1]
'and now can we have a round of applause'
&gt;&gt;&gt; lines[2]
'and now can we have a round of applause'
&gt;&gt;&gt; lines[3]
'for Terrence Edwards and his talk the'
&gt;&gt;&gt; lines[4]
'for Terrence Edwards and his talk the'
&gt;&gt;&gt; lines[5]
'for Terrence Edwards and his talk the'
&gt;&gt;&gt; lines[6]
'connected house of horrors good'
</code></pre>

<p>And now, to de-duplicate them:</p>

<pre><code class="language-python">transcript = ""
previous = None
for line in lines:
    if line == previous:
       continue
    transcript += " " + line
    previous = line
</code></pre>

<h2 id="putting-it-all-together"><a href="https://shkspr.mobi/blog/2018/09/convert-webvtt-to-a-transcript-using-python/#putting-it-all-together">Putting it all together</a></h2>

<p>Ta-da!</p>

<pre><code class="language-python">import webvtt
vtt = webvtt.read('subtitles.vtt')
transcript = ""

lines = []
for line in vtt:
    lines.extend(line.text.strip().splitlines())

previous = None
for line in lines:
    if line == previous:
       continue
    transcript += " " + line
    previous = line

print(transcript)
</code></pre>

<p>One thing to note is that there is <em>no</em> punctuation. So it's not as good as a proper transcription.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=30341&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2018/09/convert-webvtt-to-a-transcript-using-python/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Using YouTube to Transcode Videos to DASH on the Command Line]]></title>
		<link>https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/</link>
					<comments>https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Fri, 07 Jul 2017 19:59:30 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[ReDeCentralize]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[YouTube]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=25480</guid>

					<description><![CDATA[This is part of my redecentralisation efforts to liberate my videos from YouTube.  MPEG-DASH is a simple method of streaming videos which doesn&#039;t require any specialised server software. You convert a high resolution video into a series of smaller resolution videos.  You chop each of the videos up into several chunks. As the video plays, your browser then decides which chunk of the video to load…]]></description>
										<content:encoded><![CDATA[<p>This is part of my redecentralisation efforts to <a href="https://shkspr.mobi/blog/2015/11/liberate-your-youtube-videos/">liberate my videos from YouTube</a>.</p>

<p>MPEG-DASH is a simple method of streaming videos which doesn't require <em>any</em> specialised server software. You convert a high resolution video into a series of smaller resolution videos.  You chop each of the videos up into several chunks. As the video plays, your browser then decides which chunk of the video to load next depend on the bandwidth available to it.  Easy!</p>

<h2 id="aim"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#aim">Aim</a></h2>

<p>From the command line:</p>

<ul>
<li>Upload a video to YouTube</li>
<li>Download transcoded video in several formats suitable for MPEG DASH Streaming</li>
<li>Generate DASH manifest</li>
<li>Generate the HTML5 markup</li>
</ul>

<h2 id="uploading"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#uploading">Uploading</a></h2>

<p>There are a couple of YouTube video uploaders.  These are useful if you've got a video on a server, or don't want to waste a browser window.</p>

<ul>
<li><a href="https://github.com/porjo/youtubeuploader">porjo/youtubeuploader</a> has binaries available for Linux/Mac/Windows.</li>
<li><a href="https://github.com/tokland/shoogle">tokland/shoogle</a> a Python interface for <em>all</em> of Google's APIs.</li>
</ul>

<p>I'm using Porjo's client. After following the authentication instructions, the output is something like:</p>

<pre><code>./youtubeuploader_linux_amd64 -filename testing.mp4

Uploading file 'testing.mp4'...
Progress:     1.37 Mbps, 9852099 / 9852099 (100.000%) ETA          0s
Upload successful! Video ID: 6NV5heuaVuc
</code></pre>

<h2 id="downloading"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#downloading">Downloading</a></h2>

<p>The <em>only</em> program worth using is <a href="https://github.com/rg3/youtube-dl/">youtube-dl</a>.</p>

<p>We can see every video format that YouTube has created using:</p>

<pre><code>youtube-dl -F 6NV5heuaVuc
</code></pre>

<p>That will return something like:</p>

<table>
<thead>
<tr>
  <th>format code</th>
  <th>extension</th>
  <th>resolution</th>
  <th>note</th>
</tr>
</thead>
<tbody>
<tr>
  <td>139</td>
  <td>m4a</td>
  <td>audio only DASH audio</td>
  <td>49k , m4a_dash container, mp4a.40.5@ 48k (22050Hz)</td>
</tr>
<tr>
  <td>140</td>
  <td>m4a</td>
  <td>audio only DASH audio</td>
  <td>128k , m4a_dash container, mp4a.40.2@128k (44100Hz)</td>
</tr>
<tr>
  <td>134</td>
  <td>mp4</td>
  <td>640x360</td>
  <td>DASH video 104k , avc1.4d401e, 30fps, video only</td>
</tr>
<tr>
  <td>160</td>
  <td>mp4</td>
  <td>256x144</td>
  <td>DASH video 108k , avc1.4d400b, 30fps, video only</td>
</tr>
<tr>
  <td>133</td>
  <td>mp4</td>
  <td>426x240</td>
  <td>DASH video 242k , avc1.4d400c, 30fps, video only</td>
</tr>
<tr>
  <td>135</td>
  <td>mp4</td>
  <td>854x480</td>
  <td>DASH video 1155k , avc1.4d4014, 30fps, video only</td>
</tr>
<tr>
  <td>137</td>
  <td>mp4</td>
  <td>1920x1080</td>
  <td>DASH video 2306k , avc1.640028, 30fps, video only</td>
</tr>
<tr>
  <td>136</td>
  <td>mp4</td>
  <td>1280x720</td>
  <td>DASH video 2310k , avc1.4d4016, 30fps, video only</td>
</tr>
<tr>
  <td>17</td>
  <td>3gp</td>
  <td>176x144</td>
  <td>small , mp4v.20.3, mp4a.40.2@ 24k</td>
</tr>
<tr>
  <td>36</td>
  <td>3gp</td>
  <td>320x180</td>
  <td>small , mp4v.20.3, mp4a.40.2</td>
</tr>
<tr>
  <td>43</td>
  <td>webm</td>
  <td>640x360</td>
  <td>medium , vp8.0, vorbis@128k</td>
</tr>
<tr>
  <td>18</td>
  <td>mp4</td>
  <td>640x360</td>
  <td>medium , avc1.42001E, mp4a.40.2@ 96k</td>
</tr>
<tr>
  <td>22</td>
  <td>mp4</td>
  <td>1280x720</td>
  <td>hd720 , avc1.64001F, mp4a.40.2@192k (best)</td>
</tr>
</tbody>
</table>

<p>It may take several minutes for YouTube to generate all the video formats - the length of time will depend on the length and quality of the video.</p>

<p>We want to download all the DASH videos and the DASH audios.  We also want the subtitles - even if they are autogenerated. Finally, we want the thumbnail image for the HTML5 poster.</p>

<p>The <code>youtube-dl</code> command to download all the DASH audio is:</p>

<pre><code>youtube-dl -f 'all[vcodec=none]' -o '%(title)s-%(format)s.%(ext)s' 6NV5heuaVuc
</code></pre>

<p>To get all the DASH videos:</p>

<pre><code>youtube-dl -f 'all[acodec=none]' -o '%(title)s-%(format)s.%(ext)s' 6NV5heuaVuc
</code></pre>

<p>This will create a separate MP4 video for each resolution, and separate audio file for each bitrate.</p>

<p>To generate a single thumbnail, run:</p>

<pre><code>youtube-dl --write-thumbnail --skip-download 6NV5heuaVuc
</code></pre>

<p>To download the subtitles:</p>

<pre><code>youtube-dl --write-auto-sub --sub-format vtt --write-sub 6NV5heuaVuc
</code></pre>

<h2 id="convert-to-dash"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#convert-to-dash">Convert to DASH</a></h2>

<p>For this step, we need the open source <a href="https://www.bento4.com/developers/dash/">Bento4 toolkit</a>.</p>

<p>The video should already have "fragments" - the chunks which make up the stream - you can check this with:</p>

<pre><code>./mp4info "Video-133 - 426x240 (DASH video).mp4"
</code></pre>

<p>In the output, you should see:</p>

<pre><code>Movie:
  duration:   0 ms
  time scale: 90000
  fragments:  yes
</code></pre>

<p>The audio downloaded from YouTube will <strong>not</strong> have fragments, so you'll need to run this command on every audio file you've downloaded:</p>

<pre><code>./mp4fragment "Video-140 - audio only (DASH audio).m4a" high.m4a
</code></pre>

<h3 id="combine-and-create-manifest"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#combine-and-create-manifest">Combine and create manifest</a></h3>

<p>Let's take those audio and video files and make ourselves a manifest!</p>

<pre><code>./mp4dash -o output-video 133.mp4 135.mp4 136.mp4 137.mp4 160.mp4 high.m4a low.m4a
</code></pre>

<p>This creates the folder <code>output-video</code> and creates folders for the chunked audio and video.</p>

<p>It will also produce the MPD - a manifest file which references all of the chunks.</p>

<p>We're <em>nearly</em> ready to play back.</p>

<h2 id="play-dash-video-in-the-browser"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#play-dash-video-in-the-browser">Play DASH Video in the browser</a></h2>

<p>As far as I can tell, no browser <em>natively</em> supports MPEG-DASH. You will need to use <a href="https://github.com/Dash-Industry-Forum/dash.js/blob/development/README.md">the latest version of dash.js</a> to make everything work smoothly.</p>

<p>Add this piece of JavaScript to your page:</p>

<pre><code>&lt;script src="https://cdn.dashjs.org/latest/dash.all.min.js"&gt;&lt;/script&gt;
</code></pre>

<p>Then reference the MPD in a <code>video</code> element:</p>

<pre><code>&lt;video width="1080" data-dashjs-player src="stream.mpd" controls poster="example.jpg"&gt;
    &lt;track kind="subtitles" src="en.vtt" srclang="en" label="English"&gt;
&lt;/video&gt;
</code></pre>

<h2 id="demo"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#demo">Demo</a></h2>

<p>Here is an adaptive stream of one of my videos - hosted natively on this site, with no server-side streaming.</p>

<script src="https://cdn.dashjs.org/latest/dash.all.min.js"></script>

<video width="1080" data-dashjs-player="" controls="" poster="https://shkspr.mobi/dash/demo/poster.jpg">
    <source src="https://shkspr.mobi/dash/demo/stream.mpd" type="application/dash+xml">
    <source src="https://shkspr.mobi/dash/demo/fallback.mp4" type="video/mp4">
    <track kind="subtitles" src="https://shkspr.mobi/dash/demo/en.vtt" srclang="en" label="English">
</video>

<h2 id="problems"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#problems">Problems?</a></h2>

<h3 id="fallback-video"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#fallback-video">Fallback video</a></h3>

<p>Some browsers can't play back DASH, even with the JavaScript - so you can put a fallback video in the HTML.</p>

<pre><code>&lt;video width="1080" data-dashjs-player controls &gt;
    &lt;source src="stream.mpd"   type="application/dash+xml"&gt;
    &lt;source src="fallback.mp4" type="video/mp4"&gt;
&lt;/video&gt;
</code></pre>

<h3 id="hls"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#hls">HLS</a></h3>

<p>Because Apple are special, they don't support DASH on its phones.  So you'll need to use their proprietary HLS streaming solution.  You can use <a href="https://www.bento4.com/developers/hls/">Bento4 to create HLS</a> in exactly the same way as you create DASH.</p>

<p>You may also need to use <a href="https://github.com/video-dev/hls.js/">hls.js JavaScript</a> to get things to work smoothly.</p>

<h3 id="subtitles"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#subtitles">Subtitles</a></h3>

<p>You can use <a href="https://www.bento4.com/developers/dash/subtitles/">DASH native subtitles</a>, or HTML5 subtitles.</p>

<p>I found that the HTML5 subtitles downloaded by <code>youtube-dl</code> contain some strange CSS which didn't work well with the DASH video.  You may need to test to see how it works for you.</p>

<h2 id="all-in-one-command"><a href="https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/#all-in-one-command">All in one command?</a></h2>

<p>Hahahaha! Not yet! If you know of a good way to do this - let me know!</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=25480&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2017/07/using-youtube-to-transcode-videos-to-dash-on-the-command-line/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Liberate Your YouTube Videos]]></title>
		<link>https://shkspr.mobi/blog/2015/11/liberate-your-youtube-videos/</link>
					<comments>https://shkspr.mobi/blog/2015/11/liberate-your-youtube-videos/#respond</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Fri, 20 Nov 2015 08:12:26 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[NaBloPoMo]]></category>
		<category><![CDATA[ReDeCentralize]]></category>
		<category><![CDATA[YouTube]]></category>
		<guid isPermaLink="false">https://shkspr.mobi/blog/?p=21934</guid>

					<description><![CDATA[If you&#039;ve been following this blog, you&#039;ll know that Google unjustly shut down my YouTube channel.  They&#039;ve now reinstated it - but I can no longer trust them as custodians of my data.  So, here&#039;s a quick tutorial on how to download all your videos - and metadata - from YouTube.  The Official Way  Google offers a &#34;takeout&#34; service which will allow you to package up all your YouTube videos for…]]></description>
										<content:encoded><![CDATA[<p>If you've been following this blog, you'll know that <a href="https://shkspr.mobi/blog/2015/11/the-day-google-deleted-me/">Google unjustly shut down my YouTube channel</a>.  They've now reinstated it - but I can no longer trust them as custodians of my data.</p>

<p>So, here's a quick tutorial on how to download all your videos - and metadata - from YouTube.</p>

<h2 id="the-official-way"><a href="https://shkspr.mobi/blog/2015/11/liberate-your-youtube-videos/#the-official-way">The Official Way</a></h2>

<p>Google offers a "<a href="https://www.google.com/settings/takeout/">takeout</a>" service which will allow you to package up all your YouTube videos for export.</p>

<p>It creates a multi-gigabyte archive - which isn't particularly suitable for hosting elsewhere.
<img src="https://shkspr.mobi/blog/wp-content/uploads/2015/11/Google-Takeout.jpeg" alt="Google Takeout" width="800" height="600" class="aligncenter size-full wp-image-21935">
Once the archive is created, you have to download it in 2GB chunks. The archives are only available for 7 days - so if you're on a normal speed Internet connection, you might not be able to grab everything.</p>

<p>If you do manage to download everything - you'll find another problem.
<img src="https://shkspr.mobi/blog/wp-content/uploads/2015/11/YouTube-Export-Zip-fs8.png" alt="YouTube Export Zip-fs8" width="736" height="221" class="aligncenter size-full wp-image-21936">
The files are enormous because you're downloading the originals - not the web-optimised versions.</p>

<p>So, how can we download high-quality, low-filesize copies of the videos suitable for HTML5 use?</p>

<h2 id="p-p-p-p-pick-up-some-python"><a href="https://shkspr.mobi/blog/2015/11/liberate-your-youtube-videos/#p-p-p-p-pick-up-some-python">P-p-p-p-pick Up Some Python</a></h2>

<p>We'll be using the excellent <a href="http://rg3.github.io/youtube-dl/">YouTube-DL</a> - make sure you have the most recent version installed.</p>

<p>The Google Takeout from above contains a file called <code>uploads.json</code> - it has a list of every video you've uploaded and some associated metadata:</p>

<pre><code class="language-json">...
,{
  "contentDetails" : {
    "videoId" : "2gIM9MzfaC8"
  },
  "etag" : "\"mPrpS7Nrk6Ggi_P7VJ8-KsEOiIw/7fgl8GbhgRwxNU3aCz9jzUB_65M\"",
  "id" : "UUAEmywW2HASHP0MohSNIN0qHLpdeAxkQv",
  "kind" : "youtube#playlistItem",
  "snippet" : {
    "channelId" : "UCyC5lCspQ5sXZ9L3ZdEEF2Q",
    "channelTitle" : "Terence Eden",
    "description" : "Look at me walk to work!",
    "playlistId" : "UUyC5lCspQ5sXZ9L3ZdEEF2Q",
    "position" : 168,
    "publishedAt" : "2010-12-02T10:03:15.000Z",
    "resourceId" : {
      "kind" : "youtube#video",
      "videoId" : "2gIM9MzfaC8"
    },
    "thumbnails" : {
      "default" : {
        "height" : 90,
        "url" : "https://i.ytimg.com/vi/2gIM9MzfaC8/default.jpg",
        "width" : 120
      },
      "high" : {
        "height" : 360,
        "url" : "https://i.ytimg.com/vi/2gIM9MzfaC8/hqdefault.jpg",
        "width" : 480
      },
      "medium" : {
        "height" : 180,
        "url" : "https://i.ytimg.com/vi/2gIM9MzfaC8/mqdefault.jpg",
        "width" : 320
      }
    },
    "title" : "Walking To Work In The Snow"
  },
  "status" : {
    "privacyStatus" : "public"
  }
}, {
...
</code></pre>

<p>So, we want to go through that JSON, download some web-friendly versions of the media, and save them.</p>

<p>This Python downloads a high resolution MP4 video and AAC audio - it then mixes them together.  It will also download a slightly lower resolution WEBM file.  It then grabs a screenshot and any subtitles which are present.  Finally, a little HTML5 snippet is written.</p>

<pre><code class="language-python">from __future__ import unicode_literals
from datetime import datetime

import youtube_dl
import json
import urllib
import os

#    Read the JSON
with open('uploads.json') as data_file:
    data = json.load(data_file)

#    Itterate through the JSON
for video in data:
    videoId     = video["contentDetails"]["videoId"]
    description = video["snippet"]["description"]
    publishedAt = video["snippet"]["publishedAt"]
    title       = video["snippet"]["title"]
    status      = video["status"]["privacyStatus"]

    #    Create a date object based on the video's timestamp
    date_object = datetime.strptime(publishedAt,"%Y-%m-%dT%H:%M:%S.000Z")

    #    Create a filepath and filename
    #    /YYYYMMDD-HHMM/YYYYMMDD-HHMM_My Video_abc123
    filepath    = date_object.strftime('%Y%m%d-%H%M')
    filename    = date_object.strftime('%Y%m%d') + "_" + title + "_" + videoId

    #    YouTube Options
    ydl_opts = {
        #    The highest quality MP4 should have the best resolution.
        #    Best quality AAC audio - because that's the codec which will fit in an MP4
        #    A lower quality WEBM for HTML5 streaming
        'format': 'bestvideo[ext=mp4]+bestaudio[acodec=aac],webm',
        'audioformat' :'aac',
        'merge_output_format' : 'mp4',
        #    Don't create multiple copies of things
        'nooverwrites' : 'true',
        #    Some videos have subtitles
        'writeautomaticsub' : 'true',
        'writethumbnail' : 'true',
        #    Make sure the filenames don't contain weird characters
        'restrictfilenames' : 'true',
        #    Add the correct extention for each filename
        'outtmpl' : filepath + '/' + filename + '.%(ext)s',
        #    If there is a problem, try again
        'retries' : '5',
        # 'verbose' : 'true',
    }

    #    Download the files
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        if status == "private":
            #    YouTube-DL won't download private videos
            print "Skipping private video " + videoId
        else:
            print "Downloading " + videoId + " to " + filename
            ydl.download(['http://www.youtube.com/watch?v='+videoId])
            #    Write an HTML5 snippet
            html  = "&lt;video   poster=\""+filename+".jpg\" controls &gt;\n"
            html += "    &lt;source src=\""+filename+".mp4\"    type=\"video/mp4; codecs=mp4a.40.2, avc1.42001E\"&gt;\n"
            html += "    &lt;source src=\""+filename+".webm\"   type=\"video/webm; codecs=vorbis, vp8.0\"&gt;\n"
            html += "    &lt;track  src=\""+filename+".en.vtt\" kind=\"subtitles\" srclang=\"en\" label=\"English\"&gt;\n"
            html += "&lt;/video&gt;"
            #    Write the HTML
            with open(os.path.join(filepath, "video.html"), 'w') as html_file:
                html_file.write(html)
</code></pre>

<p>The files it downloads are significantly smaller than the original uploads - with no noticeable loss of quality. The combined size of the MP4 and WEBM are around half the size of the original files.</p>

<img src="https://shkspr.mobi/blog/wp-content/uploads/2015/11/YT-Output-folders-fs8.png" alt="YT Output folders-fs8" width="618" height="336" class="aligncenter size-full wp-image-21939">

<p>There is one major bug - occasionally the script will crap out with:</p>

<pre>youtube_dl.utils.DownloadError: ERROR: content too short (expected 153471376 bytes and served 88079712)</pre>

<p>This is <a href="https://github.com/rg3/youtube-dl/issues?utf8=%E2%9C%93&amp;q=is%3Aopen+content+too+short">a persistent error with YouTube-DL</a>.</p>

<p>The script can be run again - it's smart enough to avoid re-downloading the videos.</p>

<p>And there you have it - a quick way to grab everything you've uploaded.  It's missing a few things - view counts and comments, mostly - but it's good enough for re-hosting elsewhere.</p>

<h3 id="this-is-what-it-looks-like"><a href="https://shkspr.mobi/blog/2015/11/liberate-your-youtube-videos/#this-is-what-it-looks-like">This is what it looks like</a></h3>

<p>This is what happens when you put that dash of HTML into a web-page:</p>

<video poster="https://shkspr.mobi/blog/wp-content/uploads/2015/11/20130210_Raspberry-Pi-MakeyMakey-Scratch-awesome_bNSC5W1_6U4.jpg" controls="" style="max-width:100%;">
    <source src="https://shkspr.mobi/blog/wp-content/uploads/2015/11/20130210_Raspberry-Pi-MakeyMakey-Scratch-awesome_bNSC5W1_6U4.mp4" type="video/mp4">
    <source src="https://shkspr.mobi/blog/wp-content/uploads/2015/11/20130210_Raspberry-Pi-MakeyMakey-Scratch-awesome_bNSC5W1_6U4.webm" type="video/webm">
    <track src="https://shkspr.mobi/blog/wp-content/uploads/2015/11/20130210_Raspberry-Pi-MakeyMakey-Scratch-awesome_bNSC5W1_6U4.en.srt" kind="subtitles" srclang="en" label="English">
</video>

<p>I think there's a problem with the subtitle track - but it is not a finalised standard yet.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=21934&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2015/11/liberate-your-youtube-videos/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="https://shkspr.mobi/blog/wp-content/uploads/2015/11/20130210_Raspberry-Pi-MakeyMakey-Scratch-awesome_bNSC5W1_6U4.mp4" length="59565615" type="video/mp4" />
<enclosure url="https://shkspr.mobi/blog/wp-content/uploads/2015/11/20130210_Raspberry-Pi-MakeyMakey-Scratch-awesome_bNSC5W1_6U4.webm" length="13554805" type="video/webm" />

			</item>
		<item>
		<title><![CDATA[Context Specific Content Surfacing]]></title>
		<link>https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/</link>
					<comments>https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Mon, 16 Apr 2012 09:42:51 +0000</pubDate>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[lootu.be]]></category>
		<category><![CDATA[lootube]]></category>
		<category><![CDATA[whatleydude]]></category>
		<category><![CDATA[YouTube]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=5538</guid>

					<description><![CDATA[In a mixed paradigm environment, how do you ensure content is surfaced which is context specific?  By which I mean - how do you make your content serve the user&#039;s time-bound constraints?  What I&#039;m trying to say is - serendipitous discovery must be restricted based on temporal imperatives.  Or, to break it down further, a user may only have a specific amount of time to dedicate to your app; how do …]]></description>
										<content:encoded><![CDATA[<p>In a mixed paradigm environment, how do you ensure content is surfaced which is context specific?</p>

<p>By which I mean - how do you make your content serve the user's time-bound constraints?</p>

<p>What I'm trying to say is - serendipitous discovery must be restricted based on temporal imperatives.</p>

<p>Or, to break it down further, a user may only have a specific amount of time to dedicate to your app; how do you deal with that?</p>

<p>In a mobile game, the interface may present the user a choice of "Quick Play" for when the user is waiting for a bus, "Medium Play" for when the user is on the bus, "Long Play" for when the user is stuck in a traffic jam.</p>

<p><a href="http://whatleydude.com/2012/04/an-idea-for-iplayer-mobile/">James Whatley blogged about this subject recently</a>. In a mobile video app - such as the BBC iPlayer - the length of time the user can spend on the app is (probably) more important than <em>any other</em> discovery method.</p>

<p><a href="http://www.flickr.com/photos/whatleydude/6908483060/" title="Thoughts by whatleydude, on Flickr"><img src="https://farm8.staticflickr.com/7242/6908483060_ed90face1b.jpg" width="500" height="323" alt="Thoughts"></a></p>

<h2 id="demo"><a href="https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/#demo">Demo</a></h2>

<p>So, I spent the weekend building a demonstration mobile service which starts with the amount of time a user is expecting to use the app.</p>

<h3 id="lootube"><a href="https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/#lootube">LooTube!</a></h3>

<p>As far as I could see, iPlayer doesn't have any public APIs, the videos don't work on all phones, and the content isn't available outside the UK.  So I have used YouTube as the basis.</p>

<p>The "User Story"?</p>

<blockquote><p>As a user, when I am sat on the toilet, I want to be able to view a range of interesting videos suitable to the length of my visit.</p></blockquote>

<p>Point your phone at <a href="https://web.archive.org/web/20130225163453/http://lootu.be/">http://LooTu.be</a> and this is what you'll see:</p>

<img src="https://shkspr.mobi/blog/wp-content/uploads/2012/04/LooTube-Screenshot-1.jpg" alt="LooTube Screenshot 1" title="LooTube Screenshot 1" width="320" height="533" class="aligncenter size-full wp-image-5540">

<p>YouTube's API only gives us three lengths of video - short, medium, and long - so there's not quite as much granularity as I would have liked.</p>

<p>Clicking one of the buttons, retrieves a list of videos based on time.  The "Quick" button will show the users videos which are less than 4 minutes long.
<img src="https://shkspr.mobi/blog/wp-content/uploads/2012/04/LooTube-Screenshot-2.jpg" alt="LooTube Screenshot 2" title="LooTube Screenshot 2" width="320" height="533" class="aligncenter size-full wp-image-5541"></p>

<p>At the moment, <a href="https://web.archive.org/web/20130225163453/http://lootu.be/">http://LooTu.be</a> doesn't allow the user to search for anything. It <strong>only</strong> takes <em>time</em> as a search query.  It does, however, randomly select between YouTubes standard "top" feeds - most viewed, top rated, most shared, top favourites, etc.</p>

<h2 id="technical-details"><a href="https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/#technical-details">Technical Details</a></h2>

<p>You can <a href="https://web.archive.org/web/20130225163453/http://lootu.be/">view the source of LooTu.be</a> - it's fairly basic HTML5 and <a href="http://jquerymobile.com/">jQuery Mobile</a>.  Feel free to laugh at my code and offer suggestions.</p>

<h2 id="thanks"><a href="https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/#thanks">Thanks</a></h2>

<p>Big thanks to Whatley for the inspiration, <a href="https://web.archive.org/web/20130522093955/https://robbi.es/">Robbie Dale</a> for the logo, and <a href="https://web.archive.org/web/20250000000000*/https://mymisanthropicmusings.org.uk/">my wife</a> for her patience this weekend!</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=5538&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Sky News Infringed My Copyright]]></title>
		<link>https://shkspr.mobi/blog/2012/01/sky-news-infringed-my-copyright/</link>
					<comments>https://shkspr.mobi/blog/2012/01/sky-news-infringed-my-copyright/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Fri, 27 Jan 2012 15:00:43 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[copyright]]></category>
		<category><![CDATA[legal]]></category>
		<category><![CDATA[sky]]></category>
		<category><![CDATA[sky news]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[YouTube]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=5301</guid>

					<description><![CDATA[UPDATE!  I have reached a settlement with Sky.  Update: 16 March, 2011. They have finally paid up!  tl;dr  Sky News stole my copyrighted work and distributed it without credit or payment.  I asked them to pay £1,500.  They refused.  Full Story  During the recent O2 brouhaha I recorded a video showing how the issue could affect people.  I deliberately gave it the standard YouTube licence rather …]]></description>
										<content:encoded><![CDATA[<h2 id="update"><a href="https://shkspr.mobi/blog/2012/01/sky-news-infringed-my-copyright/#update">UPDATE!</a></h2>

<p><a href="https://shkspr.mobi/blog/2012/01/sky-news-infringed-my-copyright/#settled">I have reached a settlement with Sky.</a></p>

<p>Update: 16 March, 2011. They have <em>finally</em> paid up!</p>

<h2 id="tldr"><a href="https://shkspr.mobi/blog/2012/01/sky-news-infringed-my-copyright/#tldr">tl;dr</a></h2>

<p>Sky News stole my copyrighted work and distributed it without credit or payment.</p>

<p>I asked them to pay £1,500.</p>

<p>They refused.</p>

<h2 id="full-story"><a href="https://shkspr.mobi/blog/2012/01/sky-news-infringed-my-copyright/#full-story">Full Story</a></h2>

<p>During the recent O2 brouhaha <a href="http://www.youtube.com/watch?v=67b4GTI2Tto">I recorded a video showing how the issue could affect people</a>.  I deliberately gave it the standard YouTube licence rather than the Creative Commons licence.</p>

<p>Later that evening, I was alerted to the fact that Sky News had broadcast my video without first seeking permission.</p>

<blockquote class="social-embed" id="social-embed-162228673632669696" lang="en" itemscope="" itemtype="https://schema.org/SocialMediaPosting"><header class="social-embed-header" itemprop="author" itemscope="" itemtype="https://schema.org/Person"><a href="https://twitter.com/gcluley" class="social-embed-user" itemprop="url"><img class="social-embed-avatar social-embed-avatar-circle" src="data:image/webp;base64,UklGRrgBAABXRUJQVlA4IKwBAADQCQCdASowADAAPrVIokunI6MhrjQLMOAWiUAXZoas60bYnkg/hyZbsApsJx0190/+zCfhp45ZqipDqm4o/kJtkuuNJwYtTyAR92hVuDEFGehmuwtub4QA/v4xfAA39gceYJakLpbICbM60Ldh3ZMtm1L/7vaboqHlX1IUXjUYv2mGFNd/rCRv+g3U5HolMo2NixwAgFjIUNsc53Xh5Q8pEbjKDklkSrM+V9wSBihp71KNNDmC4NRHZVczYfw2zPo7c+i9tot9r+BvoOv94jesSDws8k3O+0tyA1hMMkb+h5aBxiRTPJJOHO6u7TDMrM7EMHbNeFR5r4zCoKaZgRY0DJR3xTA+x04P393AQa8/Lf4itVVJjQN/hExxO/S5RHoYUXMKBF/G7h7j83QvPn62EqntUe4maBUXxlEcOjwLyCRK6nxrmyJbj6UrQ1JL2baika92uSgSvZXtyqfuPe4owGKnY0syp+BK5RNs8Itw0uv9zFpxTxFBqe38RtsNLucAzdP0NLGgTwhPnuoP+EKzUCzk9QNEwWgvBgx3lRaACqwEJ86pqTozhwAAAA==" alt="" itemprop="image"><div class="social-embed-user-names"><p class="social-embed-user-names-name" itemprop="name">Graham Cluley</p>@gcluley</div></a><img class="social-embed-logo" alt="Twitter" src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%0Aaria-label%3D%22Twitter%22%20role%3D%22img%22%0AviewBox%3D%220%200%20512%20512%22%3E%3Cpath%0Ad%3D%22m0%200H512V512H0%22%0Afill%3D%22%23fff%22%2F%3E%3Cpath%20fill%3D%22%231d9bf0%22%20d%3D%22m458%20140q-23%2010-45%2012%2025-15%2034-43-24%2014-50%2019a79%2079%200%2000-135%2072q-101-7-163-83a80%2080%200%200024%20106q-17%200-36-10s-3%2062%2064%2079q-19%205-36%201s15%2053%2074%2055q-50%2040-117%2033a224%20224%200%2000346-200q23-16%2040-41%22%2F%3E%3C%2Fsvg%3E"></header><section class="social-embed-text" itemprop="articleBody">Just did Sky News spot about the <a href="https://twitter.com/O2">@O2</a> controversy. From sound of what came down my earpiece they also used <a href="https://twitter.com/edent">@edent</a>'s vid <a href="https://www.youtube.com/watch?v=67b4GTI2Tto&amp;feature=youtube_gdata_player">youtube.com/watch?v=67b4GT…</a>None</section><hr class="social-embed-hr"><footer class="social-embed-footer"><a href="https://twitter.com/gcluley/status/162228673632669696"><span aria-label="0 likes" class="social-embed-meta">❤️ 0</span><span aria-label="2 replies" class="social-embed-meta">💬 2</span><span aria-label="0 reposts" class="social-embed-meta">🔁 0</span><time datetime="2012-01-25T17:41:44.000Z" itemprop="datePublished">17:41 - Wed 25 January 2012</time></a></footer></blockquote>

<p>I grumbled a bit on Twitter and was contacted by a representative of Sky News.  He was very quick in ascertaining that my video was used without my permission and arranged to prevent it being shown again.</p>

<p>I was not happy about this state of affairs.  BSkyB and News International have been very vocal about digital piracy and copyright infringement.  They have relentlessly pursued a copyright maximalist agenda which - I believe - is damaging to the creative industries.  Not to mention rampantly hypocritical.</p>

<p>Sky News accept user generated videos, with this stern warning:</p>

<blockquote><p>Copyright protects the interests of the people and companies who create these products. If the content or product or marks in your video are owned by someone else, you are infringing copyright and run the risk being prosecuted.

</p><p><strong>It is important that you understand that you cannot take other people's creations and use them as you see fit</strong>.

</p><p>Uploading somebody else's video is no different to taking something from a shop without paying. Copyright infringement damages the music, film and television businesses and the future development of music, film and TV programmes.

</p><p>From <a href="https://web.archive.org/web/20111220022940/http://uservideos.sky.com/site-skynews/article/index/faq.html">Sky News' Frequently Asked Questions about user videos</a>.  Emphasis added.
</p></blockquote>

<p>Sky News have a <a href="http://onlinejournalismblog.com/2009/08/19/what-happened-when-sky-news-took-images-from-twitter/">history of ignoring copyright</a> and infringing the moral rights of authors.</p>

<p>Unfortunately, the Digital Economy Act doesn't allow me to sue Sky News for distributing my content for free without my permission.  An individual can lose their Internet access for sharing a movie, however there don't seem to be any sanctions against a large company for sharing my copyrighted work without permission.</p>

<p>I don't have the resources to fight a legal battle against Sky.  So I decided to settle for cold, hard cash.</p>

<p>Originally, Sky made the following offer:</p>

<blockquote><p>For a short youtube video like that we would normally pay around £50 &amp; would be more than willing to pay an extra £25 for the fact you weren't asked in the inconvenience it has caused you.</p></blockquote>

<p>The <a href="http://www.londonfreelance.org/feesguide/index.php?&amp;section=Photography&amp;subsect=Videography&amp;page=INDEX">NUJ publish a freelance rate card</a>. The rate for freelance video should be around £300 per minute.</p>

<p>I farted in Sky's general direction.  I wanted £300 for the broadcast of the video, plus £1,200. I calculated that as £400 for them failing to ask permission, another £400 for them infringing my copyright, and then £400 for them violating my moral rights.</p>

<p>Even if they didn't agree with the above reasoning, it is usual to charge <a href="http://www.londonfreelance.org/feesguide/index.php?language=en&amp;country=UK&amp;section=General&amp;subsect=Rights+and+why+they+are+important&amp;page=Advice">four times time standard licence rate</a> when a copyright owner is asked to assign all rights away.  Effectively, Sky News had unilaterally assigned all my rights to them - so I felt justified asking for this sum.</p>

<p>Overall, I thought £1,500 was reasonable - especially when you consider that <a href="http://www.wonderlandblog.com/wonderland/2011/08/the-daily-mail-knowingly-and-commercially-used-my-photos-despite-my-denying-them-permission.html">the Daily Mail paid £2,000 for using photographs without permission</a>.</p>

<p>Sky came back with an offer of £300.</p>

<p>I pointed out that <a href="http://www.legislation.gov.uk/ukpga/1988/48/section/107">s107 of the Copyright, Designs and Patents Act 1988</a> had provisions for fines of up to £50,000, or a six month prison sentence.  In comparison £1,500 seems modest.</p>

<p>Sky replied:</p>

<blockquote><p>As I indicated, we do not yet agree on a sensible figure for this use.

</p><p>Bearing in mind you are now invoking the Copyright Designs and Patents Act I have placed this matter in the hands of our lawyers.

</p><p>This does not represent an unwillingness to come to an agreement between us but, unfortunately, it is likely to slow the progress slightly.</p></blockquote>

<p>Now I'm waiting to hear back from their lawyers.  I wonder what their hourly rate is?</p>

<p>I'll update this post when I know more...</p>

<h1 id="a-settlement"><a name="settled">A Settlement</a><a href="https://shkspr.mobi/blog/2012/01/sky-news-infringed-my-copyright/#a-settlement">🔗</a></h1>

<p>I have accepted an offer of £300.  A few minutes ago, I received this email from Sky:</p>

<blockquote>After consulting with our Sky lawyers our position is that we believe a £300 settlement is a fair and appropriate sum.
Our position is:
<ul>
<li>The £300 is in respect of what you describes as "infringement of copyright" rather than any "union rate";</li>
<li>Contrary to what you claim, we did not act as if you had assigned us all rights. Specifically, we did not claim ownership nor seek to profit from it by licensing to others;</li>
<li>Criminal liability will not attach in relation to an inadvertent use of footage;</li>
<li>English law does not recognise violation of moral rights;</li>
<li>There is no authority that an infringement in these circumstances attracts four times the usual licence fee.  To the contrary, the usual measure is what the reasonable cost of licensing would have been.</li>
<li>Our offer is generous for the reasons above and we will not increase it.</li>
</ul>
<p>May I also stress that when you are relating this issue to third parties on whatever platform I would consider it unfair if you did not relay the fact that we immediately acknowledged your copyright and sought to bring redress. I stress, once again, that we take copyright and its infringement very seriously at Sky News.</p></blockquote>

<p>I'm not a copyright lawyer, so am in no position to argue against their formidable legal might.  I have invoiced them for £300.  I must point out that - once I contacted them - Sky were very quick to take down the infringing content and have been unfailingly polite in their dealings with me.</p>

<p>I will be donating £100 to both <a href="http://www.openrightsgroup.org/">The Open Rights Group</a> and <a href="http://www.mysociety.org/donate/">MySociety</a>.   And drinking the rest.</p>

<p>Thank you for all your comments, tweets, and messages of support.</p>

<h3 id="footnote"><a href="https://shkspr.mobi/blog/2012/01/sky-news-infringed-my-copyright/#footnote">Footnote</a></h3>

<p>I'm currently on holiday - so comment moderation and updates may be delayed.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=5301&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2012/01/sky-news-infringed-my-copyright/feed/</wfw:commentRss>
			<slash:comments>22</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Mobile Badvertising: Sony Pictures - Easy A]]></title>
		<link>https://shkspr.mobi/blog/2010/10/mobile-badvertising-sony-pictures-easy-a/</link>
					<comments>https://shkspr.mobi/blog/2010/10/mobile-badvertising-sony-pictures-easy-a/#respond</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Mon, 11 Oct 2010 19:26:22 +0000</pubDate>
				<category><![CDATA[badvertising]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[advertising]]></category>
		<category><![CDATA[sony]]></category>
		<category><![CDATA[YouTube]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=2637</guid>

					<description><![CDATA[Sometimes a mobile advert is just so bad that you wonder what drugs the people who commissioned were on.  Easy A is new film aimed squarely a the youth market.  Perfect fodder for mobile advertising.   Cute little advert, doesn&#039;t say what it will link to, but other than that, not bad.  So let&#039;s click through and see what happens.  Sweet! YouTube has an excellent mobile optimised site.  The ab…]]></description>
										<content:encoded><![CDATA[<p>Sometimes a mobile advert is<em> </em>just <em>so</em> bad that you wonder what drugs the people who commissioned were on.</p>

<p>Easy A is new film aimed squarely a the youth market.&nbsp; Perfect fodder for mobile advertising.</p>

<p><img class="aligncenter size-full wp-image-2638" title="Easy A Advert" src="https://shkspr.mobi/blog/wp-content/uploads/2010/10/5802641e690d5afa088d5238224df2e8-b.png" alt="Easy A Advert" width="320" height="48">
Cute little advert, doesn't say what it will link to, but other than that, not bad.&nbsp; So let's click through and see what happens.
<img class="aligncenter size-full wp-image-2639" title="Mobile YouTube" src="https://shkspr.mobi/blog/wp-content/uploads/2010/10/snap20101011_185504.png" alt="Mobile YouTube" width="336" height="560">
Sweet! YouTube has an excellent mobile optimised site.&nbsp; The ability to share the video on Facebook and Twitter is <em>sure</em> to make this baby go viral. Right? <strong>Right?</strong>
<img class="aligncenter size-medium wp-image-2640" title="Sorry, this video cannot be played on mobile" src="https://shkspr.mobi/blog/wp-content/uploads/2010/10/snap20101011_185548-300x180.png" alt="Sorry, this video cannot be played on mobile" width="300" height="180"></p>

<p>As the kids say, <strong>WTF</strong>?</p>

<p>Sony Pictures have deliberately disabled mobile playing for <a href="https://www.youtube.com/watch?v=eCRbC6pq0LA">their video</a>.&nbsp; As far as I can tell, for <strong>all</strong> their videos.</p>

<p>All is not lost, though.&nbsp; Helpfully, someone has been very naughty and <strong>illegally</strong> uploaded the video for us all to enjoy.
<a href="https://shkspr.mobi/blog/wp-content/uploads/2010/10/snap20101011_190023.png"><img src="https://shkspr.mobi/blog/wp-content/uploads/2010/10/snap20101011_190023-180x300.png" alt="Various Uploads" title="Various Uploads" width="180" height="300" class="aligncenter size-medium wp-image-2646"></a></p>

<h2 id="lessons-learned"><a href="https://shkspr.mobi/blog/2010/10/mobile-badvertising-sony-pictures-easy-a/#lessons-learned">Lessons Learned</a></h2>

<ul>
    <li>Always test your advert - especially on the platforms for which they're intended.</li>
    <li>If you're a major movie studio and you don't want your content pirated - make it easily available.</li>
</ul>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=2637&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2010/10/mobile-badvertising-sony-pictures-easy-a/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Embedding Mobile YouTube in Dabr / Twitter]]></title>
		<link>https://shkspr.mobi/blog/2009/09/embedding-mobile-youtube-in-dabr-twitter/</link>
					<comments>https://shkspr.mobi/blog/2009/09/embedding-mobile-youtube-in-dabr-twitter/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Sun, 27 Sep 2009 10:15:14 +0000</pubDate>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[dabr]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[YouTube]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=554</guid>

					<description><![CDATA[I&#039;ve decided to add a preview of YouTube videos into Dabr, the mobile Twitter service.  The code is fairly simple - although I still suck at regular expressions.  if (preg_match_all(&#039;#youtube.com/watch?v=([_-dw]+)#&#039;, $tmp, $matches, PREG_PATTERN_ORDER) &#62; 0)  {   foreach ($matches[1] as $match)   {   $images[] = theme(&#039;external_link&#039;, &#34;http://m.youtube.com/watch?v={$match}&#34;, &#34;&#60;img…]]></description>
										<content:encoded><![CDATA[<p>I've decided to add a preview of <a href="http://www.youtube.com/">YouTube</a> videos into <a href="http://m.dabr.co.uk/">Dabr</a>, the mobile <a href="http://twitter.com">Twitter</a> service.</p>

<p>The <a href="http://code.google.com/p/dabr/source/detail?r=192">code is fairly simple</a> - although I still suck at regular expressions.</p>

<pre><code class="language-php">if (preg_match_all('#youtube.com/watch?v=([_-dw]+)#', $tmp, $matches, PREG_PATTERN_ORDER) &gt; 0)
 {
  foreach ($matches[1] as $match)
  {
  $images[] = theme('external_link', "http://m.youtube.com/watch?v={$match}", "&lt;img src='http://i.ytimg.com/vi/{$match}/1.jpg' class='twitpic' /&gt;");
  }
 }
</code></pre>

<p>Here's how it looks.&nbsp; A user writes a tweet which contains a YouTube URL</p>

<p></p><div id="attachment_555" style="width: 490px" class="wp-caption aligncenter"><img aria-describedby="caption-attachment-555" class="size-full wp-image-555" title="Capture7_55_25" src="https://shkspr.mobi/blog/wp-content/uploads/2009/09/Capture7_55_25.jpg" alt="A thumbnail embedded in a tweet" width="480" height="320"><p id="caption-attachment-555" class="wp-caption-text">A thumbnail embedded in a tweet</p></div><p></p>

<p>The thumbnail is displayed and hyperlinked to the <a href="http://m.youtube.com/">mobile version of YouTube</a></p>

<p></p><div id="attachment_556" style="width: 490px" class="wp-caption aligncenter"><img aria-describedby="caption-attachment-556" class="size-full wp-image-556" title="Capture7_55_41" src="https://shkspr.mobi/blog/wp-content/uploads/2009/09/Capture7_55_41.jpg" alt="Pointing to Mobile YouTube" width="480" height="320"><p id="caption-attachment-556" class="wp-caption-text">Pointing to Mobile YouTube</p></div><p></p>

<p>When clicked on, the user is taken straight to the video's page.</p>

<p></p><div id="attachment_557" style="width: 490px" class="wp-caption aligncenter"><img aria-describedby="caption-attachment-557" class="size-full wp-image-557" title="Capture8_35_37" src="https://shkspr.mobi/blog/wp-content/uploads/2009/09/Capture8_35_37.jpg" alt="The Destination" width="480" height="320"><p id="caption-attachment-557" class="wp-caption-text">The Destination</p></div><p></p>

<p>There were three main issues with this code</p>

<ol>
    <li>How do we extract the video's ID from the URL? YouTube video IDs contain alphanumeric character and the - and _ characters. They can also have other parameters passed.&nbsp; There can also be text <em>after</em> the URL.&nbsp; The regular expression above takes care of them.</li>
    <li>How do we get the thumbnail?&nbsp; Previously, I had been using the image URL given in the m.YouTube page - something like http://i.ytimg.com/vi/plvE4882B7Y/default.jpg?w=80&amp;h=60 - however those URLs now need signing. So, using the <a href="http://code.google.com/apis/youtube/2.0/reference.html">YouTube API</a>, I took a look at the Video Information XML file - http://gdata.youtube.com/feeds/api/videos/plvE4882B7Y - it showed that all videos have a full sized thumbnail - http://i.ytimg.com/vi/plvE4882B7Y/0.jpg and a mobile friendly thumbnail - http://i.ytimg.com/vi/plvE4882B7Y/1.jpg</li>
    <li>How do we link to the mobile version of YouTube?&nbsp; There are two ways to do this - either allow YouTube to detect the User-Agent and redirect based on that, or simply point to the mobile version.&nbsp; While a regular YouTube link looks like http://<strong>www</strong>.youtube.com/watch?v=plvE4882B7Y the mobile one simply substitutes www for m : http://<strong>m</strong>.youtube.com/watch?v=plvE4882B7Y</li>
</ol>

<p>TODO</p>

<p>For phones which support playing YouTube videos inline (Android, some Nokias etc) I may actually embed the video, rather than just link to it.&nbsp; I may also detect Desktop Browsers and send them to the regular version of YouTube.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=554&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2009/09/embedding-mobile-youtube-in-dabr-twitter/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[YouTube and QR Codes]]></title>
		<link>https://shkspr.mobi/blog/2009/07/youtube-and-qr-codes/</link>
					<comments>https://shkspr.mobi/blog/2009/07/youtube-and-qr-codes/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Mon, 13 Jul 2009 10:33:30 +0000</pubDate>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[qr]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[qr code]]></category>
		<category><![CDATA[YouTube]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=273</guid>

					<description><![CDATA[I haven&#039;t seen this mentioned anywhere else.  It would appear that the mobile version of YouTube now includes links to QR codes, so you can share the video with your friends.  I&#039;ve only seen this using the Android browser, I&#039;m not sure if it&#039;s available on other devices.  Browsing http://m.youtube.com/ at the bottom is a new link  A link to a QR code  Clicking on it takes you to a QR code  The QR …]]></description>
										<content:encoded><![CDATA[<p>I haven't seen this mentioned anywhere else.  It would appear that the <a href="http://m.youtube.com/">mobile version of YouTube</a> now includes links to <a href="https://shkspr.mobi/qr.php">QR codes</a>, so you can share the video with your friends.  I've only seen this using the Android browser, I'm not sure if it's available on other devices.</p>

<p>Browsing <a href="http://m.youtube.com/">http://m.youtube.com/</a> at the bottom is a new link</p>

<p></p><div id="attachment_274" style="width: 330px" class="wp-caption alignnone"><img aria-describedby="caption-attachment-274" class="size-full wp-image-274" title="ytqr0" src="https://shkspr.mobi/blog/wp-content/uploads/2009/07/ytqr0.png" alt="A link to a QR code" width="320" height="480"><p id="caption-attachment-274" class="wp-caption-text">A link to a QR code</p></div><p></p>

<p>Clicking on it takes you to a QR code</p>

<p></p><div id="attachment_275" style="width: 330px" class="wp-caption alignnone"><img aria-describedby="caption-attachment-275" class="size-full wp-image-275" title="ytqr2" src="https://shkspr.mobi/blog/wp-content/uploads/2009/07/ytqr2.png" alt="The QR code" width="320" height="480"><p id="caption-attachment-275" class="wp-caption-text">The QR code</p></div><p></p>

<p>It's using the <a href="http://code.google.com/apis/chart/">Google Chart API</a> to generate the code.</p>

<p></p><div id="attachment_276" style="width: 330px" class="wp-caption alignnone"><img aria-describedby="caption-attachment-276" class="size-full wp-image-276" title="ytqr3" src="https://shkspr.mobi/blog/wp-content/uploads/2009/07/ytqr3.png" alt="The Googe Chart API in use" width="320" height="480"><p id="caption-attachment-276" class="wp-caption-text">The Googe Chart API in use</p></div><p></p>

<p>Will this spur QR codes into the mainstream? I hope so!</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=273&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2009/07/youtube-and-qr-codes/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[WordPress Plugin - YouTube for XHTML and Mobile]]></title>
		<link>https://shkspr.mobi/blog/2009/07/wordpress-plugin-youtube-xhtml-mobile/</link>
					<comments>https://shkspr.mobi/blog/2009/07/wordpress-plugin-youtube-xhtml-mobile/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Sun, 12 Jul 2009 16:41:20 +0000</pubDate>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[YouTube]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=252</guid>

					<description><![CDATA[This blog is XHTML 1.0 Strict.  Unfortunately, the code produced by YouTube for embeding their videos isn&#039;t.  Nor is it compatible with the dotMobi WordPress Mobile Pack.  This scrap of code is a WordPress Plugin.  it allows me to write something like [youtube id=&#34;p5ACl4iBGd0&#34;]  The code then outputs either the XHTML 1.0 embeding code or the XHML-MP code which links to the mobile version of the…]]></description>
										<content:encoded><![CDATA[<p>This blog is XHTML 1.0 Strict.  Unfortunately, the code produced by YouTube for embeding their videos isn't.  Nor is it compatible with the <a href="http://mobiforge.com/running/story/the-dotmobi-wordpress-mobile-pack">dotMobi WordPress Mobile Pack</a>.</p>

<p>This scrap of code is a WordPress Plugin.  it allows me to write something like
<code>[youtube id="p5ACl4iBGd0"]</code></p>

<p>The code then outputs either the XHTML 1.0 embeding code or the XHML-MP code which links to the mobile version of the site</p>

<pre>function youtube_func($attr)
 {
 //Get the name of the Wordpress Template being used
 $name = get_template();

 //If this *isn't* a mobile theme
 if(stristr($name, 'mobile') === FALSE)
 {
 //Link to embeded YouTube video source
 $ytURL = "http://www.youtube.com/v/" . $attr['id'];

 //XHTML 1.0 Strict way of embeding movies
 $s = "&lt;object type="application/x-shockwave-flash" style="width:450px; height:366px;" data="" . $ytURL . ""&gt;"
 . "&lt;param name="movie" value="". $ytURL . "" /&gt;"
 . "&lt;/object&gt;";

 return $s;

 }
 else //This is a mobile theme
 {
 //Link to mobile YouTube
 $mYtURL = "http://m.youtube.com/watch?v=" . $attr['id'];
 //Image of the video
 $mYtIMG = "http://i.ytimg.com/vi/" . $attr['id'] . "/default.jpg?w=128&amp;amp;h=96";

 $s = "&lt;a href="" . $mYtURL . ""&gt;"
 . "&lt;img src="" . $mYtIMG . "" /&gt;"
 . "&lt;/a&gt;";

 return $s;
 }
 }
 add_shortcode('youtube', 'youtube_func');</pre>

<p>Many thanks to the <a href="http://codex.wordpress.org/Shortcode_API">Wordpress API</a>, this excellent <a href="http://planetozh.com/blog/2008/03/wordpress-25-shortcodes-api-overview/">Wordpress Plugin Tutorial</a>, and this <a href="http://www.tools4noobs.com/online_tools/youtube_xhtml/">Valid XHTML YouTube embed code generator</a>.</p>

<p>You can <a href="http://wordpress.org/extend/plugins/youtube-xhtml-and-mobile/">download the plugin from WordPress</a>.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=252&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2009/07/wordpress-plugin-youtube-xhtml-mobile/feed/</wfw:commentRss>
			<slash:comments>11</slash:comments>
		
		
			</item>
	</channel>
</rss>
