(Audio and video study notes): Extract pixel format and PCM data, command to package

table of Contents

ffmpeg command to extract pixel format and PCM data

ffmpeg command to extract pixel format

ffmpeg command to extract PCM data

ffmpeg command to package

ffmpeg command to extract pixel format and PCM data

ffmpeg command to extract pixel format

【Extract YUV】

  • Extract 3 seconds of data, the resolution is the same as the source video
fmpeg -i test_1280x720.mp4 -t 3 -pix_fmt yuv420p yuv420p_orig.yuv
  • Extract 3 seconds of data and convert the resolution to 320x240
ffmpeg -i test_1280x720.mp4 -t 3 -pix_fmt yuv420p -s 320x240 yuv420p_320x240.yuv

【Extract RGB】

  • Extract 3 seconds of data and convert the resolution to 320x240
ffmpeg -i test.mp4 -t 3 -pix_fmt rgb24 -s 320x240 rgb24_320x240.rgb

[Conversion between RGB and YUV]

ffmpeg -s 320x240 -pix_fmt yuv420p -i yuv420p_320x240.yuv -pix_fmt rgb24 rgb24_320x240_2.rgb

ffmpeg command to extract PCM data

【Extract PCM】

ffmpeg -i buweishui.mp3 -ar 48000 -ac 2 -f s16le 48000_2_s16le.pcm
ffmpeg -i buweishui.mp3 -ar 48000 -ac 2 -sample_fmt s16 out_s16.wav
ffmpeg -i buweishui.mp3 -ar 48000 -ac 2 -codec:a pcm_s16le out2_s16le.wav
ffmpeg -i buweishui.mp3 -ar 48000 -ac 2 -f f32le 48000_2_f32le.pcm
ffmpeg -i test.mp4 -t 10 -vn -ar 48000 -ac 2 -f f32le 48000_2_f32le_2.pcm

ffmpeg command to package

[Keep coding format]

ffmpeg -i test.mp4 -vcodec copy -acodec copy test_copy.ts
//两种命令等效
ffmpeg -i test.mp4 -codec copy test_copy2.ts

[Change encoding format]

ffmpeg -i test.mp4 -vcodec libx265 -acodec libmp3lame out_h265_mp3.mkv

【Modify Frame Rate】

  • Need to re-encode, do not add -codec copy
fmpeg -i test.mp4 -r 15 output2.mp4

[Modify video code rate]

  • Audio is re-encoded
ffmpeg -i test.mp4 -b 400k output_b.mkv 

[Modify video code rate]

  • Video is re-encoded
ffmpeg -i test.mp4 -b:v 400k output_bv.mkv

【Modify audio code rate】

  • If you don’t want to re-encode the video, you need to add -vcodec copy
fmpeg -i test.mp4 -b:a 192k output_ba.mp4

【Modify audio and video code rate】

ffmpeg -i test.mp4 -b:v 400k -b:a 192k output_bva.mp4

【Modify video resolution】

  • Need to recode
ffmpeg -i test.mp4 -s 480x270 output_480x270.mp4

[Modify audio sampling rate]

ffmpeg -i test.mp4 -ar 44100 output_44100hz.mp4

 

Guess you like

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