This commit is contained in:
GenZmeY 2020-11-14 21:02:26 +03:00
parent 0ad4d4771d
commit e13c2d517e
4 changed files with 32 additions and 6 deletions

View File

@ -52,6 +52,22 @@ function extract_chapters ()
echo "DUMMY" echo "DUMMY"
} }
function extract_framedurations () # $1: stream index
{
local FileIndex=0
echo "ffconcat version 1.0" > "$FrameDurationList"
while read Line
do
if echo "$Line" | grep -qF 'pts_time='; then
((FileIndex++))
printf "file \'./$(basename $FramesUpscaledDir)/%06d.png\'\n" "$FileIndex" >> "$FrameDurationList"
echo "inpoint $(echo "$Line" | grep -Po '\d+\.\d+')" >> "$FrameDurationList"
elif echo "$Line" | grep -qF 'duration_time='; then
echo "duration $(echo "$Line" | grep -Po '\d+\.\d+')" >> "$FrameDurationList"
fi
done < <(ffprobe -v quiet -show_entries packet=pts_time,duration_time -select_streams "$Index" "$InputFile")
}
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo "You must specify the video file" echo "You must specify the video file"
exit "$PARAMETER_ERROR" exit "$PARAMETER_ERROR"
@ -89,6 +105,7 @@ do
case "$Type" in case "$Type" in
video ) video )
extract_framedurations "$Index"
ffmpeg -hide_banner -i "$InputFile" -map "0:$Index" -c:v copy "$VideoDir/$Index.$Extension" ffmpeg -hide_banner -i "$InputFile" -map "0:$Index" -c:v copy "$VideoDir/$Index.$Extension"
if [[ "$?" != 0 ]]; then exit "$EXTRACT_AUDIO_ERROR"; fi ;; if [[ "$?" != 0 ]]; then exit "$EXTRACT_AUDIO_ERROR"; fi ;;
audio ) audio )

View File

@ -23,8 +23,8 @@ if ! [[ -r "$InputFile" ]]; then
fi fi
rm -rf "$FramesDir"; mkdir -p "$FramesDir" rm -rf "$FramesDir"; mkdir -p "$FramesDir"
# passthrough
ffmpeg -hide_banner -i "$InputFile" -r "$(framerate)" -f image2 "$FramesDir/%06d.png" ffmpeg -hide_banner -i "$InputFile" -r "$(framerate)" -f image2 -vsync vfr "$FramesDir/%06d.png"
if [[ "$?" != 0 ]]; then if [[ "$?" != 0 ]]; then
exit "$CONVERT_TO_FRAMES_ERROR" exit "$CONVERT_TO_FRAMES_ERROR"

View File

@ -56,12 +56,20 @@ rm -rf "$VideoUpscaledDir"; mkdir -p "$VideoUpscaledDir"
VideoUpscaled="$VideoUpscaledDir/video.mp4" VideoUpscaled="$VideoUpscaledDir/video.mp4"
# -f "image2" \
# -framerate "$(framerate)" \
# -i "$FramesUpscaledDir/%06d.png" \
# -r "$(framerate)" \
# -vf fps="$(framerate)" \
#
ffmpeg \ ffmpeg \
-hide_banner \ -hide_banner \
-f "image2" \ -f "concat" \
-framerate "$(framerate)" \ -safe 0 \
-i "$FramesUpscaledDir/%06d.png" \ -i "$FrameDurationList" \
-r "$(framerate)" \ -vsync vfr \
-r "42" \
-vcodec "$VideoCodec" \ -vcodec "$VideoCodec" \
-preset "$Preset" \ -preset "$Preset" \
-pix_fmt "$PixelFormat" \ -pix_fmt "$PixelFormat" \

View File

@ -42,6 +42,7 @@ readonly VideoUpscaledDir="${VideoDir}_upscaled"
readonly FormatJson="$OutputDir/format.json" readonly FormatJson="$OutputDir/format.json"
readonly StreamsJson="$OutputDir/streams.json" readonly StreamsJson="$OutputDir/streams.json"
readonly ChaptersJson="$OutputDir/chapters.json" readonly ChaptersJson="$OutputDir/chapters.json"
readonly FrameDurationList="$OutputDir/frameduration.list"
readonly RangesList="$OutputDir/ranges.list" readonly RangesList="$OutputDir/ranges.list"