You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
采用以下代码进行硬解码,出现了前面4帧左右都是空的问题,一般4帧之后就没有问题了,ffmpeg版本:7.1.0;av版本:13.1.0
video = av.open(VIDEO_FILE_PATH)
#target_stream = video.streams.video[0]
#target_stream = next(s for s in video.streams if s.type == 'video')
target_stream = next((stream for stream in video.streams.video), None)
This discussion was converted from issue #1583 on October 17, 2024 06:07.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
采用以下代码进行硬解码,出现了前面4帧左右都是空的问题,一般4帧之后就没有问题了,ffmpeg版本:7.1.0;av版本:13.1.0
video = av.open(VIDEO_FILE_PATH)
#target_stream = video.streams.video[0]
#target_stream = next(s for s in video.streams if s.type == 'video')
target_stream = next((stream for stream in video.streams.video), None)
获取视频编码格式
codec_name = target_stream.codec_tag
codec = target_stream.codec_context.codec.name
print("encode_format: ", codec_name)
print("encode_format2: ", codec)
decoder = str(target_stream.codec_context).split()[1]
ctx = av.Codec('hevc_cuvid', 'r').create() if 'hevc' in decoder else av.Codec('h264_cuvid', 'r').create()
ctx.extradata = target_stream.extradata
print(ctx)
frame_index = 0
for packet in video.demux(target_stream):
print(packet)
frame = ctx.decode(packet)
print("hard_decode: ",frame)
frame = packet.decode()
print("soft_decode: ",frame)
frame_index += 1
Beta Was this translation helpful? Give feedback.
All reactions