This simple bash loop will go into each subfolders in the directory where you run the script and convert each avi-file to the mp4-container with the libx264 video codec and aac audio codec using ffmpeg: Create a new file, e.g. ffmpeg-subfolder-convert.sh and edit this file so it looks like this: #!/bin/bash for i in */*.avi; do ffmpeg -i "$i" -c:v libx264 -preset slow -crf 22 -c:a libfdk_aac -b:a 128k "$i".mp4 ; done Run the skript in the directory with all the subfolders using: sh ffmpeg-subfolder-convert.sh
To do this you need the following applications installed on your linux-box: # sudo apt-get install youtube-dl ffmpeg sox To download the video do this: # youtube-dl url-to-youtube-video To extract audio from video file, do: # ffmpeg -i videofile -q:a 0 -map a audio.wav To extract part of audio from wav, do: # sox audio.wav new_audio.wav trim 00:10 04:25 (00:10 is starting position and 04:45 is the end position. This way you can trim away unwanted audio.) To convert the wav-file to mp3, do: # ffmpeg -i new_audio.wav -acodec libmp3lame audio.mp3