Note that there are some explanatory texts on larger screens.

plurals
  1. POavcodec_find_decoder for FFMpeg 2.1 is not working with Android
    primarykey
    data
    text
    <p>I ported FFMpeg 2.1 to Android with NDK and I wrote a JNI function to initialize a video.</p> <p>Here is the code of this C function :</p> <pre><code>JNIEXPORT int JNICALL Java_com_media_ffmpeg_FFMpeg_naInit(JNIEnv *pEnv, jobject pObj, jstring pfilename) { gVideoFileName = (char *) (*pEnv)-&gt;GetStringUTFChars(pEnv, pfilename, NULL); __android_log_print(ANDROID_LOG_INFO, TAG, "Init %s\n", gVideoFileName); avcodec_register_all(); __android_log_print(ANDROID_LOG_INFO, TAG, "avcodec_register_all\n"); av_register_all(); __android_log_print(ANDROID_LOG_INFO, TAG, "av_register_all\n"); VideoState *vs; __android_log_print(ANDROID_LOG_INFO, TAG, "VideoState var\n"); vs = malloc(sizeof (VideoState)); memset(vs, 0, sizeof(VideoState)); __android_log_print(ANDROID_LOG_INFO, TAG, "malloc\n"); gvs = vs; __android_log_print(ANDROID_LOG_INFO, TAG, "VideoState\n"); //open the video file avformat_open_input(&amp;vs-&gt;pFormatCtx, gVideoFileName, NULL, NULL); __android_log_print(ANDROID_LOG_INFO, TAG, "open_input\n"); //retrieve stream info avformat_find_stream_info(vs-&gt;pFormatCtx, NULL); __android_log_print(ANDROID_LOG_INFO, TAG, "find_stream_info\n"); //find the video stream AVCodecContext *pcodecctx; //find the first video stream vs-&gt;videoStreamIdx = -1; __android_log_print(ANDROID_LOG_INFO, TAG, "before loop\n"); AVCodec *pcodec; vs-&gt;videoStreamIdx = av_find_best_stream(vs-&gt;pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, &amp;pcodec, 0); __android_log_print(ANDROID_LOG_INFO, TAG, "after loop. %d\n", vs-&gt;videoStreamIdx); //get the decoder from the video stream pcodecctx = vs-&gt;pFormatCtx-&gt;streams[vs-&gt;videoStreamIdx]-&gt;codec; __android_log_print(ANDROID_LOG_INFO, TAG, "stream selected %d, %d\n", pcodecctx != NULL ? 1 : 0, pcodecctx-&gt;codec_id); pcodec = avcodec_find_decoder(pcodecctx-&gt;codec_id); __android_log_print(ANDROID_LOG_INFO, TAG, "find_decoder\n"); //open the codec avcodec_open2(pcodecctx, pcodec, NULL); __android_log_print(ANDROID_LOG_INFO, TAG, "open2\n"); return 0; } </code></pre> <p>When I execute this function from my Java code the log <code>find_decoder</code> (after the call to the function <code>avcodec_find_decoder</code>) is never displayed.</p> <p>Everything is correct : pointers have correct values and <code>pcodecctx-&gt;codec_id</code> has a value equal to <strong>28</strong>. But when <code>avcodec_find_decoder</code> there is nothing more, like a crash and I have no more log.</p> <p>Did I do something wrong when using and initializing FFMpeg ?</p> <p>PS : before that instead of a call to <code>malloc</code>, then <code>memset</code> I had a call to <code>av_mallocz</code> but I also had a crash at this point, and replacing this call by <code>malloc</code> and <code>memset</code> fixed the crash.</p> <p><strong>EDIT</strong></p> <p>I built <code>FFMpeg</code> using this script :</p> <pre><code>#!/bin/bash NDK=/Users/me/android-ndk SYSROOT=$NDK/platforms/android-8/arch-arm/ TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64 function build_one { ./configure \ --prefix=$PREFIX \ --disable-shared \ --enable-static \ --disable-doc \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ --disable-ffserver \ --disable-avdevice \ --disable-doc \ --disable-symver \ --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \ --target-os=linux \ --arch=arm \ --enable-cross-compile \ --sysroot=$SYSROOT \ --extra-cflags="-Os -fpic $ADDI_CFLAGS" \ --extra-ldflags="$ADDI_LDFLAGS" \ $ADDITIONAL_CONFIGURE_FLAG make clean make make install } CPU=arm PREFIX=$(pwd)/android/$CPU ADDI_CFLAGS="-marm" build_one </code></pre> <p><strong>EDIT 2</strong></p> <p>Here is the output for the configuration of the build of the library</p> <pre><code>Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 install prefix /Users/fabienhenon/android-ndk/sources/ffmpeg/android/arm source path . C compiler /Users/fabienhenon/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc C library bionic host C compiler gcc host C library ARCH arm (armv5te) big-endian no runtime cpu detection yes ARMv5TE enabled yes ARMv6 enabled yes ARMv6T2 enabled yes VFP enabled yes NEON enabled yes THUMB enabled no debug symbols yes strip symbols yes optimize for size no optimizations yes static yes shared no postprocessing support no new filter support yes network support yes threading support pthreads safe bitstream reader yes SDL support no opencl enabled no libzvbi enabled no texi2html enabled no perl enabled yes pod2man enabled yes makeinfo enabled yes External libraries: zlib Enabled decoders: aac bmp iac aac_latm bmv_audio idcin aasc bmv_video idf ac3 brender_pix iff_byterun1 adpcm_4xm c93 iff_ilbm adpcm_adx cavs imc adpcm_afc cdgraphics indeo2 adpcm_ct cdxl indeo3 adpcm_dtk cinepak indeo4 adpcm_ea cljr indeo5 adpcm_ea_maxis_xa cllc interplay_dpcm adpcm_ea_r1 comfortnoise interplay_video adpcm_ea_r2 cook jacosub adpcm_ea_r3 cpia jpeg2000 adpcm_ea_xas cscd jpegls adpcm_g722 cyuv jv adpcm_g726 dca kgv1 adpcm_g726le dfa kmvc adpcm_ima_amv dirac lagarith adpcm_ima_apc dnxhd loco adpcm_ima_dk3 dpx mace3 adpcm_ima_dk4 dsicinaudio mace6 adpcm_ima_ea_eacs dsicinvideo mdec adpcm_ima_ea_sead dvbsub metasound adpcm_ima_iss dvdsub microdvd adpcm_ima_oki dvvideo mimic adpcm_ima_qt dxa mjpeg adpcm_ima_rad dxtory mjpegb adpcm_ima_smjpeg eac3 mlp adpcm_ima_wav eacmv mmvideo adpcm_ima_ws eamad motionpixels adpcm_ms eatgq movtext adpcm_sbpro_2 eatgv mp1 adpcm_sbpro_3 eatqi mp1float adpcm_sbpro_4 eightbps mp2 adpcm_swf eightsvx_exp mp2float adpcm_thp eightsvx_fib mp3 adpcm_xa escape124 mp3adu adpcm_yamaha escape130 mp3adufloat aic evrc mp3float alac exr mp3on4 als ffv1 mp3on4float amrnb ffvhuff mpc7 amrwb ffwavesynth mpc8 amv flac mpeg1video anm flashsv mpeg2video ansi flashsv2 mpeg4 ape flic mpegvideo ass flv mpl2 asv1 fourxm msa1 asv2 fraps msmpeg4v1 atrac1 frwu msmpeg4v2 atrac3 g2m msmpeg4v3 aura g723_1 msrle aura2 g729 mss1 avrn gif mss2 avrp gsm msvideo1 avs gsm_ms mszh avui h261 mts2 ayuv h263 mvc1 bethsoftvid h263i mvc2 bfi h263p mxpeg bink h264 nellymoser binkaudio_dct hevc nuv binkaudio_rdft hnm4_video paf_audio bintext huffyuv paf_video pam realtext v308 pbm rl2 v408 pcm_alaw roq v410 pcm_bluray roq_dpcm vb pcm_dvd rpza vble pcm_f32be rv10 vc1 pcm_f32le rv20 vc1image pcm_f64be rv30 vcr1 pcm_f64le rv40 vima pcm_lxf s302m vmdaudio pcm_mulaw sami vmdvideo pcm_s16be sanm vmnc pcm_s16be_planar sgi vorbis pcm_s16le sgirle vp3 pcm_s16le_planar shorten vp5 pcm_s24be sipr vp6 pcm_s24daud smackaud vp6a pcm_s24le smacker vp6f pcm_s24le_planar smc vp8 pcm_s32be smvjpeg vp9 pcm_s32le snow vplayer pcm_s32le_planar sol_dpcm vqa pcm_s8 sonic wavpack pcm_s8_planar sp5x webp pcm_u16be srt webvtt pcm_u16le ssa wmalossless pcm_u24be subrip wmapro pcm_u24le subviewer wmav1 pcm_u32be subviewer1 wmav2 pcm_u32le sunrast wmavoice pcm_u8 svq1 wmv1 pcm_zork svq3 wmv2 pcx tak wmv3 pgm targa wmv3image pgmyuv targa_y216 wnv1 pgssub text ws_snd1 pictor theora xan_dpcm pjs thp xan_wc3 png tiertexseqvideo xan_wc4 ppm tiff xbin prores tmv xbm prores_lgpl truehd xface ptx truemotion1 xl qcelp truemotion2 xsub qdm2 truespeech xwd qdraw tscc y41p qpeg tscc2 yop qtrle tta yuv4 r10k twinvq zero12v r210 txd zerocodec ra_144 ulti zlib ra_288 utvideo zmbv ralf v210 rawvideo v210x Enabled encoders: a64multi ljpeg prores a64multi5 mjpeg prores_aw aac movtext prores_ks ac3 mp2 qtrle ac3_fixed mp2fixed r10k adpcm_adx mpeg1video r210 adpcm_g722 mpeg2video ra_144 adpcm_g726 mpeg4 rawvideo adpcm_ima_qt msmpeg4v2 roq adpcm_ima_wav msmpeg4v3 roq_dpcm adpcm_ms msvideo1 rv10 adpcm_swf nellymoser rv20 adpcm_yamaha pam s302m alac pbm sgi amv pcm_alaw snow ass pcm_f32be sonic asv1 pcm_f32le sonic_ls asv2 pcm_f64be srt avrp pcm_f64le ssa avui pcm_mulaw subrip ayuv pcm_s16be sunrast bmp pcm_s16be_planar svq1 cljr pcm_s16le targa comfortnoise pcm_s16le_planar tiff dca pcm_s24be tta dnxhd pcm_s24daud utvideo dpx pcm_s24le v210 dvbsub pcm_s24le_planar v308 dvdsub pcm_s32be v408 dvvideo pcm_s32le v410 eac3 pcm_s32le_planar vorbis ffv1 pcm_s8 wavpack ffvhuff pcm_s8_planar wmav1 flac pcm_u16be wmav2 flashsv pcm_u16le wmv1 flashsv2 pcm_u24be wmv2 flv pcm_u24le xbm g723_1 pcm_u32be xface gif pcm_u32le xsub h261 pcm_u8 xwd h263 pcx y41p h263p pgm yuv4 huffyuv pgmyuv zlib jpeg2000 png zmbv jpegls ppm Enabled hwaccels: Enabled parsers: aac dvd_nav mpegvideo aac_latm dvdsub png ac3 flac pnm adx gsm rv30 bmp h261 rv40 cavsvideo h263 tak cook h264 vc1 dca hevc vorbis dirac mjpeg vp3 dnxhd mlp vp8 dpx mpeg4video vp9 dvbsub mpegaudio Enabled demuxers: aac hevc pcm_s32le ac3 hls pcm_s8 act hnm pcm_u16be adf ico pcm_u16le adp idcin pcm_u24be adx idf pcm_u24le aea iff pcm_u32be afc ilbc pcm_u32le aiff image2 pcm_u8 amr image2pipe pjs anm ingenient pmp apc ipmovie pva ape ircam pvf aqtitle iss qcp asf iv8 r3d ass ivf rawvideo ast jacosub realtext au jv redspark avi latm rl2 avr lmlm4 rm avs loas roq bethsoftvid lvf rpl bfi lxf rsd bink m4v rso bintext matroska rtp bit mgsts rtsp bmv microdvd sami boa mjpeg sap brstm mlp sbg c93 mm sdp caf mmf segafilm cavsvideo mov shorten cdg mp3 siff cdxl mpc smacker concat mpc8 smjpeg data mpegps smush daud mpegts sol dfa mpegtsraw sox dirac mpegvideo spdif dnxhd mpl2 srt dsicin mpsub str dts msnwc_tcp subviewer dtshd mtv subviewer1 dv mv swf dxa mvi tak ea mxf tedcaptions ea_cdata mxg thp eac3 nc tiertexseq epaf nistsphere tmv ffm nsv truehd ffmetadata nut tta filmstrip nuv tty flac ogg txd flic oma vc1 flv paf vc1t fourxm pcm_alaw vivo frm pcm_f32be vmd g722 pcm_f32le vobsub g723_1 pcm_f64be voc g729 pcm_f64le vplayer gif pcm_mulaw vqf gsm pcm_s16be w64 gxf pcm_s16le wav h261 pcm_s24be wc3 h263 pcm_s24le webvtt h264 pcm_s32be wsaud wsvqa xa xwma wtv xbin yop wv xmv yuv4mpegpipe Enabled muxers: a64 image2pipe pcm_s24be ac3 ipod pcm_s24le adts ircam pcm_s32be adx ismv pcm_s32le aiff ivf pcm_s8 amr jacosub pcm_u16be asf latm pcm_u16le asf_stream m4v pcm_u24be ass matroska pcm_u24le ast matroska_audio pcm_u32be au md5 pcm_u32le avi microdvd pcm_u8 avm2 mjpeg psp bit mkvtimestamp_v2 rawvideo caf mlp rm cavsvideo mmf roq crc mov rso data mp2 rtp daud mp3 rtsp dirac mp4 sap dnxhd mpeg1system segment dts mpeg1vcd smjpeg dv mpeg1video smoothstreaming eac3 mpeg2dvd sox f4v mpeg2svcd spdif ffm mpeg2video speex ffmetadata mpeg2vob srt filmstrip mpegts stream_segment flac mpjpeg swf flv mxf tee framecrc mxf_d10 tg2 framemd5 null tgp g722 nut truehd g723_1 ogg vc1 gif oma vc1t gxf opus voc h261 pcm_alaw w64 h263 pcm_f32be wav h264 pcm_f32le webm hds pcm_f64be webvtt hls pcm_f64le wtv ico pcm_mulaw wv ilbc pcm_s16be yuv4mpegpipe image2 pcm_s16le Enabled protocols: cache hls rtmpt concat http rtp crypto httpproxy srtp data md5 tcp ffrtmphttp mmsh udp file mmst unix ftp pipe gopher rtmp Enabled filters: aconvert colorchannelmixer null adelay compand nullsink aecho concat nullsrc aeval copy overlay aevalsrc crop pad afade curves pan aformat dctdnoiz perms ainterleave decimate pixdesctest allpass deshake psnr alphaextract drawbox removelogo alphamerge drawgrid replaygain amerge earwax rgbtestsrc amix edgedetect rotate amovie elbg scale anull equalizer select anullsink extractplanes sendcmd anullsrc fade separatefields apad field setdar aperms fieldmatch setfield aphaser fieldorder setpts aresample format setsar aselect fps settb asendcmd framestep showinfo asetnsamples gradfun showspectrum asetpts haldclut showwaves asetrate haldclutsrc silencedetect asettb hflip sine ashowinfo highpass smptebars asplit histogram smptehdbars astats hue split astreamsync idet swapuv atempo il telecine atrim interleave testsrc avectorscope join thumbnail bandpass life tile bandreject lowpass transpose bass lut treble bbox lut3d trim biquad lutrgb unsharp blackdetect lutyuv vflip blend mandelbrot vignette cellauto mergeplanes volume channelmap movie volumedetect channelsplit negate w3fdif color noformat colorbalance noise Enabled bsfs: aac_adtstoasc imx_dump_header mp3_header_decompress chomp mjpeg2jpeg noise dump_extradata mjpega_dump_header remove_extradata h264_mp4toannexb mov2textsub text2movsub Enabled indevs: dv1394 lavfi fbdev v4l2 Enabled outdevs: fbdev v4l2 License: LGPL version 2.1 or later </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload