(Audio and video study notes): parameter description and extraction of audio and video data

table of Contents

The main parameters

Audio parameters

Video parameters

ffmpeg command to extract audio and video data

Keep package format

Extract video

Extract audio

The main parameters

  • -i            set input stream
  • -f           set output format (format)
  • -ss         start time
  • -t           time length
ffmpeg -i test.mp4 -codec copy -ss 10 -t 10 -f flv out.mp4 
  • The output is actually in flv format.
  • If the suffix prevails, you need to remove -f flv.

[Query the full name of MP3 format]

ffmpeg -encoders | findstr mp3

Audio parameters

  • -aframes                               sets the number of audio frames to be output
  • -b:a                                       audio bit rate
  • -ar                                        set sampling rate
  • -ac                                     sets the number of sound channels  
  • -acodec                                sets the sound codec, if copy is used to indicate that the original codec data must be copied.
  • -an                                       does not process audio
  • -af                                        audio filter
fmpeg -i test.mp4 -b:a 192k -ar 48000 -ac 2 -acodec libmp3lame -aframes 200 out.mp3

Video parameters

  • -vframes                             sets the number of video frames to be output
  • -b                                        set video bit rate
  • -b:v                                     video bit rate
  • -r                                         set frame rate
  • -s                                        set the width and height of the screen
  • -vn                                      does not process video
  • -aspect aspect              set the aspect      ratio 4:3, 16:9 or 1.3333 1.7777
  • -vcodec                              sets the video codec, if copy is used to indicate that the original codec data must be copied.
  • -vf                                       video filter
fmpeg -i test.mp4 -vframes 300 -b:v 300k -r 30 -s 640x480 -aspect 16:9 -vcodec libx265

ffmpeg command to extract audio and video data

Keep package format

ffmpeg -i test.mp4 -acodec copy -vn audio.mp4

ffmpeg -i test.mp4 -vcodec copy -an video.mp4

Extract video

  • Keep encoding format:
ffmpeg -i test.mp4 -vcodec copy -an test_copy.h264
  • Mandatory format:
ffmpeg -i test.mp4 -vcodec libx264 -an test.h264

Extract audio

  • Keep encoding format:
fmpeg -i test.mp4 -acodec copy -vn test.aac
  • Mandatory format:
fmpeg -i test.mp4 -acodec libmp3lame -vn test.mp3

Guess you like

Origin blog.csdn.net/baidu_41388533/article/details/112255111