[Libav-user] Cross-compiling under MIPS: av_read_frame return wrong PTS

Pavel Sokolov pavel at sokolov.me
Fri Jan 27 17:11:24 CET 2012


Hi all!

I have problem with wrong PTS when compiling ffmpeg under MIPS Little 
Endian: av_read_frame return wrong PTS, but on the PC all works fine.

============================
  Configure options for MIPS:
  --disable-network --disable-everything 
--enable-demuxer=mpegts,mpeg2vob,mpegvideo,mpegps,asf,avi,flv,matroska,h263,h264,mov 
--enable-muxer=mpegts,mpeg2dvd --enable-protocol=file --disable-doc 
--disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver 
--disable-avdevice --disable-swresample --disable-swscale 
--disable-postproc --disable-avfilter --enable-cross-compile 
--prefix=/home/pavel/projects/tvip_s213/chipset/toolchain/current 
--sysinclude=/home/pavel/projects/tvip_s213/chipset/toolchain/current/include 
--target-os=linux --cross-prefix=mipsel-linux- --arch=mips

====================================================================================
test code:
====================================================================================
#include <stdio.h>
#include <string>

extern "C" {
   #include "libavformat/avformat.h"
   #include "libavcodec/avcodec.h"
   #include <libavutil/dict.h>
}

#define PRINT_LIB_INFO(libname, LIBNAME){                                \
             unsigned int version = libname##_version();                 \
             printf("%slib%-9s %2d.%3d.%2d / %2d.%3d.%2d\n",\
                    " ", #libname,                                    \
                    LIB##LIBNAME##_VERSION_MAJOR,                        \
                    LIB##LIBNAME##_VERSION_MINOR,                        \
                    LIB##LIBNAME##_VERSION_MICRO,                        \
                    version >> 16, version >> 8 & 0xff, version & 0xff); \
                    }

int main(int argc, char **argv) {

   PRINT_LIB_INFO(avutil,   AVUTIL);
   PRINT_LIB_INFO(avcodec,  AVCODEC);
   PRINT_LIB_INFO(avformat, AVFORMAT);
   //PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level);
   //PRINT_LIB_INFO(avfilter, AVFILTER, flags, level);
   //PRINT_LIB_INFO(swscale,  SWSCALE,  flags, level);
   //PRINT_LIB_INFO(postproc, POSTPROC, flags, level);


   AVFormatContext* inputFormat=NULL;

   if (argc != 2){
     printf("Usage: test-ffmpeg2 [file]\n");
     return 1;
   }

   std::string inputFileName=argv[1];

   av_register_all();
   avformat_network_init();


   if (0 != avformat_open_input(&inputFormat, inputFileName.c_str(), 
NULL, NULL)){
     printf("Can't open input");
     return 1;
   }

   printf("===== INPUT FORMAT =====\n");
   av_dump_format(inputFormat, 0, "", 0);
   printf("========================\n");

   AVPacket pkt;

   for (int i=0; i<20;){
     int res=av_read_frame(inputFormat, &pkt);
     if (res == AVERROR(EAGAIN)){
      continue;
     } else if (res < 0){
       printf("av_read_frame error\n");
       break;
     } else {
       AVStream* input_stream = inputFormat->streams[pkt.stream_index];
       if (input_stream->codec->codec_type == AVMEDIA_TYPE_VIDEO){
         i++;
         if(pkt.pts == AV_NOPTS_VALUE){
           printf("frame i:%4d orig pts: no pts\n",i);
         } else {
           printf("frame i:%4d orig pts: %lld\n",i,pkt.pts);
         }
       }
       av_free_packet(&pkt);
     }
   }
   avformat_close_input(&inputFormat);
   return 0;
}

====================================================================================
****** MIPS output:
====================================================================================
  libavutil    51. 32. 0 / 51. 32. 0
  libavcodec   53. 42. 4 / 53. 42. 4
  libavformat  53. 24. 2 / 53. 24. 2
===== INPUT FORMAT =====
Input #0, avi, from '':
   Metadata:
     encoder         : Nandub v1.0rc2
   Duration: N/A, bitrate: N/A
     Stream #0:0: Video: mpeg4 (XVID / 0x44495658), 624x352, 25 tbn
     Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, 2 
channels, 123 kb/s
========================
frame i:   1 orig pts: 0
frame i:   2 orig pts: 1
frame i:   3 orig pts: 2
frame i:   4 orig pts: 3
frame i:   5 orig pts: 4
frame i:   6 orig pts: 5
frame i:   7 orig pts: 6
frame i:   8 orig pts: 7
frame i:   9 orig pts: 8
frame i:  10 orig pts: 9
frame i:  11 orig pts: 10
frame i:  12 orig pts: 11
frame i:  13 orig pts: 12
frame i:  14 orig pts: 13
frame i:  15 orig pts: 14
frame i:  16 orig pts: 15
frame i:  17 orig pts: 16
frame i:  18 orig pts: 17
frame i:  19 orig pts: 18
frame i:  20 orig pts: 19

====================================================================================
****** PC output:
====================================================================================
  libavutil    51. 32. 0 / 51. 32. 0
  libavcodec   53. 42. 4 / 53. 42. 4
  libavformat  53. 24. 2 / 53. 24. 2
===== INPUT FORMAT =====
Input #0, avi, from '':
   Metadata:
     encoder         : Nandub v1.0rc2
   Duration: N/A, bitrate: N/A
     Stream #0:0: Video: mpeg4 (XVID / 0x44495658), 624x352, 25 tbn
     Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, 2 
channels, 123 kb/s
========================
frame i:   1 orig pts: no pts
frame i:   2 orig pts: no pts
frame i:   3 orig pts: 2
frame i:   4 orig pts: 3
frame i:   5 orig pts: no pts
frame i:   6 orig pts: 5
frame i:   7 orig pts: 6
frame i:   8 orig pts: no pts
frame i:   9 orig pts: 8
frame i:  10 orig pts: 9
frame i:  11 orig pts: no pts
frame i:  12 orig pts: 11
frame i:  13 orig pts: 12
frame i:  14 orig pts: no pts
frame i:  15 orig pts: 14
frame i:  16 orig pts: 15
frame i:  17 orig pts: no pts
frame i:  18 orig pts: 17
frame i:  19 orig pts: 18
frame i:  20 orig pts: no pts


-- 

With best regards, Pavel A. Sokolov
mobile: +7(921)419-1819
skype: pavel_a_sokolov



More information about the Libav-user mailing list