Video

~/.local/bin/video_preview

Rina Kawakita 2018. 7. 11. 21:09

~/.local/bin/video_preview.sh

  * very slow 

#!/usr/bin/env bash

if [ -z "$1" ]; then
    echo "usage: ./video_preview VIDEO [HEIGHT=120] [COLS=100] [ROWS=1] [OUTPUT]"
    exit
fi

MOVIE=$1
HEIGHT=$2
COLS=$3
ROWS=$4
OUT_FILENAME=$5

# get video name without the path and extension
MOVIE_NAME=`basename "${MOVIE}"`
OUT_DIR=`pwd`

if [ -z "$HEIGHT" ]; then
    HEIGHT=40
fi
if [ -z "$COLS" ]; then
    COLS=6
fi
if [ -z "$ROWS" ]; then
    ROWS=9
fi
if [ -z "$OUT_FILENAME" ]; then
    OUT_FILENAME=`echo ${MOVIE_NAME%-trans.*}_preview.png`
fi

OUT_FILEPATH=`echo "${OUT_DIR}"/"${OUT_FILENAME}"`

TOTAL_IMAGES=`echo "$COLS*$ROWS" | bc`

# get total number of frames in the video
# ffprobe is fast but not 100% reliable. It might not detect number of frames correctly!
NB_FRAMES=`ffprobe -show_streams "$MOVIE" 2> /dev/null | grep nb_frames | head -n1 | sed 's/.*=//'`

if [ "$NB_FRAMES" = "N/A" ]; then
    # as a fallback we'll use ffmpeg. This command basically copies this
    # video to /dev/null and it counts frames in the process.
    # It's slower (few seconds usually) than ffprobe but works everytime.
    NB_FRAMES=`ffmpeg -nostats -i "$MOVIE" -vcodec copy -f rawvideo -y /dev/null 2>&1 | grep frame | awk '{split($0,a,"fps")}END{print a[1]}' | sed 's/.*= *//'`
fi

# calculate offset between two screenshots, drop the floating point part
NTH_FRAME=`echo "$NB_FRAMES/$TOTAL_IMAGES" | bc`
echo "capture every ${NTH_FRAME}th frame out of $NB_FRAMES frames"

# make sure output dir exists
mkdir -p "${OUT_DIR}"

#FFMPEG_CMD="ffmpeg -loglevel panic -i \"$MOVIE\" -y -frames 1 -q:v 1 -vf \"select=not(mod(n\,$NTH_FRAME)),scale=-1:${HEIGHT},tile=${COLS}x${ROWS}\" \"$OUT_FILEPATH\""
#FFMPEG_CMD="ffmpeg -loglevel panic -i \"$MOVIE\" -y -frames 1 -q:v 1 -vf \"select=not(mod(n\,$NTH_FRAME)),tile=${COLS}x${ROWS}:padding=100:margin=200,scale=1920:-1\" \"$OUT_FILEPATH\""
#FFMPEG_CMD="ffmpeg -loglevel panic -i \"$MOVIE\" -y -frames 1 -q:v 1 -vf \"select=not(mod(n\,$NTH_FRAME)),tile=${COLS}x${ROWS}:padding=100:margin=200,scale=1080:-1\" \"$OUT_FILEPATH\""
FFMPEG_CMD="ffmpeg -loglevel panic -i \"$MOVIE\" -y -frames 1 -q:v 1 -vf \"select=not(mod(n\,$NTH_FRAME)),tile=${COLS}x${ROWS}:padding=100:margin=200:color=0x000000,scale=1080:-1\" \"$OUT_FILEPATH\""

eval $FFMPEG_CMD
echo $OUT_FILEPATH
$ video_preivew MEYD-393.mp4







* package: ffmpeg-generate-video-preview

   https://github.com/transitive-bullshit/ffmpeg-generate-video-preview


$ sudo npm install -g ffmpeg-generate-video-preview
$ generate-video-preview "meyd-393.mp4" preview.jpg --width 180 --rows 9 --cols 6 --padding 6 --margin 8 --color 0x783e57

  Usage: generate-video-preview [options]  

  Options:

    -V, --version                 output the version number
    -w, --width            frame width
    -h, --height          frame height
    -q, --quality              frame image quality
    -n, --num-frames           number of frames to capture
    -p, --num-frames-percent   number of frames to capture as % of overall frames
    -P, --padding              image strip tile padding (default: 0)
    -M, --margin               image strip border margin (default: 0)
    -r, --rows                 image strip number of rows
    -c, --cols                 image strip number of cols
    -C, --color            image strip background color (default: Black)
    -f, --gif-fps              gifski fps (default: 10)
    -Q, --gif-quality          gifski quality (default: 80)
    -F, --gif-fast                enable gifski fast mode
    -h, --help                    output usage information


