Shenma 16-core server you asked me to run FFMPEG in a single thread

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.