Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tips:video [2015/07/25 12:20] – created scipio | tips:video [2020/09/02 15:59] (current) – [from images to video] scipio | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
===== Getting INFO ===== | ===== Getting INFO ===== | ||
Line 21: | Line 21: | ||
</ | </ | ||
+ | |||
+ | ===== from images to video ===== | ||
+ | |||
+ | < | ||
+ | # 5 images per seconds | ||
+ | ffmpeg -y -framerate 5 -pattern_type glob -i ' | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | ffmpeg -r 30 -s 1080x1080 -i imgs/ | ||
+ | </ | ||
+ | * crf: quality, minor is better | ||
+ | |||
+ | ===== from video to images ===== | ||
+ | |||
+ | |||
+ | < | ||
+ | ffmpeg -i input.mp4 -qscale:v 2 imgs/ | ||
+ | </ | ||
+ | * qscale:v is quality, 2-15 minor is better | ||
===== MKV===== | ===== MKV===== | ||
Line 31: | Line 52: | ||
convert to mkv and downgrade quality | convert to mkv and downgrade quality | ||
< | < | ||
- | avconv -i < | + | avconv -i < |
</ | </ | ||
Line 39: | Line 60: | ||
</ | </ | ||
+ | ===== x264 ===== | ||
+ | From x265 to x264 | ||
+ | < | ||
+ | ffmpeg -xerror -i input.mkv -hide_banner -threads 0 -map 0 -c:a copy -c:s copy -c:v libx264 -pix_fmt yuv420p output.mkv | ||
+ | </ | ||
+ | |||
+ | ===== script ===== | ||
+ | |||
+ | convert files to mkv and downgrade them if greater than specific value | ||
+ | |||
+ | tomkv (chmod +x) | ||
+ | < | ||
+ | #!/bin/bash | ||
+ | |||
+ | OUTDIR=out | ||
+ | LIMIT_MBYTE=1500 | ||
+ | QUALITY=20 # lower values are better | ||
+ | |||
+ | mkdir -p $OUTDIR | ||
+ | set -x | ||
+ | for f in " | ||
+ | do | ||
+ | [ -f " | ||
+ | |||
+ | SIZE=$(stat -c%s " | ||
+ | OUTNAME=$OUTDIR/ | ||
+ | [ -f " | ||
+ | |||
+ | if [ $SIZE -gt $(($LIMIT_MBYTE*1000000)) ]; then | ||
+ | echo avconv $f | ||
+ | avconv -i " | ||
+ | else | ||
+ | echo mkvmerge $f | ||
+ | mkvmerge " | ||
+ | fi | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | Usage to convert into ./out folder | ||
+ | < | ||
+ | tomkv file1 file2 ... | ||
+ | </ | ||
+ | |||
+ | ===== lates ===== | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | CHATID=$1 | ||
+ | BASEpath='/ | ||
+ | |||
+ | [ -z " | ||
+ | |||
+ | |||
+ | for folder in $(find / | ||
+ | |||
+ | for video in $(find $folder -newer $folder.jpg -name " | ||
+ | i=$(echo " | ||
+ | preview=$BASEpath/ | ||
+ | |||
+ | ago_seconds=$(( $(date +%s) - $(stat -c %Y $video ) )) | ||
+ | if [ $ago_seconds -le 3600 ]; then | ||
+ | ago=" | ||
+ | else | ||
+ | ago=" | ||
+ | fi | ||
+ | echo "video $video is $ago" | ||
+ | |||
+ | ( ffmpeg -i $video -r 0.5 -c:v libx264 -an -t 30 -y $preview </ | ||
+ | ~/ | ||
+ | sleep 1 | ||
+ | done | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | ===== on motion ===== | ||
+ | |||
+ | < | ||
+ | #!/bin/bash | ||
+ | |||
+ | CHROOT=/ | ||
+ | |||
+ | FILENAME=$1 | ||
+ | |||
+ | # name of the first folder level inside CHROOT | ||
+ | INPUT=$(cut -d'/' | ||
+ | |||
+ | # lowercase | ||
+ | INPUT=${INPUT,, | ||
+ | |||
+ | LOCK=${CHROOT}${INPUT}.lock | ||
+ | [ -f $FILENAME ] && ln -sf $FILENAME ${CHROOT}${INPUT}.jpg | ||
+ | |||
+ | |||
+ | [ -f $LOCK ] && exit 0 | ||
+ | |||
+ | touch $LOCK | ||
+ | name=" | ||
+ | i=${INPUT/ | ||
+ | video=$CHROOT/ | ||
+ | |||
+ | echo " | ||
+ | ( ffmpeg -i rtsp:// | ||
+ | </ | ||
+ | |||
+ | ===== telegram ===== | ||
+ | |||
+ | < | ||
+ | #!/bin/sh | ||
+ | |||
+ | set -x | ||
+ | |||
+ | caption=$1 | ||
+ | video=$2 | ||
+ | CHATID=$3 | ||
+ | |||
+ | # | ||
+ | TOKEN=" | ||
+ | |||
+ | [ -z " | ||
+ | |||
+ | |||
+ | curl -F chat_id=" | ||
+ | -F document=@" | ||
+ | -F caption=" | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== preview day ===== | ||
+ | |||
+ | < | ||
+ | #!/bin/bash | ||
+ | |||
+ | set -x | ||
+ | |||
+ | CHATID=$1 | ||
+ | CHATID=${CHATID: | ||
+ | i=$2 | ||
+ | i=${i:=1} | ||
+ | SPEED=${3} | ||
+ | SPEED=${SPEED: | ||
+ | |||
+ | INVSPEED=$(echo " | ||
+ | |||
+ | [ -z " | ||
+ | |||
+ | BASE=/ | ||
+ | |||
+ | DAY=$(date +" | ||
+ | video=$BASE/ | ||
+ | |||
+ | echo " | ||
+ | |||
+ | # 0.02: 20 volte la velocita | ||
+ | |||
+ | if [ ! -f $video ]; then | ||
+ | ffmpeg -f concat -safe 0 \ | ||
+ | -i <(find " | ||
+ | -c:v libx264 -filter:v " | ||
+ | # -r 0.1 -c:v libx264 -an -y $video | ||
+ | fi | ||
+ | |||
+ | |||
+ | ~/ | ||
+ | </ | ||
+ | |||
+ | ===== camera motion ===== | ||
+ | |||
+ | < | ||
+ | INPUT=rtsp:// | ||
+ | ffprobe -i $INPUT | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | ffmpeg -rtsp_transport tcp -i $INPUT -c:v libx264 -an -y test.mp4 | ||
+ | </ | ||
+ | |||
+ | shinobi | ||
+ | < | ||
+ | ffmpeg -loglevel warning -analyzeduration 5000000 -probesize 5000000 \ | ||
+ | | ||
+ | | ||
+ | | ||
+ | -tune zerolatency -g 1 -hls_time 2 -hls_list_size 3 -start_number 0 -hls_allow_cache 0 \ | ||
+ | | ||
+ | -f singlejpeg -vf fps=0.5 -s 640x380 pipe:0 \ | ||
+ | | ||
+ | -y -f mpegts -c:v libx264 http:// | ||
+ | </ |