~/zshrc.d/aliases.zsh (cpu full load 무한루프 방지용)

# ffmpeg-video-preview
function fvp() {
    local NB_FRAMES=`ffprobe -show_streams "$1" 2> /dev/null | grep nb_frames | head -n1 | sed 's/.*=//'`
    [ "$NB_FRAMES" != "N/A" ] || { echo "Used [video_preview] script"; $HOME/.local/bin/video_preview "$1"; return; }

    local output_format="jpg"      #png
    local inputfile="$1"
    local outputfile="`echo ${inputfile%.*}`-preview.$output_format"
    echo "Used [ffmpeg-video-preview]"
    echo INPUT=\"$inputfile\"  OUTPUT=\"$outputfile\"
    generate-video-preview $inputfile $outputfile --width 180 --rows 9 --cols 6 --padding 6 --margin 8 --color 0x783e57
}
$ fvp MEYD-393.mp4

 | result : MEYD-393-preview.jpg







* package : mtn

   http://moviethumbnail.sourceforge.net






~/.local/bin/movieThumbnailer

   * requirement : mplayer, imagemagic

   * very fast

#!/bin/bash
#####################################################################
#			Version: 1.5.9
#####################################################################
#
# This script takes screenshots of a movie
# Depends on mplayer and imagemagick
#
# Made by	Starlite	<http://starl1te.wordpress.com/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################

usage="Type shot -h for help"

_help(){
echo -e "\nusage: shot [options] [file] ... [fileN]\n
 Options:
  -t <time> - Set time (in minutes) between screenshots; the number of screenshots is calculated automatically.
  -n <number> - Set a fixed number of screenshots to take.
  -m - Manual mode. Use arrows to FF/rewind. Press [S] to make screenshots. Quit mplayer to continue.
  -r <percent> - Change the size of the output image. Less than 40% is recommended.
  -s - Seed mode. Gives extra video and audio information. Removes spaces from filenames.
  -h - Display this help message\n

If you don't like screenshots run the script again.
This script depends on Mplayer and ImageMagic. Make sure you have them installed.\n
Usage example:
shot -n 25 -r 35% ~/films/film.avi\n"
}

shot(){
# Making screenshots...
for i in `seq 1 $shots_number`;
do
  randomiser=$RANDOM; let "randomiser %= 25"
  hop=`echo $[$shot_time*60*$i+$randomiser]`
  mplayer -ss $hop -noautosub -frames 1 -ao null -vo png "$file_path" &> /dev/null
  mv 00000001.png /tmp/shots/$i.png &> /dev/null
  echo -ne "Taking screenshot #${i} \r"
done
  echo "Taking screenshots...           [OK]"
}

# ====== first step is here! ^_^ ========
# Checking options...
while getopts ":t:n:mr:sh" option
	do
		case $option in
		t ) shot_time=$OPTARG; opt=_time;;
		n ) shots_number=$OPTARG; opt=_num;;
		m ) opt=_manual;;
		h ) _help; opt=1; exit 1;;
		s ) seed=1;;
		r ) res=$OPTARG;;
		: ) echo "No argument given"; opt=1; exit 1;;
		* ) echo "Unknown option"; echo $usage; opt=1; exit 1;;
		esac
	done

if [ "$res" == "" ]; then res=35%; fi
if [ "$opt" == "" ]; then echo "No options given!"; echo $usage; exit 1; fi
shift $(($OPTIND - 1))
if [ "$1" == "" ]; then echo "No file given!"; echo $usage; exit 1; fi
mkdir /tmp/shots

