How to Merge Multiple MP4 videofiles using concat while transposing 180o two MP4 videofiles?

Currently, i am using the following ffmpeg (concat) command:

ffmpeg -f concat -safe 0 -i VIDEOFILES.txt -r 32 -crf 14  -vcodec libx264 -vb 20M -vf "scale=1280:720,setpts=0.25*PTS" -fflags +genpts  -an   video_output_01.avi

How can I, in the same time, transpose two MP4 files 180 degrees?

Note that i used the following HEX code hack HERE "True lossless rotation of MP4: " to rotate MP4 video files 180 degrees but ffmpeg ignored that information during encoding time!

What I can do?

1 Answer 1


I finally found out how to do it!

ffmpeg -f concat -safe 0 -i VIDEOFILES.txt -filter_complex  \
 "[0:v] fps=32, scale=1920:1080, vflip, hflip, setpts=0.25*PTS, fifo [v0]; \
  [0:v] fps=32, scale=1920:1080, vflip, hflip, setpts=0.25*PTS, fifo [v1];  
  [v0][v1]concat=n=2:v=1[out]" -map "[out]" -crf 14  -vcodec libx264  -vb 20M  -loglevel error  video_out_01.avi
  • concat: concetrate files
  • VIDEOFILES.txt: video files with path included, eg. file '/path/a.mp4' (including file)
  • fps=32, scale=1920:1080: drop to 32 frames, and reducing video resolution
  • vflip, hflip: 180 degrees rotation of the video
  • setpts=0.25*PTS: Four times speeder
  • fifo: a ffmpeg filter that it says to wait frame to be fully processed before it is given to the next process --- due to some filter process frame quicker than others e.g. due to frame drop (?)
  • crf 14: High quality ensured (0 = uncompressed)
  • vcodec libx264: codec to compress the video file
  • vb 20M: video bitrate (a high one)
  • loglevel error: ffmpeg output information only errors will be displayed

BIG Questions:

A) I tried to reverse the order of filters eg. [0:v] setpts=0.25*PTS, fps=32, scale=1920:1080, vflip, hflip, fifo [v0] However, it was extremely low. The commands are executed seriasly? Then, why I must recode every frame, when only 1/4 of them will be kept? How can I do that in order to gain recoding speed?

B) Why I need FIFO eventually. This must be not the default behavior? All frames that are kept must be processed from all filters! Right? Why then ffmpeg drop frames without being processed? this is the meaning of FIFO? Right?

UPDATE: ffmpeg 4.2.3 freezes when multiple video files exist e.g. >5

  • I am still looking for a solution Jun 14, 2020 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.