/
01_rotate_video.sh
executable file
·77 lines (64 loc) · 3.18 KB
/
01_rotate_video.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
# Copyright 2020-2022, Xilinx, Inc.
# Copyright 2022, Advanced Micro Device, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This script accepts an 8-bit, YUV420, pre-encoded h264 file and will send the rotated, encoded h.264 output to /tmp/xil_rotate_<N>.mp4 at a rate of 8Mbps.
# method property enumeration:
# video-direction : Video direction: rotation and flipping
# flags: readable, writable, controllable
# Enum "GstVideoOrientationMethod" Default: 0, "identity"
# (0): identity - GST_VIDEO_ORIENTATION_IDENTITY
# (1): 90r - GST_VIDEO_ORIENTATION_90R
# (2): 180 - GST_VIDEO_ORIENTATION_180
# (3): 90l - GST_VIDEO_ORIENTATION_90L
# (4): horiz - GST_VIDEO_ORIENTATION_HORIZ
# (5): vert - GST_VIDEO_ORIENTATION_VERT
# (6): ul-lr - GST_VIDEO_ORIENTATION_UL_LR
# (7): ur-ll - GST_VIDEO_ORIENTATION_UR_LL
if [ $# -ne 3 ]
then
echo "Incorrect arguments supplied"
echo "Usage: ./01_rotate_video.sh <device index> <1080p60 h264 clip> <direction {0..7}>"
exit 1
fi
#check if the input stream is compatiable with this script
container=`gst-discoverer-1.0 $2 | grep "container:" | cut -d":" -f2`
codec_type=`gst-discoverer-1.0 $2 | grep "video codec:" | cut -d":" -f2 | awk '{print $1;}'`
echo $container
echo $codec_type
if [ -z "$container" ] && [ -z "$codec_type" ]; then
echo "Input file is of unknown/unsupported type"
exit -1
elif [ -z "$container" ] && [ "$codec_type" = "H.264" ]; then
echo "Input file is of type H.264";
elif [ -z "$container" ] && [ "$codec_type" = "H.265" ]; then
echo "Input file is of type H.265. Invalid for this script";
exit -1
elif [ $container = "Quicktime" ] && [ "$codec_type" = "H.264" ]; then
echo "Input file is of type Quicktime H.264. Invalid for this script";
exit -1
elif [ $container = "Quicktime" ] && [ "$codec_type" = "H.265" ]; then
echo "Input file is of type Quicktime H.265. Invalid for this script";
exit -1
else
echo "Input file is of unknown/unsupported type"
exit -1
fi
di=$1
INPUT=$2
DIRECTION=$3
pipe="gst-launch-1.0 -v filesrc location=$INPUT ! h264parse ! vvas_xvcudec dev-idx=$di ! video/x-raw, format=NV12 ! videoflip video-direction=${DIRECTION} ! vvas_xvcuenc dev-idx=$di target-bitrate=8000 ! h264parse ! qtmux ! fpsdisplaysink video-sink=\"filesink location=/tmp/xil_rotate_${DIRECTION}.mp4\" sync=false text-overlay=false"
$pipe