Saturday, April 24, 2021

How to concatenate videos with ffmpeg

This one works for me:

ffmpeg -i input1.mp4 -i input2.webm -i input3.mov \
-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1[outv][outa]" \
-map "[outv]" -map "[outa]" output.mkv


Reference: https://trac.ffmpeg.org/wiki/Concatenate

It assumes the videos have the same size and TBR. To transpose a video when one is vertical and another is horizontal, see here.
When video TBRs are different, it may come up with the strange message:

"More than 1000 frames duplicated"

When this happens, try adding "-vsync 2" to the command. Reference: https://stackoverflow.com/questions/62822889/ffmpeg-filter-complex-concat-never-completes. It worked for me.

How to transpose a video with ffmpeg

ffmpeg -i input.mp4 -vf "transpose=1" output.mp4

or

ffmpeg -i input.mp4 -vf "transpose=clock" output.mp4

for one 90-deg clockwise rotation.


Reference: https://ostechnix.com/how-to-rotate-videos-using-ffmpeg-from-commandline/#:~:text=FFMpeg%20has%20a%20feature%20called,flip%20them%20vertically%20and%20horizontally.&text=Here%2C%20transpose%3D1%20parameter%20instructs,video%20by%2090%20degrees%20clockwise.

Monday, April 5, 2021

Combine image + audio file to make a video

Source: https://video.stackexchange.com/questions/5291/how-to-make-a-video-from-a-still-image-and-an-audio-file

I tried at least 5 commands from different sites, and only this one worked well enough for me - about 37x speed, waitable.

ffmpeg -loop 1 -f image2 -r 2 -i image.jpg -i audio.m4a -c:v libx264 -c:a copy -shortest video.mp4

Wednesday, February 3, 2021

How to prevent Automounting of Volumes (USB drives, optical discs, etc) upon connecting on Mac OS X

 https://discussions.apple.com/docs/DOC-7942

  1. diskutil info /Volumes/<volume that shouldn't be mounted>
  2. Get UUID from output from above step 1.
  3. sudo /etc/vifs
  4. Add this to the file:
    1. UUID=<LONG-UUID-LIKE-F77F-3F72-A6C2-26676F39B7CE> none hfs rw,noauto
  5. sudo automount -vc
Done! Worked for me!

Saturday, December 26, 2020

ffmpeg aac -> mp3 conversion

It seems that it isn't easy to handle aac/m4a files in sox anymore. Online help threads suggest using ffmpeg to convert it to mp3 instead:

 ffmpeg -i input.m4a -c:a libmp3lame -q:a 8 output.mp3

Reference link: https://askubuntu.com/questions/1200430/how-to-convert-m4a-audio-files-to-mp3-use-command-line