CERCA
PER MODELLO
FullScreen Chatbox! :)

Utente del giorno: 9mm con ben 2 Thanks ricevuti nelle ultime 24 ore
Utente della settimana: 9mm con ben 7 Thanks ricevuti negli ultimi sette giorni
Utente del mese: 9mm con ben 31 Thanks ricevuti nell'ultimo mese

Visualizzazione dei risultati da 1 a 1 su 1
Discussione:

Problema utilizzo mediacodec

Se questa discussione ti è stata utile, ti preghiamo di lasciare un messaggio di feedback in modo che possa essere preziosa in futuro anche per altri utenti come te!
  1. #1
    Baby Droid


    Registrato dal
    Jun 2013
    Messaggi
    5
    Smartphone
    Samsung Galaxy S advance

    Ringraziamenti
    0
    Ringraziato 0 volte in 0 Posts
    Predefinito

    Problema utilizzo mediacodec

    Ciao a tutti ragazzi, io avrei un problema con questa libreria

    https://github.com/fyhertz/libstreaming

    in pratica permette via wireless di mandare lo streaming della visione delle photocamera, come da descrizione permette di utilizzare 3 metodologie 2 che utilizzano i mediacodec e 1 che utilizza il mediarecorder.
    Io vorrei modificarla e per forza di cose devo utilizzare i mediacodec, ma con tutti i dispositivi con cui l'ho provata ho sempre lo stesso errore:
    mi dice che il dispositivo può utilizzare i mediacodec, imposta l'encoder e si pianta quando testa il decoder, in quanto il buffer è pieno di -1.

    Questo è il metodo dove avviene l'eccezione, qualche anima pia riesce ad aiutarmi?

    private long decode(boolean withPrefix) {
    int n = 0, i = 0, j = 0;
    long elapsed = 0, now = timestamp();
    int decInputIndex = 0, decOutputIndex = 0;
    ByteBuffer[] decInputBuffers = mDecoder.getInputBuffers();
    ByteBuffer[] decOutputBuffers = mDecoder.getOutputBuffers();
    BufferInfo info = new BufferInfo();

    while (elapsed<3000000) {

    // Feeds the decoder with a NAL unit
    if (i<NB_ENCODED) {
    if (VERBOSE) Log.e(TAG,"Feeds the decoder with a NAL unit");

    decInputIndex = mDecoder.dequeueInputBuffer(1000000/FRAMERATE);
    if (decInputIndex>=0) {
    if (VERBOSE) Log.e(TAG,"FEEDS 1 if");
    int l1 = decInputBuffers[decInputIndex].capacity();
    int l2 = mVideo[i].length;
    decInputBuffers[decInputIndex].clear();

    if ((withPrefix && hasPrefix(mVideo[i])) || (!withPrefix && !hasPrefix(mVideo[i]))) {
    if (VERBOSE) Log.e(TAG,"FEEDS 2 if");
    check(l1>=l2, "The decoder input buffer is not big enough (nal="+l2+", capacity="+l1+").");
    decInputBuffers[decInputIndex].put(mVideo[i],0,mVideo[i].length);
    } else if (withPrefix && !hasPrefix(mVideo[i])) {
    if (VERBOSE) Log.e(TAG,"FEEDS 3 if");
    check(l1>=l2+4, "The decoder input buffer is not big enough (nal="+(l2+4)+", capacity="+l1+").");
    decInputBuffers[decInputIndex].put(new byte[] {0,0,0,1});
    decInputBuffers[decInputIndex].put(mVideo[i],0,mVideo[i].length);
    } else if (!withPrefix && hasPrefix(mVideo[i])) {
    if (VERBOSE) Log.e(TAG,"FEEDS 4 if");
    check(l1>=l2-4, "The decoder input buffer is not big enough (nal="+(l2-4)+", capacity="+l1+").");
    decInputBuffers[decInputIndex].put(mVideo[i],4,mVideo[i].length-4);
    }

    mDecoder.queueInputBuffer(decInputIndex, 0, l2, timestamp(), 0);
    i++;
    } else {
    if (VERBOSE) Log.d(TAG,"No buffer available !");
    }
    }

    // Tries to get a decoded image
    if (VERBOSE) Log.e(TAG,"Tries to get a decoded image 1000000/FRAMERATE = "+(1000000/FRAMERATE));

    decOutputIndex = mDecoder.dequeueOutputBuffer(info, 1000000/FRAMERATE);
    if (VERBOSE) Log.e(TAG,"DECODE decOutputIndex = "+decOutputIndex);
    if (decOutputIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
    if (VERBOSE) Log.e(TAG,"DECODE 1 if");
    decOutputBuffers = mDecoder.getOutputBuffers();
    } else if (decOutputIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
    if (VERBOSE) Log.e(TAG,"DECODE 2 if");
    mDecOutputFormat = mDecoder.getOutputFormat();
    } else if (decOutputIndex>=0) {
    if (VERBOSE) Log.e(TAG,"DECODE 3 if");
    if (n>2) {
    if (VERBOSE) Log.e(TAG,"DECODE 4 if");
    // We have successfully encoded and decoded an image !
    int length = info.size;
    mDecodedVideo[j] = new byte[length];
    decOutputBuffers[decOutputIndex].clear();
    decOutputBuffers[decOutputIndex].get(mDecodedVideo[j], 0, length);
    // Converts the decoded frame to NV21
    convertToNV21(j);
    if (j>=NB_DECODED-1) {
    if (VERBOSE) Log.e(TAG,"DECODE 5 if");
    flushMediaCodec(mDecoder);
    if (VERBOSE) Log.v(TAG, "Decoding "+n+" frames took "+elapsed/1000+" ms");
    return elapsed;
    }
    j++;
    }
    mDecoder.releaseOutputBuffer(decOutputIndex, false);
    n++;
    }
    elapsed = timestamp() - now;
    }

    throw new RuntimeException("The decoder did not decode anything.");

    }

  2.  

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire risposte
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Torna su
Privacy Policy