more debugging. its finding VP9 and replacing it with VP8 and so it can't read it.
frankly confused about libvpx.
This code will work on other codecs and only replaces VP9 (167) where it fails
@@ -219,7 +219,7 @@ def ffmpeg_stream_info(file, stream_index):
av_stream = file.context.contents.streams[stream_index].contents
context = av_stream.codecpar.contents
if context.codec_type == AVMEDIA_TYPE_VIDEO:
- if _debug:
+ if True:#_debug:
print ("codec_type=",context.codec_type)
print (" codec_id=",context.codec_id)
codec_name = avcodec.avcodec_get_name(context.codec_id).decode('utf-8')
@@ -296,12 +296,16 @@ def ffmpeg_open_stream(file, index):
if result < 0:
avcodec.avcodec_free_context(byref(codec_context))
raise FFmpegException('Could not copy the AVCodecContext.')
- codec = avcodec.avcodec_find_decoder(codec_context.contents.codec_id)
+ codec_id = codec_context.contents.codec_id
+ codec = avcodec.avcodec_find_decoder(codec_id)
+ print("!Found Codec=",codec_id,"=",codec.contents.long_name.decode())
+ if codec_id == 167: #Google VP9
codec = avcodec.avcodec_find_decoder_by_name("libvpx".encode('utf-8'))
- codec_context.contents.codec_id = codec.contents.id
+ codec_id = codec.contents.id
+ print("!Replaced with Codec=",codec_id,"=", codec.contents.long_name.decode())
if not codec:
raise FFmpegException('No codec found for this media. '
- 'codecID={}'.format(codec_context.contents.codec_id))
+ 'codecID={}'.format(codec_id))
if _debug:
print("Loaded codec: ", codec.contents.long_name.decode())
