mirror of
https://github.com/MeexReay/Youtube2Maker.git
synced 2025-05-05 23:58:02 +03:00
av1 scripts
This commit is contained in:
parent
ddce86afaf
commit
bc13706ebd
20
av1-dl-playlist.sh
Normal file
20
av1-dl-playlist.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Ошибка: укажите ссылку на плейлист."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PLAYLIST_URL=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
VIDEO_URLS=$(yt-dlp --flat-playlist --print webpage_url "$PLAYLIST_URL")
|
||||||
|
|
||||||
|
echo "$VIDEO_URLS" | wc -l
|
||||||
|
|
||||||
|
for VIDEO_URL in $VIDEO_URLS; do
|
||||||
|
echo "Загружаем видео: $VIDEO_URL"
|
||||||
|
./av1-dl-video.sh "$VIDEO_URL" "$@"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Плейлист успешно скачан"
|
67
av1-dl-video.sh
Normal file
67
av1-dl-video.sh
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Ошибка: укажите ссылку на видео."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
VIDEO_URL=$1
|
||||||
|
shift
|
||||||
|
ADDITIONAL_ARGS="$@"
|
||||||
|
|
||||||
|
VIDEO_ID=$(echo -n "$VIDEO_URL" | md5sum | awk '{print $1}')
|
||||||
|
|
||||||
|
mkdir -p "videos"
|
||||||
|
|
||||||
|
if [ -f "videos/${VIDEO_ID}.json" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
yt-dlp --skip-download --write-info-json -o "videos/${VIDEO_ID}" "$VIDEO_URL" $ADDITIONAL_ARGS
|
||||||
|
yt-dlp --skip-download --write-thumbnail -o "videos/${VIDEO_ID}_preview" "$VIDEO_URL" $ADDITIONAL_ARGS
|
||||||
|
PREVIEW_FILENAME=$(find videos -type f -iname "${VIDEO_ID}_preview*")
|
||||||
|
yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" -o "videos/${VIDEO_ID}_video" "$VIDEO_URL" $ADDITIONAL_ARGS
|
||||||
|
VIDEO_FILENAME=$(find videos -type f -iname "${VIDEO_ID}_video*")
|
||||||
|
|
||||||
|
ffmpeg -i $VIDEO_FILENAME -c:v libsvtav1 -crf 15 -preset 4 -c:a copy "videos/${VIDEO_ID}.mkv"
|
||||||
|
|
||||||
|
# ffmpeg -i "$VIDEO_FILENAME" \
|
||||||
|
# -vf "scale='min(1920,iw)':'min(1080,ih)':force_original_aspect_ratio=decrease" \
|
||||||
|
# -c:v libx264 -preset slow -crf 23 \
|
||||||
|
# -c:a copy \
|
||||||
|
# "videos/${VIDEO_ID}_video_compressed.mp4"
|
||||||
|
|
||||||
|
rm "videos/${VIDEO_ID}_video.mp4"
|
||||||
|
VIDEO_FILENAME="videos/${VIDEO_ID}_video.mkv"
|
||||||
|
|
||||||
|
NAME=$(jq -r '.fulltitle' "videos/${VIDEO_ID}.info.json")
|
||||||
|
DESCRIPTION=$(jq -r '.description' "videos/${VIDEO_ID}.info.json")
|
||||||
|
CHANNEL_NAME=$(jq -r '.uploader' "videos/${VIDEO_ID}.info.json")
|
||||||
|
CHANNEL_ID=$(jq -r '.channel_id' "videos/${VIDEO_ID}.info.json")
|
||||||
|
CHANNEL_URL=$(jq -r '.uploader_url' "videos/${VIDEO_ID}.info.json")
|
||||||
|
|
||||||
|
yt-dlp --write-thumbnail --skip-download \
|
||||||
|
--playlist-items 0 -o "videos/${CHANNEL_ID}_avatar" "$CHANNEL_URL" $ADDITIONAL_ARGS
|
||||||
|
AVATAR_FILENAME=$(find videos -type f -iname "${CHANNEL_ID}_avatar*")
|
||||||
|
|
||||||
|
jq --arg id "$VIDEO_ID" \
|
||||||
|
--arg name "$NAME" \
|
||||||
|
--arg description "$DESCRIPTION" \
|
||||||
|
--arg video_file "${VIDEO_FILENAME}" \
|
||||||
|
--arg image_file "${PREVIEW_FILENAME}" \
|
||||||
|
--arg channel_name "$CHANNEL_NAME" \
|
||||||
|
--arg channel_avatar_file "${AVATAR_FILENAME}" \
|
||||||
|
'{
|
||||||
|
id: $id,
|
||||||
|
name: $name,
|
||||||
|
description: $description,
|
||||||
|
"video-file": $video_file,
|
||||||
|
"image-file": $image_file,
|
||||||
|
"channel-name": $channel_name,
|
||||||
|
"channel-avatar-file": $channel_avatar_file
|
||||||
|
}' \
|
||||||
|
"videos/${VIDEO_ID}.info.json" > "videos/${VIDEO_ID}.json"
|
||||||
|
|
||||||
|
rm "videos/${VIDEO_ID}.info.json"
|
||||||
|
|
||||||
|
echo "Видео успешно скачано"
|
6
build.sh
6
build.sh
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
rm -rf build
|
rm -rf build
|
||||||
mkdir build
|
mkdir build
|
||||||
cp -r root build/iso
|
cp -lR root build/iso
|
||||||
cp -r www build/iso/www
|
cp -lR www build/iso/www
|
||||||
cp -r videos build/iso/www/videos
|
cp -lR videos build/iso/www/videos
|
||||||
rm build/iso/www/videos/video-example.json
|
rm build/iso/www/videos/video-example.json
|
||||||
echo "const videos = [" > build/iso/www/videos.js
|
echo "const videos = [" > build/iso/www/videos.js
|
||||||
for i in build/iso/www/videos/*.json; do
|
for i in build/iso/www/videos/*.json; do
|
||||||
|
@ -25,7 +25,8 @@ VIDEO_FILENAME=$(find videos -type f -iname "${VIDEO_ID}_video*")
|
|||||||
# -c:a copy \
|
# -c:a copy \
|
||||||
# "videos/${VIDEO_ID}_video_compressed.mp4"
|
# "videos/${VIDEO_ID}_video_compressed.mp4"
|
||||||
|
|
||||||
# mv "videos/${VIDEO_ID}_video_compressed.mp4" "$VIDEO_FILENAME"
|
mv $VIDEO_FILENAME "videos/${VIDEO_ID}_video.mp4"
|
||||||
|
VIDEO_FILENAME="videos/${VIDEO_ID}_video.mp4"
|
||||||
|
|
||||||
NAME=$(jq -r '.fulltitle' "videos/${VIDEO_ID}.info.json")
|
NAME=$(jq -r '.fulltitle' "videos/${VIDEO_ID}.info.json")
|
||||||
DESCRIPTION=$(jq -r '.description' "videos/${VIDEO_ID}.info.json")
|
DESCRIPTION=$(jq -r '.description' "videos/${VIDEO_ID}.info.json")
|
||||||
|
14
nvenc-compress-all.sh
Normal file
14
nvenc-compress-all.sh
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function compress_video {
|
||||||
|
ffmpeg -i videos/$1 -c:v hevc_nvenc -preset p4 -rc vbr -cq 28 -b:v 0 -c:a aac -b:a 96k videos/tmp_$1
|
||||||
|
mv videos/tmp_$1 videos/$1
|
||||||
|
}
|
||||||
|
|
||||||
|
for video_file in videos/*.mp4; do
|
||||||
|
base_name=$(basename "$video_file")
|
||||||
|
|
||||||
|
compress_video $base_name &
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
15
nvenc-compress.sh
Normal file
15
nvenc-compress.sh
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Ошибка: укажите название видео в папке videos."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
function compress_video {
|
||||||
|
ffmpeg -i videos/$1 -c:v hevc_nvenc -preset p4 -rc vbr -cq 28 -b:v 0 -c:a aac -b:a 96k videos/tmp_$1
|
||||||
|
mv videos/tmp_$1 videos/$1
|
||||||
|
}
|
||||||
|
|
||||||
|
for video_file in "$@"; do
|
||||||
|
compress_video $video_file
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user