|
1 | 1 | #!/bin/bash
|
2 |
| - |
3 |
| -duration="$(ffprobe "$1" 2>&1 | grep Duration | awk '{ print $2 }')" |
4 |
| -seconds="$(echo $duration \ |
5 |
| - | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }' \ |
6 |
| - | cut -d '.' -f 1)" |
7 |
| -fps="$(ffprobe "$1" 2>&1 \ |
8 |
| - | sed -n 's/.*, \(.*\) fps,.*/\1/p' \ |
9 |
| - | awk '{printf("%d\n",$1 + 0.5)}')" |
10 |
| -frames="$(( seconds*fps ))" |
11 |
| - |
12 |
| - |
13 |
| -ffmpeg -y -i pianist2.mp4-frames 1 -vf f'scale=1:{height}:sws_flags=area,normalize,tile={framecount}x1', '-aspect', f'{framecount}:{height}', target_name_y |
14 |
| - |
15 |
| -1280 720 |
16 |
| - |
17 |
| -# Check number of frames |
18 |
| -ffprobe -v error -select_streams v:0 -count_packets -show_entries stream=nb_read_packets -of csv=p=0 input.mp4 |
19 |
| - |
20 |
| - |
21 |
| -#Rendering horizontal videogram |
22 |
| -ffmpeg -y -i pianist2.mp4 -frames 1 -vf scale=1:720:sws_flags=area,normalize,tile=230x1 -aspect 230:720 out_horizontal.png |
23 |
| - |
24 |
| -#Rendering vertical videogram |
25 |
| -ffmpeg -y -i pianist2.mp4 -vf scale=1280:1:sws_flags=area,normalize,tile=1x230 -aspect 1280:230 -frames 1 out_vertical.png |
26 |
| - |
| 2 | +# ------------------------------------------------------------------ |
| 3 | +# Description: |
| 4 | +# Will create horizontal and vertical videograms of video |
| 5 | +# |
| 6 | +# Usage: |
| 7 | +# Place in folder with video files |
| 8 | +# Make executable: chmod u+x [scriptname] |
| 9 | +# Run script: sh [scriptname] |
| 10 | +# |
| 11 | +# Dependency: |
| 12 | +# Using FFmpeg |
| 13 | +# |
| 14 | +# Author: |
| 15 | +# Alexander Refsum Jensenius |
| 16 | +# University of Oslo |
| 17 | +# |
| 18 | +# Version: |
| 19 | +# 0.1 - 2022-01-09 |
| 20 | +# ------------------------------------------------------------------ |
| 21 | + |
| 22 | +FILENAME=$1 |
| 23 | +# get video name without the path and extension |
| 24 | +NAMESTRING=`basename $FILENAME` |
| 25 | +OUT_DIR=`pwd` |
| 26 | + |
| 27 | +echo "Reading file: $FILENAME" |
| 28 | + |
| 29 | +HEIGHT=`ffmpeg -i $FILENAME 2>&1 | grep Video: | grep -Po '\d{3,5}x\d{3,5}' | cut -d'x' -f1` |
| 30 | +WIDTH=`ffmpeg -i $FILENAME 2>&1 | grep Video: | grep -Po '\d{3,5}x\d{3,5}' | cut -d'x' -f2` |
| 31 | +FRAMES=`ffprobe -select_streams v -show_streams $FILENAME 2>/dev/null | grep nb_frames | sed -e 's/nb_frames=//'` |
| 32 | + |
| 33 | +echo "File info: $WIDTH x $HEIGHT - $FRAMES frames" |
| 34 | + |
| 35 | +echo "Rendering horizontal videogram..." |
| 36 | +ffmpeg -y -i pianist2.mp4 -frames 1 -vf scale=1:${HEIGHT}:sws_flags=area,normalize,tile=${FRAMES}x1 -aspect ${FRAMES}:${HEIGHT} ${NAMESTRING%.*}_horizontal.jpg |
| 37 | + |
| 38 | +echo "Rendering vertical videogram..." |
| 39 | +ffmpeg -y -i pianist2.mp4 -vf scale=${WIDTH}:1:sws_flags=area,normalize,tile=1x${FRAMES} -aspect ${WIDTH}:${FRAMES} -frames 1 ${NAMESTRING%.*}_vertical.jpg |
0 commit comments