Wikipedia:Reference desk/Archives/Computing/2020 December 21

= December 21 =

No sound when playing downloaded YouTube video on VLC
I lately saw this video about when the star Betelgeuze is going to explode as a supernova, so I downloaded the video (it's almost two hours long) via an on-line YouTube downloader to an MP4 file so I could watch it later with VLC on my Fedora 32 Linux system. So, a few days ago, I tried to watch it. The video played all right, but the audio didn't. There was no sound of any kind, even though I turned both the physical volume control on my speakers and the logical volume controls on the XFCE panel and VLC to the maximum.

However, when I resorted to playing the original video straight from YouTube, I could hear the sound all OK. So the problem is not in Fedora 32 Linux or in my physical hardware. It's either in VLC or the downloaded MP4 file. What could be the reason here? How can I check if the MP4 file has sound at all? J I P &#124; Talk 00:41, 21 December 2020 (UTC)
 * , I won't be helping someone violate YouTube's terms of service. Elizium23 (talk) 00:48, 21 December 2020 (UTC)
 * Why don't you leave this message on every message board thread about web scraping, in case someone cares? 95.168.116.108 (talk) 16:57, 21 December 2020 (UTC)
 * I don't think it's a good look for Wikipedians to assist each other in violating copyright when the site has particularly strict rules against doing it on the site itself. Elizium23 (talk) 00:11, 22 December 2020 (UTC)

ffmpeg -i 

Then Google the specific command line options needed for the audio codec you have. ffprobe also has some ways of verifying what streams are there.

Jdphenix (talk) 04:39, 21 December 2020 (UTC)
 * All the formats youtube serves for that video either have AAC or Opus audio, both of which should be included in the default codec package VLC ships with. If you can play other audio files with VLC, it's more likely the downloader either didn't include the audio, or munged it somehow. I recommend using an offline extractor like youtube-dl, they tend to be more reliable. 71.190.77.44 (talk) 05:26, 21 December 2020 (UTC)
 * For clarity, when you watch a youtube video, youtube's servers generally send the audio and video tracks as separate streams, which the client (the in-browser youtube player, the official or unofficial phone apps, etc) is responsible for recombining. This is done to allow youtube to support as many possible devices (who may have specific video or audio limitations requiring specific format combinations) without having to keep around a specific copy of each video for each possible device. It's this recombining step that I suspect the online downloader got wrong. 71.190.77.44 (talk) 05:38, 21 December 2020 (UTC)
 * I just watched another video (not downloaded from YouTube) on VLC and the sound worked all OK. So as the problem is not in the computer itself, in Linux, or in VLC, it must be in the MP4 file I downloaded. J I P  &#124; Talk 16:32, 21 December 2020 (UTC)
 * Yes. You could post mediainfo output if you want to troubleshopt it further, but the easiest solution is to use another way to download the video. 95.168.116.108 (talk) 16:57, 21 December 2020 (UTC)`

In VLC media player select Tools -> Codec Information -> Codec. This will show whether your downloaded file has an audio stream. Some on-line downloader sites impose a time limit. You may also try using VLC to download a file by selecting Media -> Open Network Stream -> (paste the URL) https://www.youtube.com/watch?v=a-urLDGwW7M  -> Convert (choose profile e.g. Video H264 + MP3 (MP4) ) -> Name a destination file -> Start 84.209.119.241 (talk) 17:21, 21 December 2020 (UTC)

mv with tr not working when result contains spaces
Here is a question about the Unix command line. I have a file containing punctuation marks. I want to rename the file so that the punctuation marks get converted to other punctuation marks.

If I want to convert underscores to hyphens,  works OK. But this doesn't work if I want to convert them to spaces. gives me an error:.

"Why don't I simply type ?" you may ask. This is because the operation is supposed to be part of a script to convert hundreds of file names. How can I get the syntax right? J I P &#124; Talk 22:15, 21 December 2020 (UTC)


 * The problem is that the shell breaks the input into tokens at spaces. So your result is not one file name, but multiple ones. You can construct the name to be in single quotes (just get your echo to spit out quoted quotes at the very beginning and end). --Stephan Schulz (talk) 22:37, 21 December 2020 (UTC)


 * I think you need \\ to get the end result of \. Or, encase the new name in quotes.   For example: , then  .  My shell programming is a little rusty, but I think that will work.  RudolfRed (talk) 22:43, 21 December 2020 (UTC)
 * Replacing \ with \\ didn't work, but using the variable NEWNAME and putting it in quotes did. Thanks! J I P  &#124; Talk 22:47, 21 December 2020 (UTC)
 * Or use directly   --Lambiam 11:53, 22 December 2020 (UTC)
 * You've fallen prey to the hammer-and-nail problem. "I know about tr and backticks; therefore, I need to use tr and backticks to munge file names". In modern shells like bash it's trivial:


 * If you need a strictly-POSIX solution, that link gives you some as well. Unix filenames can contain any non-null character, and yes this includes things like newlines. --47.152.93.24 (talk) 17:17, 26 December 2020 (UTC)