<?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>vlc &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/vlc/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Sat, 18 Jan 2025 11:12:20 +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>vlc &#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>
	</channel>
</rss>
