BaShMu Posted July 24, 2019 Report Share Posted July 24, 2019 Introduction I'm writing this as a quick walk through for Ubuntu Linux users who have a Pioneer AVH-270BT fitted in their vehicle and are struggling playing downloaded YouTube video files from USB. This may or may not work for other video formats, at the time of writing this has only been tested with .mp4 files downloaded from YouTube. Install Youtube-dl Firstly, on Ubuntu make sure you have youtube-dl installed either from the repository; Quote sudo apt install youtube-dl Or, from the official website or Git repository; Youtube-dl Link Download Youtube Video Once installed, find a video you want to download and copy its Uniform Resource Locator (URL) from the address bar. At the time of this writing, a link will look like the following; https://www.youtube.com/watch?v=dxqYDrELD_E Now, youtube-dl allows us to download different qualities of video, with different screen resolutions, using the -F switch, an example of this follows; Quote Hacker@Hacked-Laptop:~$ youtube-dl -F https://www.youtube.com/watch?v=dxqYDrELD_E [youtube] dxqYDrELD_E: Downloading webpage [youtube] dxqYDrELD_E: Downloading video info webpage [info] Available formats for dxqYDrELD_E: format code extension resolution note 249 webm audio only DASH audio 63k , opus @ 50k, 2.32MiB 250 webm audio only DASH audio 82k , opus @ 70k, 3.03MiB 140 m4a audio only DASH audio 130k , m4a_dash container, mp4a.40.2@128k, 5.17MiB 171 webm audio only DASH audio 134k , vorbis@128k, 4.92MiB 251 webm audio only DASH audio 161k , opus @160k, 5.89MiB 160 mp4 256x144 144p 112k , avc1.4d400c, 30fps, video only, 3.18MiB 278 webm 256x144 144p 114k , webm container, vp9, 30fps, video only, 3.83MiB 242 webm 426x240 240p 225k , vp9, 30fps, video only, 6.79MiB 133 mp4 426x240 240p 337k , avc1.4d4015, 30fps, video only, 7.42MiB 243 webm 640x360 360p 414k , vp9, 30fps, video only, 12.06MiB 134 mp4 640x360 360p 688k , avc1.4d401e, 30fps, video only, 14.46MiB 244 webm 854x480 480p 755k , vp9, 30fps, video only, 19.57MiB 135 mp4 854x480 480p 978k , avc1.4d401f, 30fps, video only, 20.64MiB 247 webm 1280x720 720p 1532k , vp9, 30fps, video only, 35.37MiB 136 mp4 1280x720 720p 2050k , avc1.4d401f, 30fps, video only, 32.93MiB 248 webm 1920x1080 1080p 2727k , vp9, 30fps, video only, 84.15MiB 137 mp4 1920x1080 1080p 4333k , avc1.640028, 30fps, video only, 105.03MiB 18 mp4 640x360 medium , avc1.42001E, mp4a.40.2@ 96k, 24.68MiB 43 webm 640x360 medium , vp8.0, vorbis@128k, 33.84MiB 22 mp4 1280x720 hd720 , avc1.64001F, mp4a.40.2@192k (best) In this example I will be using the number 22 option; Quote 22 mp4 1280x720 hd720 , avc1.64001F, mp4a.40.2@192k (best) Once we know the option we require, we download the video using the -f switch passing in the option as follows; Quote Hacker@Hacked-Laptop:~$ youtube-dl -f 22 https://www.youtube.com/watch?v=dxqYDrELD_E [youtube] dxqYDrELD_E: Downloading webpage [youtube] dxqYDrELD_E: Downloading video info webpage [download] Destination: What Happens If One Million People Actually Stormed Area 51-dxqYDrELD_E.mp4 [download] 100% of 38.08MiB in 00:08 Once the video is downloaded, if you chose the .mp4 option, it is time to convert the video to a playable file format and screen resolution. In this example I will be converting the .mp4 file to divx with the .avi file format with a screen resolution of 640x480. Converting Your Video On Ubuntu, if you have ffmpeg you can either batch convert or single file convert. To batch convert, first create a shell script file, I created the file convert.sh in the directory where my video files are I want to convert. I added the following shell code to my convert.sh file then saved the file; Quote #!/bin/bash for i in *.mp4; do ffmpeg -i "$i" -c:v mpeg4 -q:v 5 -tag:v DIVX -s 640x480 -c:a libmp3lame -q:a 5 -ac 2 -ar 44100 "$(basename "$i" .mp4)".avi ; done I then made the convert.sh file an executable file by changing its permissions using the command; Quote chmod u+x convert.sh I then ran the file using the command; Quote sh convert.sh Or, for a single video without using a shell script you can use the command; Quote ffmpeg -i input.mp4 -c:v mpeg4 -q:v 5 -tag:v DIVX -s 640x480 -c:a libmp3lame -q:a 5 -ac 2 -ar 44100 output.avi Making sure you replace input.mp4 with your downloaded file name and the output.avi with the name you want your file to be. Automated Process I have created an automated shell script which can be added to a file as mentioned above which is a work in progress, simply create a convert.sh file as above, add the following shell code instead of the shell code mentioned in the previous chapter. Quote #!/bin/bash RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color echo "${RED}################################################${NC}" echo "Enter 1 for multi-file convert or 2 to download " echo "a single file and convert" echo " " read -p "Enter Option: " option echo " " case "$option" in #case 1 "1") echo "Converting multiple files" for i in *.mp4; do ffmpeg -i "$i" -c:v mpeg4 -q:v 5 -tag:v DIVX -s 640x480 -c:a libmp3lame -q:a 5 -ac 2 -ar 44100 "$(basename "$i" .mp4)".avi ; done ;; #case 2 "2") echo " " echo "${RED}################################################${NC}" read -p "Enter Youtube Video Link: " videolink echo " " youtube-dl -F $videolink echo " " echo "${RED}################################################${NC}" read -p "Enter Youtube Video Quality: " videoquality echo " " videofilename=$(youtube-dl --get-filename -f $videoquality $videolink) youtube-dl -f $videoquality $videolink echo " " echo "${RED}################################################${NC}" echo "Converting your video to DIVX with a 640x480 " echo "video resolution for use with your Pioneer Radio" echo " " videotitle=${videofilename%.*} ffmpeg -i "$videofilename" -c:v mpeg4 -q:v 5 -tag:v DIVX -s 640x480 -c:a libmp3lame -q:a 5 -ac 2 -ar 44100 "$videotitle-640x480".avi echo " " echo "${RED}################################################${NC}" echo "Your file has been converted." read -p "Delete old mp4 file, Yes[y] or No[n], Enter Option: " deloption echo " " #Pass the variable in string case "$deloption" in #case 1 "y") rm "$videofilename" echo "You're done, $videofilename removed" exit ;; #case 2 "n") echo "You're done, $videofilename not removed" exit ;; esac ;; esac If anyone feels like adding to or rewriting the shell script please can you repost for other people. Conclusion Converting will depend on the time of the video file and the resources of your computer. Once complete, you should be able to play the converted YouTube video on your head unit. These commands worked for me every time, I have an AVH-270BT I bought second hand and it has a screen resolution of 800x480. I couldn't get it to work using other resolutions, it kept saying screen resolution not supported. References 1. https://www.pioneerelectronics.com/PUSA/Car/DVD+Receivers/AVH-270BT#manuals 2. https://www.taniarascia.com/how-to-create-and-use-bash-scripts/ 3. https://superuser.com/questions/309822/ffmpeg-command-to-convert-to-divx 4. https://stackoverflow.com/questions/5784661/how-do-you-convert-an-entire-directory-with-ffmpeg 5. https://superuser.com/questions/1150745/how-to-convert-multiple-videos-into-avi-one-after-another Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.