Wikipedia:Reference desk/Archives/Computing/2016 April 5

= April 5 =

How do I save videos on the internet to my computer or hard drive?


I often run across various videos on the internet, on various sites (for example, You Tube and many other sites). Sometimes, I go back to view the videos again, and they are gone. I assume that the person who posted them has removed them. Or maybe the site itself has removed them, for whatever reason. Who knows? Anyways, it often upsets me. So, here is my question. When I run across a video on the internet, is there some way that I can save it onto my computer or my hard drive or wherever? So that I can prevent the possibility that I return in the future and the video is gone? Thanks. Joseph A. Spadaro (talk) 05:39, 5 April 2016 (UTC)


 * youtube-dl is good. It's free and open-source and actively maintained and supports a lot of web sites, not just YouTube. It's a command-line utility. If you want a GUI frontend, you could try youtube-dlG. I haven't used it but it's also free and open-source. -- BenRG (talk) 05:50, 5 April 2016 (UTC)

A command-line interface means that you have to type commands that the program will execute. Remember MS DOS? That is a command-line interface. A GUI is a Graphical user interface, which is intended to be more userfriendly. A GUI usually has buttons you can click on with a mouse. Open source software is computer software with its source code made available with a license in which the copyright holder provides the rights to study, change, and distribute the software to anyone and for any purpose. The Quixotic Potato (talk) 06:34, 5 April 2016 (UTC)
 * Thanks. But, your reply was somewhat technical.  I didn't understand a word you said.  Please clarify.  Thanks. Joseph A. Spadaro (talk) 05:55, 5 April 2016 (UTC)
 * Click here, to download the software, open it and follow the instructions on your screen.


 * I tried it a dozen times. Doesn't do anything. Joseph A. Spadaro (talk) 07:29, 5 April 2016 (UTC)
 * Parse it as "Click here to download the software. Then open the file downloaded and follow the instructions on your screen". If I click the link, I download a zip file from gitub., in particular "youtube-dl-gui-0.3.8-win-setup.zip" which may or may not be a Windows installer (I don't do Windows). I don't vouch for the integrity of that file.... --Stephan Schulz (talk) 07:46, 5 April 2016 (UTC)


 * I was able to download the software onto my PC. Yes.  But, when I tried to apply it to a video, I kept getting an error message.  This is the video that I am trying to download onto my computer: Hundreds rally, protest at Hartford city council meeting.  Is there some other issue at play here?  Thanks.   Joseph A. Spadaro (talk) 19:28, 5 April 2016 (UTC)


 * You can download that video by clicking "Embed" in the upper left corner of the player, taking the "src" part of the HTML, and passing that to youtube-dl. In other words, given the HTML that looks like
 *   
 * You can download the video by typing
 *  youtube-dl "http://player.ooyala.com/iframe.js#ec=dqZG5sMjE6UYQnXkUMlowUc5KmXZR5Y3&pbid=XXXXXX" 
 * If you're using a GUI frontend, omit the quotes (although it may also work with the quotes, and even with all of the surrounding crud). -- BenRG (talk) 01:30, 6 April 2016 (UTC)


 * Thanks. I will try that when I get to my computer at home.  Hopefully, that will work.  Thanks.   Joseph A. Spadaro (talk) 02:49, 6 April 2016 (UTC)


 * Wow, it worked! Can't believe it!  Thanks!  Joseph A. Spadaro (talk) 17:14, 6 April 2016 (UTC)


 * Now, will this work with any video? I have to do the same steps as above (click "embed"; cut/paste the "src" info; etc.)?   Joseph A. Spadaro (talk) 17:14, 6 April 2016 (UTC)


 * It will probably work if youtube-dl supports downloading that video at all. You might have better luck copy-pasting the whole hunk of HTML instead of just the "src" part (if there is one). However, if you do that on the command line, you have to quote it properly, which is tricky in general. In a GUI frontend you can probably just paste it in. -- BenRG (talk) 20:11, 6 April 2016 (UTC)


 * I'm not sure what advantages the command line tool has. A simple way is using Keepvid website. Just paste youtube address (url) and click "Download" (the one to the right of the address, the other buttons are deceptive ads). It will give you the options of different downloads in terms of format, quality, video/audio, etc. No longer a penguin (talk) 07:44, 5 April 2016 (UTC)
 * The advantage is that it lives in the shell, and therefore inherits all the advantages of the environment, be it piping, scripting, etc. There is also the advantage that the developer doesn't have to write a GUI ;) SemanticMantis (talk) 14:12, 5 April 2016 (UTC)
 * But I wouldn't be surprised if coding something like Keepvid is actually similar to coding Youtube-dl. Even if it's using standard libraries to download, you still need to code the integration with these libraries including I presume the handling of cookies. With coding something like Keepvid, you're relying on the browser for all of that. The GUI just consists of telling the browser what to display the same as any HTML including CSS etc. Nil Einne (talk) 06:02, 6 April 2016 (UTC)
 * I generally use Keepvid on the occasion I need to download Youtube videos (although I do this a lot less than before). It normally works well but does to some extent require you to trust whoever is behind the website particularly when Java is needed (not normally needed for Youtube nowadays AFAIK). I don't think Keepvid is open source, but since it's mostly Javascript with some Java, you can review it but it can also be updated any time. While you need to trust the source+whoever reviews it (presuming you didn't) for the commandline tool, the level of trust is different since I presume the code can't be updated without your involvement. On the other hand, browsers are developed as fairly sandboxed environments. It's also probably not the best option if you need to download lots of files in one go. And with the way Youtube works now, if you want certain qualities (particularly 1080P) you may need to download the video and audio seperately so either need a video player that can handle that or need to mux them with a seperate program. I don't know if Youtube-dl has a built in muxer, but it can't be that hard to integrate one (whether you use the command line directly or a GUI with support for that built in). The number of sites supported by Keepvid is likely smaller then Youtube-dl The big advantage of course with Keepvid is that you don't need anything other than your browser and something to play the video provided Javascript is enabled (and the security settings don't otherwise prevent it running) and the site doesn't need Java forn downloads. (If it does then you need Java in addition and security settings to allow it.)  Nil Einne (talk) 07:14, 6 April 2016 (UTC)
 * Youtube-dl does combine audio and video for you (if you have ffmpeg installed; it's bundled with the Windows version of youtube-dlG).
 * Youtube-dl seems to support a lot more web sites than KeepVid (for example, I can't get KeepVid to download the video from fox61.com that was mentioned earlier in this thread).
 * Also, I prefer free software hosted on GitHub to web services supported by fake-download-button adware/scareware/malware scam ads. And the arguments for downloading videos in the first place apply also to software. -- BenRG (talk) 20:38, 6 April 2016 (UTC)

Thanks, all. Joseph A. Spadaro (talk) 17:55, 7 April 2016 (UTC)

analysis of an algorithm
I was asked, given an array A[1...n] of positive integers, to create an array S[1...n] where S[i] is the maximum of all k such that all elements at places A[i-k...i] are not bigger than A[i].The creation of S should be at O(n). The hint says that we may use a stack.

For example,

I thought about a trivial algorithm that works at O(n^2) and scans all numbers from A[i] backwards until it finds j such that A[j]>A[i]. Another algorithm I thought on, that doesn't use a stack, works in the following way: if A[i]13 and S[9]=4 therefore we jump 4 places backwards and arrive at index=5; 15>14 and S[5]=2 so we jump 2 places backwards an arrive at index=3. now 15<18 therefore S[10] would be the sum of the distances we traveled plus one: 4+2+1=7. The latter algorithm is clearly more efficient than the naive one, but I don't know how to assess its complexity.

I'd appreciate it if someone could help me with a way to asses the complexity of the algorithm or, preferably, give an hint regarding the solution that uses a stack.

Thanks! — Preceding unsigned comment added by 212.179.21.194 (talk) 08:21, 5 April 2016 (UTC)


 * Your algorithm seems fine, it's just the complexity that's a bit tricky. Basically, when calculating S[i], you need to examine A[i] and A[i-1]. If A[i-1]>A[i], that's enough to calculate S[i]. If you're unlucky, you might have to examine up to n other S values, but when you encode S[i] you're effectively creating a "short-cut" ensuring that you'll never have to examine those S values again. So the total complexity is something like 2n for the lucky cases, plus a total of n for shortcut-creation, which is O(n). Or something like that. Unsure about the stack though. 192.176.1.95 (talk) 09:18, 5 April 2016 (UTC)
 * Well, a sequence breaks whenever there is a value lower than the preceding one. As long as the sequence is ascending, it may beat the previous maximum, in which case the preceding values will be captured. So whenever your sequence breaks, put the index of the highest value on the stack. If a new sequence beats that value, pop the value and extend your sequence to the previous maximum, until you run out of maxima or the old maximum is higher than your current value. Thus, you can do the thing with only one pass over the array, and in O(n). --Stephan Schulz (talk) 09:37, 5 April 2016 (UTC)
 * Thank you both! I'd still be happy to read a more systematic way to think about the complexity of the algorithm, although I share the impression it's O(n). Stephan Schulz, when talking about "maximum", do you mean maximum value of A or of S? "the index of the highest value" - of the ascending series until the "breaking point"? it would be helpful if you could add a short example. 212.179.21.194 (talk) 09:53, 5 April 2016 (UTC)
 * Both algorithms are very similar. After computing S(10) in your example, in both algorithms, index 10 and index 3 are the only ones that are alive in the sense that we might need to examine them again in the future. In the stack case, after computing S(10) we have a stack with (index 10 = 15) on top and (index 3 = 18) underneath. If we examined a new element A(11), we would compare it to the top element in the stack, which is 15. If it is smaller than 15, we add it to the stack, and note that S(11) is 11-10 (the index of the top element). If it is larger than 15, we pop the stack and compare A(11) to the new top element, which is 18.


 * The comparisons being made are the same in both algorithms, but the complexity of the stack variant is a bit easier to figure out. Instead of creating a "short-cut" that ensures we'll never have to inspect an element again, we're removing the element from a stack which has a total of at most n elements.192.176.1.95 (talk) 10:58, 5 April 2016 (UTC)


 * Maybe amortized analysis is the more systematic way you're looking for. The idea is that you can spend one step at any time to purchase a token good for one free step, and leave it somewhere to be used later. In this case, when you push an item on the stack, you also push enough tokens to pay for comparing against and popping that stack item once. Then for each array element you 1. compare against and pop smaller values from the stack (free, paid for by tokens); 2. compare against top of stack and find it's larger (cost: one comparison); 3. push current element with tokens (cost: 1 push + 1 comparison + 1 pop). With this rebudgeting of the steps, the work for each array element is constant, so the algorithm is manifestly linear. I omitted the arithmetic to calculate the output values, but it works by the same principle. -- BenRG (talk) 17:00, 5 April 2016 (UTC)

Reduce Video Volume
Pretty simple, I have a video file I recorded and edited (currently saved as a .avi) and for some reason, my video editor software doesn't have options to change the volume. Usually I use Avidemux for editing, but searching online brings up a bunch of forum threads where people have asked this question, been given simple instructions and responded to say they don't work. I have also followed the same instructions and found that they don't work, hence the simple conclusion that Avidemux cannot change the volume of this file type.

So, looks like I'll have to find alternative software, the internet is full of free to download video editing programs, half of which are viruses and half are massive things that have far more options and settings than I need. Any suggestions of software I can get just to carry out this one simple task?

Thank you,

86.24.139.55 (talk) 16:14, 5 April 2016 (UTC)


 * I use Linux, so I use linux-based video editors like Avidemux. What I normally do is save the audio track separately. Then, I edit that in Audacity. After I get it just the way I want it, I add it back to the video. In my experience, Audacity is a million times better at audio editing than the video editors. If you have a fast machine that handle both a video and audio programming running at the same time, you can click play in both the audio and video programs to get a nearly-synced test playback. Usually though, you must make a change, reimport, play, make a change, reimport, play... 199.15.144.250 (talk) 16:34, 5 April 2016 (UTC)


 * I've done that in the past, back when I had Windows Live movie maker to paste the two parts back together, never got around to learning how to do it in any other software since that crashed. Does Avidemux have an option to export audio and reimport it and add to a video? 86.24.139.55 (talk) 17:57, 5 April 2016 (UTC)


 * Any demuxer which supports the container format of your file should be able to seperate the audio and video. You can then use a muxer, whether the same program or a different one, which supports the container format you want, again whether the same one or different one, to combine them again. In terms of increasing the volume, I think the bigger issue is whether you can decompress and recompress it as I assume it's compressed. Most common unencrypted audio file formats can be decompressed by something (or otherwise converted to simple uncompressed PCM that most audio software can understand). And worst case scenario if you can play it back somehow on your PC, you can probably use the analog hole. I don't think this is likely to be a problem though since AFAIK even Dolby TrueHD and DTS-HD can be decoded in some way although I'm not certain if they can decode all channels and losslessly, although most video aren't intended to have these formats exclusively anyway.  However I don't believe there's any open source or freely available software capable of encoding to a number of audio formats like DTS-HD or Dobly TrueHD. So depending on what your source audio format is, you may need to change it to something else. Although I'm surprised anyone would store any such format in AVI, perhaps the more likely problem is if it's some weird audio format which is not supported by any modern software. Particularly in the later, there doesn't seem to be a good reason to keep the older format anyway so just encode it to Advanced Audio Coding or Opus (audio format) (or perhaps MP3 if you have real ancient devices.)  BTW certain audio formats have some sort of gain or other such volume setting standard, which you can try to use to adjust the audio without recompressing, but playback software don't always implement proper support for these settings so they can be a bit hit and miss. (I also wonder if it's theoretically possible to increase volume directly on the compressed format somehow. Not exactly lossless but not exactly recompressing then decompressing. But even if this is possible I don't think it's particularly common and I also wonder how it will deal with clipping and dynamic range compression issues anyway.)  I don't know how relevant this is but note if you have a decent video player, you should be able to play the files in perfect sync without muxing them, although you will need the modified audio and video. You could potentially use a frame server to edit the video if it fulfills you're need presuming your computer is able to handle any processing real time. Probably similar for the audio. Alternatively just play back both files at nearly the same time if you don't care about perfect synchronisation. If you aren't editing the video, I imagine most audio processing can be handled real time on any modern computer provided the software allows it.  Nil Einne (talk) 07:05, 6 April 2016 (UTC)


 * Something like this?. See ffmpeg.org. The Quixotic Potato (talk) 16:34, 5 April 2016 (UTC)

iPad problem
I have an annoying problem with my iPad and iPod. When browsing the Internet and scrolling up and down pages, it sometimes highlights the word my finger is over, giving me a black box with options to copy, define, or share, covering the text above. I need to tap the screen multiple times to get rid of the box. Is there any way to do it permanently? KägeTorä - (影虎) ( もしもし！ ) 17:37, 5 April 2016 (UTC)


 * Most people just train their fingers a bit. The problem is that you're not inputing a "swipe", you're inputting a "long press" which triggers highlighting. Here are instructions on how to disable that "right click"/"long press" contextual pop-up menu, though they also recommend to not do it. These   also discuss how to eliminate/change the contextual menu, but more from a developer perspective. 19:35, 5 April 2016 (UTC)
 * Or maybe this is more relevant. I forget whether the copy menu triggers on long press, but this shows how to disable the whole ability to select text. That will of course prevent you from ever copy/pasting anything, but perhaps that's what you want. SemanticMantis (talk) 19:40, 5 April 2016 (UTC)