Hello,<br><br>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?<br>
<br>Here's the media info for the bad file:<br><span style="font-family:courier new,monospace">General</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">ID                               : 0 (0x0)</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Complete name                    : D:\Projects\Investigation\00793.MTS</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Format                           : BDAV</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Format/Info                      : Blu-ray Video</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">File size                        : 91.9 MiB</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Duration                         : 34s 97ms</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Overall bit rate                 : 22.6 Mbps</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Maximum Overall bit rate         : 24.0 Mbps</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Video</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">ID                               : 4113 (0x1011)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Menu ID                          : 1 (0x1)</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Format                           : AVC</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Format/Info                      : Advanced Video Codec</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Format profile                   : High@L4.0</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Format settings, CABAC           : No</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Format settings, ReFrames        : 2 frames</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Format settings, GOP             : M=1, N=28</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Codec ID                         : 27</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Duration                         : 33s 984ms</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Bit rate mode                    : Variable</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Bit rate                         : 21.4 Mbps</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Maximum bit rate                 : 22.6 Mbps</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Width                            : 1 920 pixels</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Height                           : 1 080 pixels</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Display aspect ratio             : 16:9</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Frame rate                       : 29.970 fps</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Color space                      : YUV</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Chroma subsampling               : 4:2:0</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Bit depth                        : 8 bits</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Scan type                        : Interlaced</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Scan order                       : Top Field First</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Bits/(Pixel*Frame)               : 0.345</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Stream size                      : 86.8 MiB (94%)</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Audio</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">ID                               : 4352 (0x1100)</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Menu ID                          : 1 (0x1)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Format                           : AC-3</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Format/Info                      : Audio Coding 3</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Mode extension                   : CM (complete main)</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Codec ID                         : 129</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Duration                         : 34s 16ms</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Bit rate mode                    : Constant</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Bit rate                         : 256 Kbps</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Channel(s)                       : 2 channels</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Channel positions                : Front: L R</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Sampling rate                    : 48.0 KHz</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Bit depth                        : 16 bits</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Compression mode                 : Lossy</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Delay relative to video          : -34ms</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Stream size                      : 1.04 MiB (1%)</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Text</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">ID                               : 4608 (0x1200)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Menu ID                          : 1 (0x1)</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Format                           : PGS</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Codec ID                         : 144</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">Duration                         : 33s 602ms</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Delay relative to video          : -34ms</span><br>
<br><br><br>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.<br><br><br><span style="font-family:courier new,monospace">    // Allocate video frame<br>
    pFrame=avcodec_alloc_frame();<br><br>    // Allocate an AVFrame structure<br>    pFrameYUV=avcodec_alloc_frame();<br>    if(pFrameYUV==NULL)<br>    {<br>        return NULL;<br>    }<br>    <br>    // Determine required buffer size and allocate buffer<br>
    numBytes=avpicture_get_size(PIX_FMT_YUV420P, width, height);<br>    buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));<br>    <br>    // Assign appropriate parts of buffer to image planes in pFrameYUV<br>    avpicture_fill((AVPicture *)pFrameYUV, buffer, PIX_FMT_YUV420P, width, height);<br>
    <br>    AVFormatContext* pFormatCtx;<br>    pFormatCtx = pHelper->FormatContextPointer();<br><br>    int videoStreamIndex = pHelper->VideoStreamIndex();<br>    int frameScanCount = 0;<br><br>    AVCodecContext* pCodecCtx;<br>
    pCodecCtx = pHelper->CodecContextPointer();<br><br>    while (av_read_frame(pFormatCtx, &packet) >= 0)<br>    {<br><br>        <br>        // Is this a packet from the video stream?<br>        if (packet.stream_index == videoStreamIndex &&<br>
            frameLocation++)<br>        {<br>                        <br>            // Decode video frame<br>            avcodec_decode_video2(pCodecCtx, pFrameYUV, &isFrameFinished, &packet);<br><br>            <b>// FOR THIS VIDEO, </b></span><b><span style="font-family:courier new,monospace">isFrameFinished </span></b><span style="font-family:courier new,monospace"><b>IS ALWAYS 0</b><br>
            if (isFrameFinished == 0)<br>            {<br>                pLog->Write("Frame %d not finished", frameLocation);<br>            }<br><br>            // Did we get a video frame?<br>            if (isFrameFinished) {<br>
<br>                // do some analysis on the pixels<br><br>            } // whether we successfully decoded the frame<br><br><br>        } // whether we were supposed to decode the frame<br>        <br>        av_free_packet(&packet);<br>
<br>    } // for each available frame<br><br>    //delete [] buffer;<br>    av_free(buffer);<br>    av_free(pFrame);<br><br>    // Free the YUV frame<br>    av_free(pFrameYUV);<br><br><br style="font-family:arial,helvetica,sans-serif">
<span style="font-family:arial,helvetica,sans-serif">Thanks!</span><br style="font-family:arial,helvetica,sans-serif"><br style="font-family:arial,helvetica,sans-serif"><span style="font-family:arial,helvetica,sans-serif">Simon</span><br>
</span><span style="font-family:courier new,monospace"></span>