A few days ago i’ve downloaded some videos from youtube using a dedicated portal as youtube-dl won’t work with most of them.
I prefer to download the best quality (HD-videos) but i wasn’t able to download them with audio (only available without!)
So i’ve downloaded the hd-version without audio and the same video in a lower quality but with audio. With the following script (save it as
youtube_merge.sh) i was able to merge the to videos and so i got a full hd-video with audio:
#!/bin/bash FILE_WITH_AUDIO="$1" FILE_WITH_GOOD_VIDEO="$2" TMP_AUDIO=$(basename "$FILE_WITH_AUDIO") NEW_FILE="NEW_$TMP_AUDIO" TMP_AUDIO="/tmp/$TMP_AUDIO.aac" ffmpeg -i "$FILE_WITH_AUDIO" -vn -acodec copy "$TMP_AUDIO" ffmpeg -i "$FILE_WITH_GOOD_VIDEO" -i "$TMP_AUDIO" -c:v copy -c:a aac -bsf:a aac_adtstoasc -strict experimental "$NEW_FILE"
Call it like
youtube_merge.sh video_with_audio.mp4 hd_video_without_audio.mp4
und you’ll get a file called
NEW_video_with_audio.mp4 which can be played fined using mplayer, vlc and others …
You also need to have ffmpeg installed!