LoginSignup
0
0

More than 3 years have passed since last update.

Python上でintのFourCCを文字列に復元する雑なメモ

Posted at

GStreamerやOpenCVで動画のFourCCを取得すると、以下のように数値で帰ってくる

 In [1]: import cv2

 In [2]: cap = cv2.VideoCapture('./XXXXXX.avi')

 In [3]: cap.get(cv2.CAP_PROP_FOURCC)
 Out[3]: 844713045.0

これをリトルエンディアンでbyte化 -> UTF-8でデコードすると、4文字の文字列に変換できる

 In [4]: fourcc = list((fourcc_int.to_bytes(4, 'little').decode('utf-8')))

 In [5]: fourcc
 Out[5]: ['U', 'L', 'Y', '2']
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0