preface

In the project, it is useful to combine multiple MP4 videos into one MP4 and cut one MP4 into multiple MP4 filesCopy the code

Viewing File Information

ffmpeg -i input.mp4
Copy the code

Multiple MP4 files are combined into one MP4 file

  1. Concat (not available for MP4)
ffmpeg -i "concat:input1|input2" -codec copy output
Copy the code
  1. First convert mp4 files to TS, and then TS synthesizes MP4 files (for this use)
  • A. to ts
    ffmpeg -i input.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts input.ts
    Copy the code
  • B.t s synthetic mp4
    ffmpeg -i "concat:input1.ts|input2.ts|input3.ts" -c copy -bsf:a aac_adtstoasc -movflags +faststart output.mp4
    Copy the code

An MP4 is cut into multiple MP4 files

ffmpeg -i input.mp4 -vf "crop=out_w:out_h:x:y" -y output.mp4
Copy the code
  • Out_w is the width of the output rectangle
  • Out_h is the height of the output rectangle
  • x:y specify the top left corner of the output rectangle
  • Reference (video.stackexchange.com/questions/4…

Add watermark to MP4 files

ffmpeg -i input.mp4 -i overlay.png -filter_complex "[1:v]scale=800x800 [ovrl], [0:v][ovrl]overlay=0:0 " -c:v libx26 -profile:v baseline -level 3.1 -s 368x368 -y 
Copy the code
  • Overlay. PNG is a watermark image

reference

  • Stackoverflow.com/questions/7…

  • ffmpeg.org/

Original address: here