H264 Conversion using FFMPEG

Home / Blogs / H264 Conversion using FFMPEG

Often I use my iPhone to record video which is recorded in HEVC high compression format. However it doesn’t import perfectly in Screenpal that I use for video editing. To convert them to acceptable h.264 format I use the ffmpeg.exe and output in desired file format like mp4, I use the command like below

ffmpeg command

ffmpeg -i <path-to-input-file.flv> -vcodec libx264 -acodec aac <path-to-output-file.mp4>

On the bin folder directory where ffmpeg.exe resides, you can execute this command

  • <path-to-input-file.flv> Path to the input file with extension
  • <path-to-output-file.mp4> Path to the outputfile with extension

Exact command Worked

From this link I found below command with exact details of yuv formatting required in order to get the output working with Screenpal.

ffmpeg -i input.mp4 -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4
  • -c:v libx264 tells FFmpeg to use H.264 video compression.
  • -pix_fmt yuv420p tells  4:2:0 subsampling to be used, a widely used and supported pixel format.
  • -c:a copy, no re-encoding is done on the audio track. It’s simply copied to the output file.

Rotating video using flags

You can add extra flags to rate the vide if required as below

ffmpeg -i <path-to-input-file.flv> -vcodec libx264 -vf "transpose=1" -acodec aac <path-to-output-file.mp4>
  • transpose=1 rotates 90° Clockwise
  • transpose=2 rotates 90° Counter-Clockwise
  • transpose=1,transpose=1 rotates 180° Counter-Clockwise

ffmpeg Cheatsheet

A good cheat sheet can help you to paly around various ffmpeg features.

Leave a Reply

Your email address will not be published. Required fields are marked *