Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • Decoding a TCP stream using ffmpeg

    22 août 2011, par JConway

    I am using the Ffmpeg library in an Android application I am writing. I have written the code to open up a local file and decode that using avformat_open_input(). However I need to use Ffmpeg to read in a video stream over TCP. I have found a few things within Ffmpeg such as libavcodec/tcp.h but I can't establish how to actually open up a TCP stream into the decoder.

    Any suggestions would be really appreciated.

  • play audio (stream) with ffmpeg on iphone

    22 août 2011, par The Psicopath

    i compiled FFMpeg and i have put them in the xcode project, i don't found in the net any tutorial for stream a wma file with this lib, someone have any tutorial links? (or can make me any example?) thanks!

  • FFMPEG with QT memory leak

    22 août 2011, par Timothy Baldridge

    Let me start with a code clip:

    QByteArray ba;
    ba.resize(500000);
    
    int encsize = avcodec_encode_video(context, (uint8_t*)ba.data(), 500000, frame.unownedPointer());
    

    What I'm doing is encoding the data from frame and putting the data into the buffer pointed at QByteArray. If I comment out the avcodec_encode_video line my memory leak goes away. unownedPointer() looks like this:

     if (this->frame != NULL) return this->frame;
        this->frame =  avcodec_alloc_frame();
        uchar *data = this->img.bits();
        frame->data[0] = (uint8_t *)data;
        frame->data[1] = (uint8_t *)data + 1;
        frame->data[2] = (uint8_t *)data + 2;
        frame->linesize[0] = width * lineSize(this->fmt);
        frame->linesize[1] = width * lineSize(this->fmt);
        frame->linesize[2] = width * lineSize(this->fmt);
        return this->frame;
    

    Where this->frame is a AVFrame *, and this->img is a QImage.

    At a encoding rate of about 30fps, I'm getting a memory leak of about 50MB/sec. So I'm not sure what the issue could be. It seems as if avcodec_encode_video() is copying memory and never freeing it or something. Any ideas?

    If avcodec_encode_video is converting my RGB24 data to YUV420P would it be modifying the data pointed to by frame.unownedPointer()?

  • possible C code implementation ideas for a given shell script(related to ffmpeg)

    21 août 2011, par Ted

    The shell script i'm trying to implement goes like this,

        #!/bin/bash
        while [ 1 ]
        do
           nc -l 1234 | ffmpeg -i pipe:0 -vcodec mpeg4 -s qcif -f m4v -y pipe:1 | nc localhost 1235
        done 
    

    what it does is to simply take in a stream of video input through network and do live video transcoding(with ffmpeg of course!) and streaming back the video through the net. my question is how should i go by to implement this functionality in a clean C code. i know i can use popen() to pipe such a command from a c code but i would like to do better. may be with sockets and staff... any pointers are appreciated.

    AskLearnDo.

  • Iphone Streaming and playing Audio Problem

    20 août 2011, par KayKay

    I am trying to make an app that plays audio stream using ffmpeg, libmms.
    I can open mms server, get stream, and decode audio frame to raw frame using suitable codec.
    However I don't know how to do next.
    I think I must use AudioToolbox/AudioToolbox.h and make audioqueue.
    but however when I give audioqueuebuffer decode buffer's memory and play, Only plays the white noise.
    Here is my code.

    What am i missing?
    Any comment and hint is very appreciated.
    Thanks very much.

    while(av_read_frame(pFormatCtx, &pkt)>=0)
    {
        int pkt_decoded_len = 0;
        int frame_decoded_len;
        int decode_buff_remain=AVCODEC_MAX_AUDIO_FRAME_SIZE * 5;
        if(pkt.stream_index==audiostream)
        {
            frame_decoded_len=decode_buff_remain;
            int16_t *decode_buff_ptr = decode_buffer;
            int decoded_tot_len=0;
            pkt_decoded_len = avcodec_decode_audio2(pCodecCtx, decode_buff_ptr, &frame_decoded_len,
                                                    pkt.data, pkt.size);
            if (pkt_decoded_len <0) break;
            AudioQueueAllocateBuffer(audioQueue, kBufferSize, &buffers[i]);
            AQOutputCallback(self, audioQueue, buffers[i], pkt_decoded_len);
    
            if(i == 1){
                AudioQueueSetParameter(audioQueue, kAudioQueueParam_Volume, 1.0);
                AudioQueueStart(audioQueue, NULL);
            }
            i++;
        }
    }
    
    
    void AQOutputCallback(void *inData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer, int copySize)
    {
        mmsDemoViewController *staticApp = (mmsDemoViewController *)inData;
        [staticApp handleBufferCompleteForQueue:inAQ buffer:inBuffer size:copySize];
    }
    
    - (void)handleBufferCompleteForQueue:(AudioQueueRef)inAQ
                              buffer:(AudioQueueBufferRef)inBuffer
                                size:(int)copySize
    {
        inBuffer->mAudioDataByteSize = inBuffer->mAudioDataBytesCapacity;
        memcpy((char*)inBuffer->mAudioData, (const char*)decode_buffer, copySize);
    
        AudioQueueEnqueueBuffer(inAQ, inBuffer, 0, NULL);
    }