Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Video Metadata Question
#7
(Jul-20-2018, 11:23 PM)malonn Wrote: the basic approach I need is to open the file in binary mode and read a certain amount of bytes, right?
That's a start,read some data let say 1000 bytes at time and look at the data.
Example.
with open('planet.mkv', 'rb') as f:
    data = f.read()[:1000]
    print(data)
When doing this test i can see that some of the meta data is in clear text.
To take of some data.
import re

with open('planet.mkv', 'rb') as f:
    data = f.read()[:3000]
    #print(data)

rate = re.search(b'bitrate=\d+', data)
print(rate.group())
vbv_max = re.search(b'vbv_maxrate=\d+', data)
print(vbv_max.group())
Output:
b'bitrate=2250' b'vbv_maxrate=2812'
From bytes to string(this Unicode bye default) in Python 3.
>>> b = b'bitrate=2250'
>>> type(b)
<class 'bytes'>

>>> s = b.decode() # same as decode('utf-8')
>>> s
'bitrate=2250'
>>> type(s)
<class 'str'>
Reply


Messages In This Thread
Video Metadata Question - by malonn - Jul-20-2018, 03:53 PM
RE: Video Metadata Question - by DeaD_EyE - Jul-20-2018, 04:54 PM
RE: Video Metadata Question - by snippsat - Jul-20-2018, 06:37 PM
RE: Video Metadata Question - by malonn - Jul-20-2018, 08:35 PM
RE: Video Metadata Question - by snippsat - Jul-20-2018, 09:51 PM
RE: Video Metadata Question - by malonn - Jul-20-2018, 11:23 PM
RE: Video Metadata Question - by snippsat - Jul-21-2018, 12:41 AM
RE: Video Metadata Question - by malonn - Jul-21-2018, 01:26 AM
RE: Video Metadata Question - by malonn - Jul-21-2018, 05:17 PM
RE: Video Metadata Question - by malonn - Jul-21-2018, 08:26 PM
RE: Video Metadata Question - by malonn - Jul-23-2018, 04:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question image manipulation (cropping and MetaData) SpongeB0B 4 1,244 Jul-03-2023, 06:35 PM
Last Post: SpongeB0B
  AttributeError: 'function' object has no attribute 'metadata 3lnyn0 5 4,818 Mar-28-2022, 04:42 PM
Last Post: Larz60+
  Adding Language metadata to a PDF programmatically bhargavi22 0 1,982 Aug-17-2020, 12:53 PM
Last Post: bhargavi22
  METADATA Errors millpond 0 1,964 Jul-21-2020, 08:22 AM
Last Post: millpond
  How to sort image files according to a metadata file? Brahmslove 1 3,181 Dec-05-2019, 11:25 PM
Last Post: scidam
  Parse the data in XML metadata field klllmmm 2 3,350 Jun-19-2019, 04:24 PM
Last Post: klllmmm
  Tiff metadata sudecki 1 22,763 Aug-10-2018, 07:08 AM
Last Post: sudecki
  I have a question from a YouTube video I saw: nelsonkane 9 5,290 Dec-27-2017, 11:17 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020