• How to prepare videos for iCloud

    Old video tapes in archive

    Recently, I switched to the Apple ecosystem of devices almost entirely and transitioned all my data into iCloud for ease of usage. The main issue I encountered was that not all popular video formats are supported. It could have been a better experience moving years of photos and videos to the service. (But it’s not, haha!)

    The common Apple way to solve it is to buy a fancy video converter just for 95.99$ (only today). But why would we do it when we already have everything in the console? Let’s go.

    Prepare

    FFmpeg is a powerful command-line tool to manipulate video and audio files easily. On macOS, you can get it using Homebrew.

    brew install ffmpeg

    Copy to another container

    A video file is like a box with goodies. But if it is only the box that iCloud dislikes, you can move the video and audio information without any encoding:

    ffmpeg -i VIDEO_00001.mkv -c copy 1.mov
    • -i VIDEO_00001.mkv specifies the input file
    • -c copy tells ffmpeg to copy both audio and video data without encoding it into something else
    • 1.mov is the name of the resulting file

    Encode video but copy audio

    ffmpeg -i VIDEO_00001.mkv -c:v libx264 -profile:v main -level 3.1 -preset medium -crf 23 -x264-params ref=4 -c:a copy 1.mov
    • -i VIDEO_00001.mkv specifies the input file
    • -c:v libx264 specifies the video codec to use, H.264 is a good one for our needs
    • -profile:v main -level 3.1 -preset medium -crf 23 -x264-params ref=4 are settings for video codec suitable for a decent quality
    • -c:a copy tells to copy audio codec without encoding

    Encode audio but copy video

    ffmpeg -i VIDEO_00001.mkv -c:v copy -c:a aac 1.mov
    • -i VIDEO_00001.mkv specifies the input file
    • -c:v copy tells to copy video codec without encoding
    • -c:a aac specifies the audio codec to use

    Encode in a batch

    for f in *.mkv; do ffmpeg -i "$f" -c copy "${f%.mkv}.mov"; done

    This snippet will find all *.mkv files in a given directory and convert them to mov of the same name using the -c copy strategy. You can change it to what suits your needs.

One is the pinnacle of evolution; another one is me

One on the picture is the pinnacle of evolution; another one is me: inspired developer, geek culture lover, sport and coffee addict