Summary of software development for converting videos to FLV in batches (2) -- Technical Summary: FFMPEG

Source: Internet
Author: User

The following is a special summary of the technical experience and gains, mainly about the actual problems and solutions encountered when using FFMPEG, and will also recommend relevant online materials.

I. formats supported by FFMPEG

Formats that can be parsed by ffmpeg.exe: (ASX, ASF, mpg, WMV, 3GP, MP4, mov, Avi, and FLV ),Mencoder can be used to convert files that cannot be parsed by ffmpeg.exe (such as wmv9, RM, and rmvb.

Ii. FFMPEG parameter problems

example: FFmpeg-y-I "1.avi"-title" test "-vcodec XviD-s 368x208-r 29.97-B 1500-acodec AAC-AC 2-ar 24000-AB 128-Vol 200-f psp-muxvisual 768 "1. * ** "

Explanation: The preceding commands can be entered in the doscommand line or created to run in a batch file. However, the premise is that it should be executed in the directory where FFmpeg is located (the cores subdirectory under the directory where conversion is located ).
Parameters:
-Y (overwrite the output file, that is, if the 1. *** file already exists, it will be overwritten without prompt)
-I "1.avi" (the input file is a 1. AVI file in the same directory as FFMPEG. You can add the path and change the name)
-Title "test" (the title of the video displayed in PSP)
-Vcodec Xvid (videos are compressed using Xvid encoding and cannot be changed)
-S 368x208 (the output resolution is 368x208. Note that the source of the video must be or it will be deformed)
-R 29.97 (the number of frames. This is generally used)
-B 1500 (for video data traffic, use the-B XXXX command to use a fixed bit rate. The number can be changed as needed, and the value above 1500 does not work. Dynamic bit rates can also be used, for example: -The quality of qscale 4 and-qscale 6 is 6)
-Acodec aac (AAC for Audio Encoding)
-AC 2 (number of audio channels: 1 or 2)
-Ar 24000 (sound sampling frequency, as if PSP only supports 24000Hz)
-AB 128 (audio data traffic, usually 32, 64, 96, 128)
-Vol 200 (200% volume, change by yourself)
-F psp (dedicated output PSP format)
-Muxvb 768 (it seems to be the bit rate recognized by PSP machines. Generally, we select 384, 512, and 768. if I change it to 1500, PSP will say the file is damaged)
"1. ***" (output file name, you can also add a path to change the file name)

Reprinted from: http://g006.javaeye.com/blog/347152

3. Obtain output information using FFMPEG(Problem solving: http://www.ffmpeg.com.cn/index.php/.NET_2.0 (c)

Reprinted: . NET 2.0 calls FFMPEG and asynchronously reads the output informationCode...

Public void convertvideo () {PROCESS p = new process (); // create an external call thread P. startinfo. filename = @ "C: \ ffmpeg.exe"; // call an external callProgramAbsolute path of P. startinfo. arguments = "-I xxxxxxxxxxxxxx"; // parameter (here is the FFMPEG parameter) p. startinfo. useshellexecute = false; // do not use the operating system shell program to start the thread (it must be false. For details, see msdn) p. startinfo. redirectstandarderror = TRue; // write the error output of an external program to the standarderror stream. (Note that all output information of FFmpeg is an error output stream,
 
Standardoutput is used to capture no messages... this is an experience I have spent more than two months.... mencoder uses standardoutput To Capture messages)
P. startinfo. createnowindow = false; // do not create a process window p. errordatareceived + = new datareceivedeventhandler (output); // events generated when an external program (FFMPEG) outputs the stream. Here, the stream processing process is transferred to the following method, for details, refer to msdn p. start (); // start the thread p. beginerrorreadline (); // starts asynchronous reading of P. waitforexit (); // blocking waits for the process to end p. close (); // close the process P. dispose (); // release resources} private void output (Object sendprocess, datareceivedeventargs output) {If (! String. isnullorempty (output. Data) {// processing method ...}}

 
Beginerrorreadline can read standarderror streams synchronously or asynchronously. The read, Readline, and readtoend Methods perform synchronous read operations on the error output stream of the process.
 
These synchronous read operations can only be completed after the associated process writes the standarderror stream or closes the stream. Conversely, beginerrorreadline
 
Start asynchronous read operations on the standarderror stream. This method enables the specified event handler for the stream output and immediately returns it to the caller.
 
When the event handler is directed, the caller can perform other operations. Follow these steps to perform asynchronous read operations on standarderror of process:
    • Set useshellexecute to false.
    • Set redirectstandarderror to true.
    • Add an event handler to the errordatareceived event. The event handler must match the system. Diagnostics. datareceivedeventhandler delegate signature.
    • START process.
    • Call beginerrorreadline of process. This call starts the asynchronous read operation on standarderror.
    • When an asynchronous read operation is started, the associated process calls the event handler every time it writes a line of text to its standarderror stream.
    • You can call cancelerrorread to cancel asynchronous read operations. The read operation can be canceled by the caller or event handler. After cancellation, you can call beginerrorreadline again to continue asynchronous read operations.
 
The errordatareceived event indicates that the associated process has been written to its redirected standarderror stream. This event occurs only when standarderror is asynchronously read.
 
To enable asynchronous read operations, you must redirect the standarderror stream of process to add an event handler to the errordatareceived event,
 
And call beginerrorreadline. When this process writes a row to the redirected standarderror stream, the errordatareceived event
 
Sends a signal until the process exits or calls cancelerrorread.

4. Recommendation website

Java instance: http://www.w3china.org/blog/more.asp? Name = lhwork & id = 22488

FFmpeg China: http://www.ffmpeg.com.cn/

FFmpeg: http://ffmpeg.org/

Official documents: http://ffmpeg.org/ffmpeg-doc.html

Parameter description: http://www.cnblogs.com/94cool/archive/2009/08/28/1555830.html

Http://www.chinaz.com/Design/Video/0223CG32009.html

Related Article

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.