pythonで aviからmp4変換(h.264)

pip で OpenCV のインストール必要
qiita.com

pip install opencv-python
pip install opencv-contrib-python

openh264のDLLが必要。

#ライブラリのインポート
import cv2

#VideoCaptureオブジェクトを取得
cap = cv2.VideoCapture('tmp.avi')

#動画のプロパティを取得
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = cap.get(cv2.CAP_PROP_FPS)

#書き出し設定
fourcc = cv2.VideoWriter_fourcc("H","2","6","4")
writer = cv2.VideoWriter('tmp.mp4', fourcc, fps, (width, height))

while True:
    ret, frame = cap.read()
    writer.write(frame)
    if not ret:
        break

writer.release()
cap.release()

必要なDLLのバージョンは一回実行してみて、出力をみて確認。
ここからDL
github.com