Hello, I've come across a particular MTS file that doesn't seem to want to be decoded. I've decoded plenty of other MTS, M4V, and MOV files with my code so something seems to be unique to this one. I can play the file just fine too. Any idea what's going on here?
Here's the media info for the bad file: General ID : 0 (0x0) Complete name : D:\Projects\Investigation\00793.MTS Format : BDAV Format/Info : Blu-ray Video File size : 91.9 MiB Duration : 34s 97ms Overall bit rate : 22.6 Mbps Maximum Overall bit rate : 24.0 Mbps Video ID : 4113 (0x1011) Menu ID : 1 (0x1) Format : AVC Format/Info : Advanced Video Codec Format profile : High@L4.0 Format settings, CABAC : No Format settings, ReFrames : 2 frames Format settings, GOP : M=1, N=28 Codec ID : 27 Duration : 33s 984ms Bit rate mode : Variable Bit rate : 21.4 Mbps Maximum bit rate : 22.6 Mbps Width : 1 920 pixels Height : 1 080 pixels Display aspect ratio : 16:9 Frame rate : 29.970 fps Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Interlaced Scan order : Top Field First Bits/(Pixel*Frame) : 0.345 Stream size : 86.8 MiB (94%) Audio ID : 4352 (0x1100) Menu ID : 1 (0x1) Format : AC-3 Format/Info : Audio Coding 3 Mode extension : CM (complete main) Codec ID : 129 Duration : 34s 16ms Bit rate mode : Constant Bit rate : 256 Kbps Channel(s) : 2 channels Channel positions : Front: L R Sampling rate : 48.0 KHz Bit depth : 16 bits Compression mode : Lossy Delay relative to video : -34ms Stream size : 1.04 MiB (1%) Text ID : 4608 (0x1200) Menu ID : 1 (0x1) Format : PGS Codec ID : 144 Duration : 33s 602ms Delay relative to video : -34ms Here's a somewhat simplified version of my code. I use av_open_input_file, av_find_stream_info, avcodec_find_decoder, and avcodec_open in my helper functions. // Allocate video frame pFrame=avcodec_alloc_frame(); // Allocate an AVFrame structure pFrameYUV=avcodec_alloc_frame(); if(pFrameYUV==NULL) { return NULL; } // Determine required buffer size and allocate buffer numBytes=avpicture_get_size(PIX_FMT_YUV420P, width, height); buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t)); // Assign appropriate parts of buffer to image planes in pFrameYUV avpicture_fill((AVPicture *)pFrameYUV, buffer, PIX_FMT_YUV420P, width, height); AVFormatContext* pFormatCtx; pFormatCtx = pHelper->FormatContextPointer(); int videoStreamIndex = pHelper->VideoStreamIndex(); int frameScanCount = 0; AVCodecContext* pCodecCtx; pCodecCtx = pHelper->CodecContextPointer(); while (av_read_frame(pFormatCtx, &packet) >= 0) { // Is this a packet from the video stream? if (packet.stream_index == videoStreamIndex && frameLocation++) { // Decode video frame avcodec_decode_video2(pCodecCtx, pFrameYUV, &isFrameFinished, &packet); *// FOR THIS VIDEO, **isFrameFinished **IS ALWAYS 0* if (isFrameFinished == 0) { pLog->Write("Frame %d not finished", frameLocation); } // Did we get a video frame? if (isFrameFinished) { // do some analysis on the pixels } // whether we successfully decoded the frame } // whether we were supposed to decode the frame av_free_packet(&packet); } // for each available frame //delete [] buffer; av_free(buffer); av_free(pFrame); // Free the YUV frame av_free(pFrameYUV); Thanks! Simon
_______________________________________________ Libav-user mailing list Libav-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/libav-user