libavcodec - FFMPEG decoding too slow (avcodec_send_packet() / avcodec_receive_frame()) -


i'm using ffmpeg libraries decode, scale, , re-encode video within mpeg transport stream. i've recompiled source v3.3.2 , changed old avcodec_decode_video2() api new send/receive api.

both old , new apis decode video slowly.

25 fps video = 1 frame every 40ms. however, see 70 120ms per frame decode. file translator need run faster real time.

the code outline below. have ideas on how improve decoding speed? there other posts deprecated avcodec_decode_video2() being slow; none of resolved. new api doesn't run faster...

gettimeofday(&tv1, null); int rc = av_read_frame(pformatcontext, pespacket); gettimeofday(&tv2, null);  int ret = avcodec_send_packet(pdecodercontext, pespacket); if (ret < 0)     continue;  ret = avcodec_receive_frame(pdecodercontext, pframedec); if (ret != 0) {     printf("avcodec_receive_frame error: %d\n", ret);     continue; } gettimeofday(&tv3, 0);  u_long twominusone   = (tv2.tv_sec - tv1.tv_sec) * 1000000 + tv2.tv_usec - tv1.tv_usec; u_long threeminustwo = (tv3.tv_sec - tv2.tv_sec) * 1000000 + tv3.tv_usec - tv2.tv_usec;  size_t pktsize = mpacketqueue.gettspktlistsize(); printf("  decode readframe %lu usec, decodevideo %lu usec. mtspacketlist %u items\n", twominusone, threeminustwo, pktsize);  transcodeframe(pframedec);  // scale , re-encode // -- call avscale downsample -- call avcodec_encode_video2() encode 

some output

decode readframe 6 usec, decodevideo 154273 usec. dump mpframeenc datetime:    avframe info frame 720 x 406. pts = 305700353  pkt_pts = 305700353 linesize[0]=720. linesize[1]=360. linesize[2]=360.    time taken encode video frame = 3685 usec. scaling time 4 usec  decode readframe 8 usec, decodevideo 128203 usec. time taken encode video frame = 3724 usec. scaling time 3 usec  decode readframe 8 usec, decodevideo 69321 usec. time taken encode video frame = 3577 usec. scaling time 3 usec 

ffmpeg version

tests running on core2 duo 3.2 ghz, 32-bit centos 6.

bin/ffmpeg ffmpeg version 3.3.2 copyright (c) 2000-2017 ffmpeg developers   built gcc 4.4.7 (gcc) 20120313 (red hat 4.4.7-11)   configuration: --prefix=/mnt/swdevel/dvstor/source_build/ext/ffmpeg-build --libdir=/mnt/swdevel/dvstor/source_build/ext/ffmpeg-build/lib3p_build --shlibdir=/mnt/swdevel/dvstor/source_build/ext/ffmpeg-build/lib3p_build --disable-static --enable-shared --disable-cuda --disable-cuvid --disable-nvenc --enable-libx264 --enable-gpl --extra-cflags=-i/usr/local/include/libx264   libavutil      55. 58.100 / 55. 58.100   libavcodec     57. 89.100 / 57. 89.100   libavformat    57. 71.100 / 57. 71.100   libavdevice    57.  6.100 / 57.  6.100   libavfilter     6. 82.100 /  6. 82.100   libswscale      4.  6.100 /  4.  6.100   libswresample   2.  7.100 /  2.  7.100   libpostproc    54.  5.100 / 54.  5.100 hyper fast audio , video encoder 

best solution found far going avcodec_decode_video2() , buy better hardware...


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -