Compare commits
5 Commits
97dd6c691b
...
51fa25809d
| Author | SHA1 | Date | |
|---|---|---|---|
|
51fa25809d
|
|||
|
de6c3a4e7f
|
|||
|
2ed4c7b6d8
|
|||
|
4afaf287bb
|
|||
|
5825c67f30
|
12
.gitmodules
vendored
Normal file
12
.gitmodules
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[submodule "ffmpeg"]
|
||||||
|
path = ffmpeg
|
||||||
|
url = https://git.ffmpeg.org/ffmpeg.git
|
||||||
|
branch = release/8.0
|
||||||
|
[submodule "codecs/x264"]
|
||||||
|
path = codecs/x264
|
||||||
|
url = https://code.videolan.org/videolan/x264.git
|
||||||
|
branch = stable
|
||||||
|
[submodule "codecs/x265"]
|
||||||
|
path = codecs/x265
|
||||||
|
url = https://bitbucket.org/multicoreware/x265_git.git
|
||||||
|
branch = Release_4.1
|
||||||
1
codecs/x264
Submodule
1
codecs/x264
Submodule
Submodule codecs/x264 added at b35605ace3
1
codecs/x265
Submodule
1
codecs/x265
Submodule
Submodule codecs/x265 added at 32e25ffcf8
1
ffmpeg
Submodule
1
ffmpeg
Submodule
Submodule ffmpeg added at d8605a6b55
@ -38,7 +38,13 @@ class Decoder:
|
|||||||
if self._context:
|
if self._context:
|
||||||
libav.codec_free_context(self._context)
|
libav.codec_free_context(self._context)
|
||||||
|
|
||||||
def _receive(self):
|
def decode(self, packet):
|
||||||
|
if not self._context:
|
||||||
|
return None
|
||||||
|
errcode = libav.codec_send_packet(self._context, packet)
|
||||||
|
if errcode < 0:
|
||||||
|
errstring = libav.strerror(errcode)
|
||||||
|
raise Exception(f"Failed to send packet: {errstring}")
|
||||||
frames = []
|
frames = []
|
||||||
while True:
|
while True:
|
||||||
frame = Frame()
|
frame = Frame()
|
||||||
@ -50,12 +56,3 @@ class Decoder:
|
|||||||
raise Exception(f"Failed to receive frame: {errstring}")
|
raise Exception(f"Failed to receive frame: {errstring}")
|
||||||
frames.append(frame)
|
frames.append(frame)
|
||||||
return frames
|
return frames
|
||||||
|
|
||||||
def decode(self, packet):
|
|
||||||
if not self._context:
|
|
||||||
return None
|
|
||||||
errcode = libav.codec_send_packet(self._context, packet)
|
|
||||||
if errcode < 0:
|
|
||||||
errstring = libav.strerror(errcode)
|
|
||||||
raise Exception(f"Failed to send packet: {errstring}")
|
|
||||||
return self._receive()
|
|
||||||
|
|||||||
31
mp4/libav.py
31
mp4/libav.py
@ -40,8 +40,32 @@ AVMEDIA_TYPE_DATA = 2
|
|||||||
AVMEDIA_TYPE_SUBTITLE = 3
|
AVMEDIA_TYPE_SUBTITLE = 3
|
||||||
AVMEDIA_TYPE_ATTACHMENT = 4
|
AVMEDIA_TYPE_ATTACHMENT = 4
|
||||||
|
|
||||||
|
AV_NUM_DATA_POINTERS = 8
|
||||||
|
|
||||||
|
c_uint8_p = ctypes.POINTER(ctypes.c_uint8)
|
||||||
|
c_uint8_pp = ctypes.POINTER(c_uint8_p)
|
||||||
|
|
||||||
|
class AVRational(ctypes.Structure):
|
||||||
|
_fields_ = [
|
||||||
|
("num", ctypes.c_int),
|
||||||
|
("den", ctypes.c_int)]
|
||||||
|
|
||||||
class AVFrame(ctypes.Structure):
|
class AVFrame(ctypes.Structure):
|
||||||
pass
|
_fields_ = [
|
||||||
|
("data", c_uint8_p * AV_NUM_DATA_POINTERS),
|
||||||
|
("linesize", ctypes.c_int * AV_NUM_DATA_POINTERS),
|
||||||
|
("extended_data", c_uint8_pp),
|
||||||
|
("width", ctypes.c_int),
|
||||||
|
("height", ctypes.c_int),
|
||||||
|
("nb_samples", ctypes.c_int),
|
||||||
|
("format", ctypes.c_int),
|
||||||
|
("key_frame", ctypes.c_int),
|
||||||
|
("pict_type", ctypes.c_int),
|
||||||
|
("sample_aspect_ratio", AVRational),
|
||||||
|
("pts", ctypes.c_int64),
|
||||||
|
("pkt_dts", ctypes.c_int64),
|
||||||
|
("time_base", AVRational)]
|
||||||
|
# ...
|
||||||
|
|
||||||
AVFrame_p = ctypes.POINTER(AVFrame)
|
AVFrame_p = ctypes.POINTER(AVFrame)
|
||||||
AVFrame_pp = ctypes.POINTER(AVFrame_p)
|
AVFrame_pp = ctypes.POINTER(AVFrame_p)
|
||||||
@ -51,11 +75,6 @@ class AVCodecParameters(ctypes.Structure):
|
|||||||
|
|
||||||
AVCodecParameters_p = ctypes.POINTER(AVCodecParameters)
|
AVCodecParameters_p = ctypes.POINTER(AVCodecParameters)
|
||||||
|
|
||||||
class AVRational(ctypes.Structure):
|
|
||||||
_fields_ = [
|
|
||||||
("num", ctypes.c_int),
|
|
||||||
("den", ctypes.c_int)]
|
|
||||||
|
|
||||||
class AVStream(ctypes.Structure):
|
class AVStream(ctypes.Structure):
|
||||||
_fields_ = [
|
_fields_ = [
|
||||||
("av_class", ctypes.c_void_p),
|
("av_class", ctypes.c_void_p),
|
||||||
|
|||||||
Reference in New Issue
Block a user