Skip to content

Instantly share code, notes, and snippets.

@BaNru
Created July 12, 2019 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BaNru/27b42ed0fd704f67256a33b6e3c8106d to your computer and use it in GitHub Desktop.
Save BaNru/27b42ed0fd704f67256a33b6e3c8106d to your computer and use it in GitHub Desktop.
concat video and upload Youtube
#!/bin/bash
# source directory / папка с исходными видео
dirstart="DCIM/100MEDIA/"
# date format for new file / формат даты для названия нового файла
firstfile=`date -u -r $dirstart$(ls $dirstart | head -n 1) +"%Y%m%d %H:%M"`
lastfile=`date -u -r $dirstart$(ls $dirstart | tail -n 1) +"%Y%m%d %H:%M"`
echo -n "Введите название видео: "
read name
echo -n "Введите теги: "
read tags
echo -n "Введите описание: "
read desc
newnamefile="$firstfile - $lastfile $name"
echo "Сборка $newnamefile началась
Теги: $tags
Описание: $desc
"
# destination directory / папка назначения
dirend="~/video"
newdirnamefile="$dirend""youtube_upload/$newnamefile"".mp4"
# building files with MP4Box / сборка файлов с помощью MP4Box
# https://gpac.wp.imt.fr/mp4box/
filesList=""
for file in $(ls $dirstart*.mp4|sort -n);do
filesList="$filesList -cat $file"
done
MP4Box $filesList -new "$newdirnamefile"
# create a log file with data about files through mediainfo / создаём лог файл данными о файлах через mediainfo
mediainfo --LogFile="$newdirnamefile.txt" $dirstart*.mp4
# upload to Youtube using python script / выгружаем на Ютуб с помощью python скрипта
# https://blog.g63.ru/?p=2226
# https://developers.google.com/youtube/v3/quickstart/python
python "$dirend/youtube-upload.py" \
--file="$newdirnamefile" \
--title="$newnamefile" \
--category='2' \
--keywords="$tags" \
--description="$desc" \
--privacyStatus="private"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment