sudo apt install x264 x265 libx264-dev libx265-dev
sudo apt-get install ubuntu-restricted-extras
sudo apt-get install libavcodec54 libav-tools ffmpeg
sudo apt install x264 x265 libx264-dev libx265-dev
sudo apt-get install ubuntu-restricted-extras
sudo apt-get install libavcodec54 libav-tools ffmpeg
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char* argv){
cv::Mat src = cv::imread("../tony.jpg");
// rect is the RotatedRect (I got it from a contour...)
cv::RotatedRect rect(cv::Point2f(453, 127), cv::Size(230,140), 45);
// matrices we'll use
cv::Mat M, rotated, cropped;
// get angle and size from the bounding box
float angle = rect.angle;
cv::Size rect_size = rect.size;
if (rect.angle < -45.) {
angle += 90.0;
cv::swap(rect_size.width, rect_size.height);
}
// get the rotation matrix
M = cv::getRotationMatrix2D(rect.center, angle, 1.0);
// perform the affine transformation
cv::warpAffine(src, rotated, M, src.size(), cv::INTER_CUBIC);
// crop the resulting image
cv::getRectSubPix(rotated, rect_size, rect.center, cropped);
cv::imshow("cropped", cropped);
cv::waitKey(0);
return 0;
}
A list of useful commands for the ffmpeg command line tool.
Download FFmpeg: https://www.ffmpeg.org/download.html
Full documentation: https://www.ffmpeg.org/ffmpeg.html
ffmpeg -i in.mp4 out.avi
ffmpeg -i in.mkv -c:v copy -c:a copy out.mp4
Use the crf
(Constant Rate Factor) parameter
to control the output quality. The lower crf, the higher the quality
(range: 0-51). The default value is 23, and visually lossless
compression corresponds to -crf 18
. Use the preset
parameter to control the speed of the compression process. Additional info: https://trac.ffmpeg.org/wiki/Encode/H.264
ffmpeg -i in.mp4 -preset slower -crf 18 out.mp4
Without re-encoding:
ffmpeg -ss [start] -i in.mp4 -t [duration] -c copy out.mp4
-ss
specifies the start time, e.g. 00:01:23.000
or 83
(in seconds)-t
specifies the duration of the clip (same format).ffmpeg
also has a flag to supply the end time with -to
.-c
copy copies the first video, audio, and subtitle bitstream from the
input to the output file without re-encoding them. This won't harm the
quality and make the command run within seconds.With re-encoding:
If you leave out the -c copy
option, ffmpeg
will automatically re-encode the output video and audio according to
the format you chose. For high quality video and audio, read the x264 Encoding Guide and the AAC Encoding Guide, respectively.
For example:
ffmpeg -ss [start] -i in.mp4 -t [duration] -c:v libx264 -c:a aac -strict experimental -b:a 128k out.mp4
To copy the video from in0.mp4 and audio from in1.mp4:
ffmpeg -i in0.mp4 -i in1.mp4 -c copy -map 0:0 -map 1:1 -shortest out.mp4
stream copied
, not re-encoded, so there will be no quality loss. If you want to re-encode, see FFmpeg Wiki: H.264 Encoding Guide.-shortest
option will cause the output duration to match the duration of the shortest input stream.-map
option documentation for more info.First, make a text file.
file 'in1.mp4'
file 'in2.mp4'
file 'in3.mp4'
file 'in4.mp4'
Then, run ffmpeg
:
ffmpeg -f concat -i list.txt -c copy out.mp4
Delay video by 3.84 seconds:
ffmpeg -i in.mp4 -itsoffset 3.84 -i in.mp4 -map 1:v -map 0:a -vcodec copy -acodec copy out.mp4
Delay audio by 3.84 seconds:
ffmpeg -i in.mp4 -itsoffset 3.84 -i in.mp4 -map 0:v -map 1:a -vcodec copy -acodec copy out.mp4
Use the libass library (make sure your ffmpeg install has the library in the configuration --enable-libass
).
First convert the subtitles to .ass format:
ffmpeg -i sub.srt sub.ass
Then add them using a video filter:
ffmpeg -i in.mp4 -vf ass=sub.ass out.mp4
To extract all frames from between 1 and 5 seconds, and also between 11 and 15 seconds:
ffmpeg -i in.mp4 -vf select='between(t,1,5)+between(t,11,15)' -vsync 0 out%d.png
To extract one frame per second only:
ffmpeg -i in.mp4 -fps=1 -vsync 0 out%d.png
Rotate 90 clockwise:
ffmpeg -i in.mov -vf "transpose=1" out.mov
For the transpose parameter you can pass:
0 = 90CounterCLockwise and Vertical Flip (default)
1 = 90Clockwise
2 = 90CounterClockwise
3 = 90Clockwise and Vertical Flip
Use -vf "transpose=2,transpose=2"
for 180 degrees.
ffmpeg -i "path_to_playlist.m3u8" -c copy -bsf:a aac_adtstoasc out.mp4
If you get a "Protocol 'https not on whitelist 'file,crypto'!" error, add the protocol_whitelist
option:
ffmpeg -protocol_whitelist "file,http,https,tcp,tls" -i "path_to_playlist.m3u8" -c copy -bsf:a aac_adtstoasc out.mp4
To replace the first 90 seconds of audio with silence:
ffmpeg -i in.mp4 -vcodec copy -af "volume=enable='lte(t,90)':volume=0" out.mp4
To replace all audio between 1'20" and 1'30" with silence:
ffmpeg -i in.mp4 -vcodec copy -af "volume=enable='between(t,80,90)':volume=0" out.mp4
Deinterlacing using "yet another deinterlacing filter".
ffmpeg -i in.mp4 -vf yadif out.mp4
Parameters: -r
marks the image framerate (inverse time of each image); -vf fps=25
marks the true framerate of the output.
ffmpeg -r 1/5 -i img%03d.png -c:v libx264 -vf fps=25 -pix_fmt yuv420p out.mp4
ffmpeg -i input.mp4 thumb%04d.jpg -hide_banner
ffmpeg -i input.mp4 -vf fps=1 thumb%04d.jpg -hide_banner
ffmpeg -i input.mp4 -ss 00:00:10.000 -vframes 1 thumb.jpg
ffmpeg -i in.mp4 -map_metadata -1 -metadata title="My Title" -c:v copy -c:a copy out.mp4
ls /usr/lib/x86_64-linux-gnu/libQt5Core*
pip uninstall pyqt5
conda list qt
conda install pyqt==5.9.2
method1:
double t = (double)cv::getTickCount();
bool status = weightedMovingVariance(frame, output, count);
t = ((double)cv::getTickCount() - t)/cv::getTickFrequency();
std::cout << "Times passed in seconds: " << t << std::endl;
method2:
gg then =G
/data/build/main1.sh &
P1=$!
/data/build/main2.sh &
P2=$!
wait $P1 $P2
wget https://bootstrap.pypa.io/pip/3.5/get-pip.py
python get-pip.py
predefined:-
name: "kps"
platform: "tensorrt_plan"
max_batch_size: 16
dynamic_batching {
preferred_batch_size: [ 1,2,4,8,16 ]
max_queue_delay_microseconds: 50
}
instance_group [
{
count: 16
kind: KIND_GPU
gpus: [ 0 ]
}
]
input [
{
name: "input"
data_type: TYPE_FP32
format: FORMAT_NCHW
dims: [ 3, 64, 64 ]
reshape { shape: [ 3, 64, 64 ] }
}
]
output [
{
name: "output1"
data_type: TYPE_FP32
dims: [ 1]
},
{
name: "output2"
data_type: TYPE_INT32
dims: [ 1 ]
},
{
name: "output3"
data_type: TYPE_FP32
dims: [ 8,64 ]
}
]
version_policy: { all { } }
dynamic:-
platform: "tensorrt_plan"
max_batch_size: 0
instance_group [
{
count: 16
kind: KIND_GPU
gpus: [ 0 ]
}
]
input [
{
name: "images"
data_type: TYPE_FP32
dims: [ -1,3, 640, 640]
}
]
output [
{
name: "524"
data_type: TYPE_FP32
dims: [ -1,3,80,80, 7 ]
},
{
name: "585"
data_type: TYPE_FP32
dims: [ -1,3,40,40, 7 ]
},
{
name: "646"
data_type: TYPE_FP32
dims: [ -1,3,20,20, 7 ]
},
{
name: "output"
data_type: TYPE_FP32
dims: [ -1, 25200, 7 ]
}
]
~
~
~
~
cmake_minimum_required(VERSION 3.10)
#set the project name and version
project(render)
find_package(OpenCV REQUIRED)
find_package(CUDA 10.2 REQUIRED)
set(WITH_CUDA ON)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(main main_nvgstcamera_capture.cpp)
target_include_directories(main PUBLIC
-I/usr/local/cuda-10.2/targets/aarch64-linux/include
/usr/share/visionworks/sources/nvxio/include
/usr/share/visionworks/sources/nvxio/src/
/usr/share/visionworks/sources/nvxio/src/NVX/
/usr/share/visionworks/sources/3rdparty/opengl
/usr/share/visionworks/sources/3rdparty/glfw3/include
/usr/share/visionworks/sources/3rdparty/freetype/include
/usr/share/visionworks/sources/3rdparty/eigen
)
target_link_libraries(main
-L$(PKG_CONFIG_SYSROOT_DIR)/usr/lib
/usr/share/visionworks/sources/libs/aarch64/linux/release/libovx.a
/usr/share/visionworks/sources/3rdparty/freetype/libs/libfreetype.a
/usr/share/visionworks/sources/3rdparty/glfw3/libs/libglfw3.a
/usr/lib/aarch64-linux-gnu/tegra-egl/libGLESv2_nvidia.so.2
-L/usr/lib/aarch64-linux-gnu
-lEGL
-lXrandr
-lXi
-lXxf86vm
-lX11
-lgstpbutils-1.0
-lgstaudio-1.0
-lgstvideo-1.0
-lgstapp-1.0
-lgstbase-1.0
-lgstreamer-1.0
-lgobject-2.0
-lglib-2.0
/usr/lib/aarch64-linux-gnu/tegra/libcuda.so
-L/usr/local/cuda-10.2/targets/aarch64-linux/lib
-lcudart
-lvisionworks
${OpenCV_LIBS}
)
#include "iostream"
#include "string.h"
using namespace std;
int main()
{
string strNames[] = { "Name1", "Name2", "Name3", "Name4", "Name5", "Name6"};
for each(string name in strNames)
{
printf("%s\n", name.c_str());
}
return 0;
}