After the weekend, I should organize the skills used in my work last week and write them into a blog, which is also convenient for me to check later.
Recently usedFFmpegFor video transcoding, considerFFmpegThis tool supports multiple threads, and the server is also multi-core. We want to maximize the computing power of the server. Obviously, you cannot use a single thread, but the more threads, the better. You need to find a balance point. This requiresTimeCommand, and redirect the output of the screen to a file for later analysis.
FFMPEG many encoding methods are available online, here are some examples ( http://www.cnblogs.com/MikeZhang/archive/2012/07/17/videoCodec.html in " 3. Video Encoding tools " are described in this section ). Today we will introduce FFMPEG transcoding, and time command redirection.
Suppose I haveIn.mp4Video file, resolution is640*480, Bit rate is580 kbpsTo reduce the resolution320*240To reduce the bit rate290 kbps(This parameter does not take effect when used at the same time as the resolution, especially when you exit midway through ).
Common commands to reduce the resolution and bit rate:
FFmpeg-y-IIn. MP4-s 32Zero x 240-B290000Out290.mp4
TapeThreadParameter command:
FFmpeg-y-threads2-IIn. MP4-s 32Zero x 240-B290000Out290.mp4
Two threads are used here.
UseTimeTime Statistics command:
TimeFFmpeg-y-threads2-IIn. MP4-s 32Zero x 240-B290000Out290.mp4
Output redirection command:
(TimeFFmpeg-y-threads2-IIn. MP4-s 32Zero x 240-B290000Out290.mp4)2>1. Txt
Because the output is a standard error, we use2> 1.txt
You can also use the following command:
(TimeFFmpeg-y-threads2-IIn. MP4-s 32Zero x 240-B290000Out290.mp4)> &1. Txt
You can useTeeCommand. First, redirect the standard error to the standard output, and then pass it to the file through the channel. The command is as follows:
(TimeFFmpeg-y-threads2-IIn. MP4-s 32Zero x 240Out290.mp4)2> &1|Tee 1. Txt
If you want to test the number of threads supported by the server, you need to write a script to run it. Here I have one for your reference only:
#! /Bin/Bash Echo " Input num: " Read num For (I = 1 ; I <= $ num; I = I + 1 )) Do #( Time FFmpeg-y-threads $ I-I In . MP4-s 32 Zero x 240 -Vcodec libx264-vpre fast out290.mp4)> & $ I .txt ( Time FFmpeg-y-threads $ I-I In . MP4-s 32 Zero x 240 -Vcodec libx264-vpre fast out290.mp4) 2 > & 1 | Tee $ I .txt Done
Okay, start the script and let the server fly for a while.TailCommand.
Okay, that's all. I hope it will help you.