PHP uses FFmpeg to extract audio and video footage from video

Source: Internet
Author: User
To extract the audio information from the video, the preferred technique is that ffmpeg,ffmpeg is a very useful command-line program that can be used to transcode media files. This article mainly introduces the use of PHP FFmpeg extract video audio and video footage of the relevant information, the need for friends can refer to.

Objective

The name of FFmpeg comes from the MPEG video coding standard, the front "FF" stands for "Fast Forward", and FFmpeg is an open-source computer program that can be used to record, convert digital audio, video, and turn it into a stream. It is easy to convert multiple video formats to each other.

FFmpeg users have Google,facebook,youtube, Youku, iqiyi art, potatoes and so on.

Composition

1, Libavformat: For a variety of audio and video packaging format generation and resolution, including to obtain the information needed to decode the decoding context structure and read the audio and video frames and other functions, containing demuxers and Muxer library;

2, Libavcodec: For various types of sound/image codec;

3, Libavutil: Contains some common tool functions;

4, Libswscale: For video scene scaling, color mapping conversion;

5, Libpostproc: For the post-processing effect;

6, FFmpeg: is a command line tool for the video file conversion format, also supports real-time encoding of the TV card;

7, Ffsever: is an HTTP multimedia real-time broadcast streaming server, support time translation;

8, Ffplay: is a simple player, using the FFmpeg library parsing and decoding, through the SDL display;

Extracting audio and video footage from video

To extract the audio information from the video, the preferred technique is ffmpeg, and the vast majority of ffmpeg use tutorials on the Web are:

Like your file is Test.mp4.

Separate video out:ffmpeg -i test.mp4 -vcodec copy -an 视频流.avi

Separate the audio out:ffmpeg -i test.mp4 -acodec copy -vn 音频流.mp3

In this way, there is no problem in extracting the video. But when I extracted the audio, I encountered the following error:


Invalid Audio stream. Exactly one MP3 audio stream is required. Could not write header for output file #0 (incorrect codec parameters) Invalid argument


In fact, simply extracting the audio and video does not need to be so complicated, just execute the following two lines:

Separate video out:ffmpeg -i test.mp4 视频流.avi

Separate the audio out:ffmpeg -i test.mp4 音频流.mp3

Summarize

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.