# Parsing files...
while [ "$1" != "" ]
do
  file_path=$1
  file_name_ext=${file_path##*/}
  file_name=`echo "$file_name_ext" | sed '$s/....$//'`
  randomiser=0
  quality=87
  testpath=`dirname "$file_path" | cut -c1`
	if [ "$testpath" == "." ]||[ "$testpath" != "/" ]; then
	file_path=`pwd`/$file_path
	fi
  path=`pwd`
  cd "$path"
echo -e "==> Processing file $file_name_ext..."

# Getting video info...
tmp="/tmp/shots/info"
inf=`mplayer "$file_path" -identify -frames 1 -ao null -vo null 2>/dev/null | tee $tmp`

length=`cat $tmp | grep LENGTH | sed -e 's/^.*=//' -e 's/[.].*//'`
if [ "$length" == "" ]; then echo "Error! Can't get the length of the movie."; exit 1; fi

# Calculating timing...
if [ "$opt" == "_time" ]; then
	shots_number=`echo $[$length/60/$shot_time]`
	shot
elif [ "$opt" == "_num" ]; then
	shot_time=`echo $[$length/$shots_number/60]`
	shot
elif [ "$opt" == "_manual" ]; then
	cd /tmp/shots
	echo "Press [S] to make screenshots."
	mplayer -ao null -vf screenshot -quiet "$file_path"
	echo "Taking screenshots...           [OK]"
fi

# Merging screenshots...
echo -n "Putting screenshots together..."
cd /tmp/shots/
montage -geometry +2+2 `ls *.png | sort -n` "$file_name".jpg
mogrify -resize $res "$file_name".jpg
echo " [OK]"
echo -n "Getting video info..."
size=`stat -c%s  "$file_path"`
size=`echo $[$size/1024/1024]`
format=`cat $tmp | grep VIDEO: | cut -d " " -f 5`
length=`echo $[$length/60]`

# It's a tricky code here, it adds some info about the movie to the output image.
echo -e "File name: $file_name_ext\nSize: $size Mb\nResolution: $format\nDuration: $length min." | convert -pointsize 16 -trim +repage text:- text.jpg
convert "$file_name".jpg -quality $quality -splice 0x80 -draw 'image over 5,5 0,0 text.jpg' "$path/$file_name".jpg
echo "           [OK]"
cd "$path"
# Extra info
    if [ "$seed" == "1" ]; then
	#====Video====
	width=`cat $tmp | grep VIDEO_WIDTH | sed -e 's/^.*=//'`
	height=`cat $tmp | grep VIDEO_HEIGHT | sed -e 's/^.*=//'`
	format=`cat $tmp | grep VIDEO_FORMAT | sed -e 's/^.*=//'`
	vcodec=`cat $tmp | grep VIDEO_CODEC | sed -e 's/^.*=//'`
	video="Format:  $format\nCodec:  $vcodec"
	size="Size:  $width*$height"
	#====Audio====
	rate=`cat $tmp | grep AUDIO_RATE | sed -e 's/^.*=//' | tail -n 1`
	acodec=`cat $tmp | grep afm: | sed -e 's/^.*: //'`
	lang1=`cat $tmp | grep ID_AID_0_LANG | sed -e 's/^.*=//'`
	lang2=`cat $tmp | grep ID_AID_1_LANG | sed -e 's/^.*=//'`
	audio="Audio:  $rate $acodec"
	lang="Dub:  1: $lang1  2: $lang2"
	echo -e "\n$video\n$size\n$audio\n$lang"
	#filenames trimming
	file_name_sp=`echo "$file_name" | sed 's/ /_/g'`
	mv "$file_name".jpg "$file_name_sp".jpg &> /dev/null
    fi
rm /tmp/shots/*
echo
shift
done

rm -r /tmp/shots
echo "Done"

~/.local/bin/movieThumbnailer

   * requirement : mplayer, imagemagic, etc...

   * very fast

   * overlay: timestamp, mediainfo, poster,  logo, nfo, subtitle

#!/bin/env bash
#####################################################################
# Thumbnail Screenshot
#####################################################################
#
# This script takes screenshots of a movie
# Depends on mplayer, imagemagick and calc
#
# Original: Made by Starlite    
# 
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .
#
# Update & Modified: by nietz (2018-05-05)
#####################################################################

usage="Type 'movieThumbnailer -h' for help"
#logo="/home/nietz/redfox-logo.png"
logo="/home/nietz/prestige-logo.png"
logo="/home/nietz/madonna-logo.png"
logo="/home/nietz/tameikegoro-logo.png"
logo_tameikegoro="/home/nietz/tameikegoro-logo-box.png"
#logo="/home/nietz/rarbg-logo.png"
logo_vixen="/home/nietz/vixen-white.svg"
font="/usr/share/fonts/nerd-fonts-complete/ttf/M+ 2m bold Nerd Font Complete.ttf"   ## 너드폰트, 일본어,영어,이미지 폰트
#font="/usr/share/fonts/noto-cjk/NotoSansCJK-Bold.ttc"  ## 한중일 폰트
font_sub="/home/nietz/.local/share/fonts/SpoqaHanSans_all/SpoqaHanSans_jp_original/SpoqaHanSansJPBold.ttf"   ## 한일 폰트
#font="/home/nietz/.local/share/fonts/SpoqaHanSans_all/SpoqaHanSans_original/SpoqaHanSansBold.ttf" ## 한일 폰트
jav_lib=/mnt/jav
jav_uncensored_lib=/mnt/jav_uncensored

_help(){
echo -e "\nusage: movieThumbnailer [options] [file] ... [fileN]\n
 Options:
  -t 
# shot screenshot : -n 갯수, -r 가로너비, -s 시드모드, -k 타임스탬프모드, -l 로고모드, -m 메뉴얼모드

${HOME}/.local/bin/movieThumbnailer -n${number} -r${width} -s -k -l "${inputfile}"

| example: Movie : Disc,  Clearart, Thumb, Poster, Logo image, Media info, Nfo, Subtitle info

|| 16:9


|| 16:9, Anamorphic Rip


|| Wide, ratio: 2.28, 1878x824 Blu-Ray Rip


|| Wide, ratio: 2.35, 1920x800 BluRay Rip -> padding 16:9(1.77777777~)



|| Wide, ratio: 2.4, 1920x800 Blu-Ray Rip -> padding 16:9(1.77777777~)
   $ movieThumbnailer -n100 -r1920 -s -l -k "Alien Covenant (2017).mkv"


|| Final : 악녀 (2017)


|| Avengers: Endgame (2019)



|| Poster: ( from. ) TheMovieDB, FanArt, The Open Movie Database





| example: JAV : Poster Cover, Studio Logo, Actor image

|| Manuaul mode(-m): #25 capture,  "s" key, manuaul 25th presss then, "q" key press


|| Normal mode(-n100 -r1920 -s, -k, -l): [studio logo, actor, poster, nfo, ...] overlay


|| 16-9, Watermark file


|| Default Mode( zsh config: $ fvpi [movie_file] ) : [Studio logo, poster, poster back, nfo, ....] overlay

   16:9 No-Watermark file



| example: AV : Web content : Poster(or fanart) Cover, SVG logo,  NFO, mediainfo

|| Vixen: nfo( from. data18 DB[last updated 2018.05] )

  no-border:  $ montage -geometry +0+0


|| Pure Taboo

  border:  $ montage -geometry +2+2 -background #ffffff


CAST

Elena Koshka, Dick Chibbles


Video Description:

FUTURE DARKLY - DON'T PANIC

COUPLE MUST TRADE SEX FOR SURVIVAL AFTER THE WORLD ENDS


SCENE opens on a couple, Jacob (Logan Pierce) and Katlyn (Elena Koshka), walking hand in hand down a modern city street. They've just left dinner, and, through their small talk, it is revealed that the pair recently moved in together. They come to a corner and pause to share a tender moment. While they kiss, a shower of satellites streaks the sky behind them before tumbling to earth and exploding. The couple barely has time to react before everything buzzes and fades to white.


CUT TO TITLE PLATE


SIX WEEKS LATER


Katlyn slowly opens her eyes. She is huddled under a tarp and wearing the exact same outfit as before, except it is now filthy and soiled. Her once pretty hair is greasy and pulled back with string. Dirt streaks her face. As she pulls back the tarp, she realizes that her boyfriend Jacob is missing. The girl freaks out and jumps to her feet, looking for the wood plank she keeps by her side. As she grabs it, Jacob comes around the corner with a jug of water. He is also wearing the same outfit, caked with dirt and filth. He is unshaven and carrying a crude piece of metal. Katlyn rushes into his arms asking if he found food but her boyfriend urges her to be quiet. There is somebody up the road and he isn't sure if they're good or not. Katlyn starts to frantically gather their things. 'He might not be bad. He might know something, like the woman who drove us back in the beginning.' He continues. Katlyn asks him what he looks like. He looks pretty normal, Jacob replies. They decide to go approach him.


CUT to inside a derelict building. The couple approach the window and a man's shoulder steps into frame. He is the man Jacob saw earlier, another drifter. The couple wave their weapons above their arms and tell the man they mean no harm. They want to know if he has any information. The man hesitates before slowly sticking his head out of the door. 'You tell me first,' he says. The couple look at each other before Jacob replies that they heard it was an asteroid. Nothing works. No GPS, no internet, no electricity. The man pauses before replying 'I heard it was a nuclear attack, but I've only met 13 other people.' He pauses, before adding 'I also know where some water is.' Katlyn jumps in, demanding to know where. The man sticks his head out a little further and says he'll tell them but only if they give him some of their own water first. Jacob clutches the jug tightly. He weighs his options before Katlyn urges him to do it. Jacob agrees, and the man pulls out a dirty plastic container. Jacob fills it up and the man eagerly takes it, before telling them there is a well two miles up the road. He disappears inside, and the couple turn to keep walking.


CUT to the middle of nowhere. The couple walk through the blazing sun, with nothing in sight. Their jug is empty, and both are growing desperate. They argue about the water before coming upon a body lying in the road. Looking down on it, they root through the person's pockets but only find a dead phone.


Katlyn pleads that she is hungry, and Jacob tells her that water is more important. They need to keep walking. He tosses the phone in the dirt.


SMASH CUT to a gravel road, as the couple come up a large empty house. 'It's probably been raided already,' Jacob says but Katlyn urges them to check. They go to the front door and enter.


CUT to inside the house. It is still. There are no lights on, except for the natural light streaming in. Jacob tells Katlyn to wait while he checks the rest of the house. While she stands alone nervously, she starts to look around. A coffee cup rests on the table. It is moldy inside. She spots a pencil and snatches it up, stuffing it in her pockets. Then she sees something that shocks her: a flickering light coming from behind a closed door. She screams out to Jacob, who rushes back in.


'The whole house has been stripped,' he says. 'Like I told you.' Katlyn points to the light. The couple stare in shock. They haven't seen a single light on since it happened. Guarding his girlfriend, Jacob slowly opens the door to reveal a library with several oil lamps burning. In the middle of the floor, is a pile of tuna cans.


The couple's eyes go wide, and they pounce on them. This is more food than they've had in weeks. They try to chew them open and bang them against the floor and with books to open them. Katlyn even tries to use the pencil she found in desperation. Nothing. They collapse in frustration as a rifle barrel slowly slides out from behind a curtain in the corner of a room. A man, dressed in clean tactical clothes and greased back hair steps out. He tells them to freeze.


Jacob shields his girlfriend and begs the man to put his gun down. They are not bad people, they are just passing through. The man asks them what they know. Nervously, they reply that it might be an asteroid or a nuclear attack. There is no GPS, internet or electricity and there is supposed to be water near here. They think it's been 2 or 3 months, but they aren't sure. The man studies them before slowly putting the gun down. 'There's a well at the end of my property,' he replies. Jacob asks if they would be allowed to fill up their jug. The man smiles and sits down. 'I believe it was Kessler Syndrome,' he says matter-of-factly. Katlyn asks if he is a doctor. 'I was a high school science teacher,' he replies. There is an awkward silence, as the couple stray towards the door. 'It was a theory proposed in the seventies by NASA,' he continues. 'The idea that if enough space objects were to collide, the debris they would cause would litter our atmosphere with so much junk that all the satellites would come crashing down.' Katlyn asks her boyfriend if that is true. He shrugs his shoulders. 'No telecommunications, no electrical grids, no laws.' The man adds, laughing to himself. Jacob asks again if they can use his well. The man reaches into his pocket and pulls out a can opener. 'How about you help yourself to these cans, as well?' Katlyn freaks out and reaches for the opener, when the man pulls his hand away. 'I'll give this to you if you let me fuck your pussy!' He says, putting the opener back in his pocket. Jacob lunges at him but the man picks up his gun. 'I will defend myself,' he threatens. Jacob tells him that his girlfriend is not for sale. 'It's a trade,' he says calmly. 'Just a few minutes in exchange for a whole week's worth of food.' Jacob stares down at the food. 'I haven't been with a woman in a long time, I'm sure you can understand my position.' The man argues. He stares lustfully at Katlyn. Jacob turns and starts to debate doing it with his girlfriend. She is stunned at his attitude. How could he even be contemplating this idea? He tells her to not panic. Just calm down and listen ... food is getting harder to find. He's going to give them water too. Life isn't like it used to be. Katlyn slaps her boyfriend. He pleads with her to think about them both, not just herself. She can close her eyes. She can get through it. As he speaks, Katlyn gradually realizes that her boyfriend is right. They need the food. Old rules don't apply. She must do it. 'If you give my boyfriend the cans and the opener first, then I'll do it,' she negotiates. 'He won't leave without me.'


The man smiles. He tells her to strip while he carries the gun back to his curtain and tucks it out of view. He pulls out a single wet wipe. 'Clean yourself down there first,' he says. Katlyn nervously wipes her vagina while he inspects her. 'Wait outside,' he orders Jacob. Jacob looks guilt-ridden at his girlfriend before she tells him to go. She will be out soon. He stuffs the cans into their tarp and leaves, closing the door. Katlyn turns back to the man, tells him she is ready and then starts sucking his dick.