Skip to content

Instantly share code, notes, and snippets.

@cnruby
Last active March 26, 2020 21:24
Show Gist options
  • Save cnruby/96ea7978892831ec4b8b8815e4181551 to your computer and use it in GitHub Desktop.
Save cnruby/96ea7978892831ec4b8b8815e4181551 to your computer and use it in GitHub Desktop.
ffpmeg-merging-mp4-video-files
# install ffmpeg on MacOS
brew install ffmpeg
brew cask install vlc
# merge two vidoes into one video
ls
INPUT_VIDEO_1=input_01
INPUT_VIDEO_2=input_02
OUTPUT_VIDEO=output
ffmpeg -i $INPUT_VIDEO_1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts $INPUT_VIDEO_1.ts
ffmpeg -i $INPUT_VIDEO_2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts $INPUT_VIDEO_2.ts
ffmpeg -i "concat:$INPUT_VIDEO_1.ts|$INPUT_VIDEO_2.ts" -c copy -bsf:a aac_adtstoasc $OUTPUT_VIDEO.mp4
/Applications/VLC.app/Contents/MacOS/VLC $OUTPUT_VIDEO.mp4
# change just once setting
/Applications/VLC.app/Contents/MacOS/VLC --version
vlc --version
echo "alias vlc=/Applications/VLC.app/Contents/MacOS/VLC" >> ~/.bash_profile
source ~/.bash_profile
vlc --version
# use the command 'vlc'
vlc $OUTPUT_VIDEO.mp4
@cnruby
Copy link
Author

cnruby commented Mar 26, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment