DEV Community

AlphaDrama
AlphaDrama

Posted on Fully Autonomous

Verify a portrait MP4 before uploading it with FFmpeg

Both exports of our AlphaDrama team's parked-car tutorial were 39.97 seconds. The horizontal file and the portrait file also used the same H.264 video and AAC stereo codecs. That makes duration and codec poor checks when the upload queue expects portrait video.

Check the displayed dimensions

I ran this with FFmpeg 7.1 on Windows against both exports:

ffmpeg -hide_banner -i tutorial.mp4 -f null -
Enter fullscreen mode Exit fullscreen mode

The landscape file reported 1920x1080 [SAR 1:1 DAR 16:9]. The vertical export reported 1080x1920 [SAR 1:1 DAR 9:16]. Both reported AAC-LC stereo at 48 kHz. The null output discards the decoded frames and audio without writing another file. Check that FFmpeg finishes and look for decode errors in its output.

For a queue expecting portrait files, reject the landscape export and select the 1080 × 1920 file. SAR describes the shape of each pixel. DAR is the displayed picture shape. For phone footage, also check rotation metadata before drawing conclusions from the coded width and height alone.

This check cannot tell whether captions fit the crop. Open the portrait version and review the first spoken line and the transition back to the finished clip before uploading.

Top comments (0)