Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Choppy sound when using ffmpeg

    24 novembre 2011, par Kurt

    I suffered some choppy audio when i try to capture audio from a live stream. Another essential problem which could explain the problem is that the Wav file created is twice longer than the capture time.

    The audio is perfect when i play the avs input file with ffplay, so the avs is ok, the problem is after whether in the capture or in the Wav writing.

    To capture :

    av_read_frame(pFormatCtx, &packet)
    
    if(packet.stream_index == mAudioStream)
    {
        int buff_size = sizeof(mAudioBuffer);
        std::cout << "Buff_size " << buff_size << std::endl;
        len = avcodec_decode_audio3(pAudioCodecCtx,(int16_t*)mAudioBuffer, &buff_size,&packet);
        if(len < 0){
            qDebug("Extractor - Audio isEnd = -1;");
            mAudioBufferSize = 0;
            isEnd = ERROR_;
            return isEnd;
        }
    
        // Set packet result type
        mFrameType = AUDIO_PKT;
        mAudioBufferSize = buff_size;
        //store audio synchronization informations:
        if(packet.pts != AV_NOPTS_VALUE) {
             mAudioPts_ = av_q2d(pFormatCtx->streams[mAudioStream]->time_base);
             mAudioPts_ *= packet.pts;
        }
    }
    
            // store a copy of current audio frame in _frame
            _frame.audioFrame = new decoded_frame_t::audio_frame_t();
            _frame.audioFrame->sampleRate = mediaInfos.audioSampleRate;
            _frame.audioFrame->sampleSize = mediaInfos.audioSampleSize;
            _frame.audioFrame->nbChannels = mediaInfos.audioNbChannels;
            _frame.audioFrame->nbSamples = mAudioBufferSize / ((mediaInfos.audioSampleSize/8) * mediaInfos.audioNbChannels);
            _frame.audioFrame->buf.resize(mAudioBufferSize);
            memcpy(&_frame.audioFrame->buf[0],mAudioBuffer,mAudioBufferSize);
    

    Then i store in a Wav File using libsndfile :

    SNDFILE*            fd;
    SF_INFO             sfInf;
    
    sfInf.frames = 0;
    sfInf.channels = p_capt->ui_nbChannels;
    sfInf.samplerate = p_capt->ui_sampleRate;
    sfInf.format = SF_FORMAT_WAV | SF_FORMAT_PCM_U8;
    sfInf.sections = 0;
    sfInf.seekable = 0;
    
    if (sf_format_check(&sfInf) == FALSE)
        std::cout << "Format parameter are uncorrect ! Exit saving !" << std::endl;
    else
    {
        fd = sf_open(fileName.toStdString().c_str(), SFM_WRITE, &sfInf);
        if (fd == NULL)
        {
            std::cout << "Unable to open the file " << fileName.toStdString() << std::endl;
            return GRAB_ST_NOK;
        }
    
        //little trick because v_buf is a uint8_t vector
        sf_count_t l = sf_write_short(fd, (const short *)(&(p_capt->v_buf[0])), p_capt->v_buf.size()/2);
    
        if (l != p_capt->v_buf.size()/2)
        {
           std::cout << "sf_write didn't write the right amoung of bits " << l << " != " << p_capt->v_buf.size()/2 << std::endl;
           ret = GRAB_ST_NOK;
        }
        else
        {
            sf_write_sync(fd);
            sf_close(fd);
            ret = GRAB_ST_OK;
        }
    }
    

    I hope it's understandable. Waiting for remarks.

    Kurt

  • Link dynamic library and ffmpeg x86_64 version

    24 novembre 2011, par daniel

    I'm working with FFMPEG on Mac OSX, my Mac version is 10.6.8 (i386).

    When I try to compile my C++ code linking a dynamic library:

    g++ sdk.cpp -rpath /usr/local/lib/libinsight.dylib -o sdk
    

    I get the following error:

    Undefined symbols for architecture x86_64:
      "_main", referenced from:
        start in crt1.10.6.o
      "av_open_input_file(AVFormatContext**, char const*, AVInputFormat*, int,  AVFormatParameters*)", referenced from:
        ffmpeg_open(AVFormatContext**, char const*, int*)in ccCkx9dd.o
    
      (so forth fo every FFMPEG call)
    
      ld: symbol(s) not found for architecture x86_64
      collect2: ld returned 1 exit status
    

    Without linking dylib I have no problem. What's the matter?

    P.S. ffmpeg version is Mach-O 64-bit executable x86_64

  • Creating OpenCV project with no Video Transcoding (ffmpeg part) Support on Linux how to ?

    24 novembre 2011, par myWallJSON

    Currently I use something like this to create project make files:

    cmake -DCMAKE_INSTALL_PREFIX="./install-dir" -DBUILD_WITH_STATIC_CRT=ON -DBUILD_SHARED_LIBS=OFF -G "GCC" 
    

    And I use FFmpeg in my project that I compile sepratly. Also I do not like the way OpenCV workes with video transcoding any way - prefer to do it all manually with ffmpeg.

    I wonder if it is possible to create project file using Cmake so that OpenCV video (not images like png, jpg, tiff, etc) transcoding part will not be compiled (not camera grabbing - I like and use that one=))?

  • Simple way to grab thumbnail of FLV in ASP.NET without changing permissions on server ?

    23 novembre 2011, par Rhys Causey

    I'm looking for a simple way to grab thumbnails of FLVs in ASP.NET, without having to change any permissions/settings on the server. Ideally, nothing is installed on the server machine, but if necessary, small tools such as FFmpeg are fine.

    I've tried FFmpeg using the command-line tool with Process.Start, but the same command that works in a Windows Forms application and from the command prompt does not work in ASP.NET (presumably because of permissions).

    I've also tried using TAO.FFmpeg, and it seems to be working most of the time, but fails randomly, and does not start working again until the machine is restarted. Even when I use the sample code (decoder.cs), it sometimes fails when I try to open multiple videos in a single request.

    If this isn't possible in a clean/straightforward way, I'm open to other suggestions.

  • FFmpeg Hardware Acceleration -> GPU + DirectShow

    23 novembre 2011, par NoviceAndNovice

    Is there a hardware accelerated version of FFmpeg (e.g. a version that utilizes the GPU)?

    Also, does anybody use FFmpeg with GPU support? Possibly for scaling and converting video format? Or, for example, use DirectShow for image scaling and displaying images on surfaces? If so anybody can provide small code samples?