Search code examples
ffmpegandroid-ffmpeg

FFmpeg add rotation to a video generated from an image


I am new to FFmpeg and I don't know how to add rotate="90" to my command. I tried to add it in different places and I get Unable to find suitable output format for 'rotate=90' rotate=90: Invalid argument.

I want to append an intro video to a series of other videos taken with an android camera and concatenate them together. The concatenation works fine except the rotation should be in portrait mode and not landscape.

This is my command:

const ffmpegCommand = `-hide_banner -loglevel error -loop 1 -i ${imageUri} -f lavfi -i anullsrc=cl=mono:r=48000 -c:v libx264 -profile:v high -level:v 4.0 -video_track_timescale 90k -t ${duration} -pix_fmt yuv420p -r ${resolution[0]/resolution[1]} ${outputUri}`;

  

Solution

  • Found a solution. I am not sure if its the right solution but for me it does what I need.

    const ffmpegCommand = `-i ${firstRecordedVideURL} -i ${generatedImageVideoURL} -map 1 -c copy \ -map_metadata 0 \ -map_metadata:s:v 0:s:v \ -map_metadata:s:a 0:s:a \ ${output}`;
    

    I take the first video recorded via the android camera and copy the metadata to the video that I just generated from an image file. This way the generated video will have a matching metadata and the concatenation will work as expected.