Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Where the decoded frame by ffmepg stored ?

    26 août 2013, par Jar

    I try to decode video and convert frame to rgb32 or gb565le format.

    Then pass this frame from C to Android buffer by JNI.

    So far, I know to how pass buffer from C to Android as well as how to decode video and get decoded frame.

    My question is how to convert decoded frame to rgb32 (or rgb565le) and where is it stored?

    The following is my code, I'm not sure is correct or not.

    -Jargo


    img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, 100, 100, PIX_FMT_RGB32, SWS_BICUBIC, NULL, NULL, NULL);
    if(!img_convert_ctx) return -6;
    
    while(av_read_frame(pFormatCtx, &packet) >= 0) {
       // Is this a packet from the video stream?
       if(packet.stream_index == videoStream) {
           avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
    
           // Did we get a video frame?
           if(frameFinished) {
                AVPicture pict;
    
                if(avpicture_alloc(&pict, PIX_FMT_RGB32, 100, 100) >= 0) {
                    sws_scale(img_convert_ctx, (const uint8_t * const *)pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pict.data, pict.linesize);
                }
           } // End of if( frameFinished )
       } // End of if( packet.stream_index == videoStream )
    
       // Free the packet that was allocated by av_read_frame
       av_free_packet(&packet);
    }
    
  • How to convert 1920x1200 HD video from MOV to MP4 without change of the original size [on hold]

    25 août 2013, par user2618501

    I have a 1920x1200, 50 fps MOV file that I want to convert to MP4. I tried several converters on Mac but all create a MP4 file with 1728x1080 resolution.

    I also tried to convert the video using ffmpeg. This created a very small MP4 file with the desired size but with a horrible quality. I used

    ffmpeg -i my.mov -r 50 1920.mp4
    

    Is there some better way to convert MOV to MP4 while keeping the original resolution and quality?

  • Libav and xaudio2 - audio not playing

    25 août 2013, par siz

    I am trying to get audio playing with libav using xaudio2. The xaudio2 code I am using works with an older ffmpeg using avcodec_decode_audio2, but that has been deprecated for avcodec_decode_audio4. I have tried following various libav examples, but can't seem to get the audio to play. Video plays fine (or rather it just plays right fast now, as I haven't coded any sync code yet).

    Firstly audio gets init, no errors, video gets init, then packet:

    while (1) {
        //is this packet from the video or audio stream?
        if (packet.stream_index == player.v_id) {
            add_video_to_queue(&packet);
        } else if (packet.stream_index == player.a_id) { 
            add_sound_to_queue(&packet);
        } else {
            av_free_packet(&packet);
        }
    }
    

    Then in add_sound_to_queue:

    int add_sound_to_queue(AVPacket * packet) {
    AVFrame *decoded_frame = NULL;
    int done = AVCODEC_MAX_AUDIO_FRAME_SIZE;
    int got_frame = 0;
    
    if (!decoded_frame) {
        if (!(decoded_frame = avcodec_alloc_frame())) {
            printf("[ADD_SOUND_TO_QUEUE] Out of memory\n");
            return -1;
        }
    } else {
        avcodec_get_frame_defaults(decoded_frame);
    }
    
    if (avcodec_decode_audio4(player.av_acodecctx, decoded_frame, &got_frame, packet) < 0)  {
        printf("[ADD_SOUND_TO_QUEUE] Error in decoding audio\n");
        av_free_packet(packet);
        //continue;
        return -1;
    }
    if (got_frame) {
        int data_size;
        if (packet->size > done) {
            data_size = done;
        } else {
            data_size = packet->size;
        }
        BYTE * snd = (BYTE *)malloc( data_size * sizeof(BYTE));
    
        XMemCpy(snd,
            AudioBytes, 
            data_size * sizeof(BYTE)
        );
    
        XMemSet(&g_SoundBuffer,0,sizeof(XAUDIO2_BUFFER));
    
        g_SoundBuffer.AudioBytes = data_size;
        g_SoundBuffer.pAudioData = snd;
        g_SoundBuffer.pContext = (VOID*)snd;
    
        XAUDIO2_VOICE_STATE state;
        while( g_pSourceVoice->GetState( &state ), state.BuffersQueued > 60 ) {
            WaitForSingleObject( XAudio2_Notifier.hBufferEndEvent, INFINITE );
        }
    
        g_pSourceVoice->SubmitSourceBuffer( &g_SoundBuffer );
    }
    return 0;
    }
    

    I can't seem to figure out the problem, I have added error messages in init, opening video, codec handling etc. As mentioned before the xaudio2 code is working with an older ffmpeg, so maybe I have missed something with the avcodec_decode_audio4?

    If this snappet of code isn't enough, I can post the whole code, these are just the places in the code I think the problem would be :(

  • live stream desktop to android tablet and delay

    25 août 2013, par Nani

    I am trying to live stream the desktop to android tablet. Here is what I did

    1) Capture the screen using the ffmpeg

    ffmpeg -y -f x11grab -s 800x600 -r 20 -i :0 http://x.x.x.x:8090/feed1.ffm

    2) Stream using ffserver

    Here is partial ffserver.conf file

    
    Feed feed1.ffm
    Format flv
    NoAudio                                                
    VideoSize 800x600                                      
    
    

    3) Play the stream on the tablet (Android 4.3) using URL "http://x.x.x.x:8090/test"

    I am able to see the desktop on tablet with few issues 1) There is around 6 to 8 secs delay in the video 2) player shows a warning "first frame is no keyframe"

    When I changed the "Format flv" to "Format mpegts" in "ffserver.conf" file the warning is gone. But the delay is still there.

    Is there a way to reduce the delay?

    Am I using the correct format?

    I want to achieve at max 2 sec delay for my desktop streaming.

  • Using a Web-based installer to retrieve (not distribute) 3rd party GPL or non-free software

    25 août 2013, par user1493918

    I am developing a software product which is able to communicate over a command line interface with GPL-covered software (specifically, my software can feed commands to FFMpeg). I understand that a crucial aspect of the GPL license is whether or not you distribute GPL-covered applications. My goal is to allow my users to have a seamless experience installing both my software and 3rd party GPL software. But I am trying to do this without my software actually including the the 3rd party (GPL-covered) software. To do this I am considering Web-based installers. I could use a Web-based installer to allow the end-user the option to retrieve a GPL-covered or non-free software app from a totally different server, independent of my own and outside my control. The user would be the one to install the software simply by making a decision (i.e. pressing "Next" in my installer). If they chose to do so, then my software's Web-based installer would retrieve the 3rd-party software, decompress and install it, then move on to installing my own application. In this way, my installer doesn't ship any GPL-covered or non-free software, and yet from the user's perspective all they had to do is click Next... Next... Next... Done!

    I have read about the GPL allowing you to distribute GPL-covered apps as part of an "aggregate..." http://www.gnu.org/licenses/gpl-faq.html#MereAggregation

    ...but this scenario isn't that. It's allowing the user to retrieve applications or libraries at his own discretion, using his own bandwidth, downloading from a server that has nothing to do with me.

    I can't seem to find information anywhere about the GPL-related licensing implications of using a Web-based installer. My goal is simply to give the end user every high-quality transcoding option possible within FFMpeg without stepping on anybody's toes legally.

    Possible? If so then I'm hoping someone might be able to point me to a software installer program that would facilitate this. Thank you in advance for any replies.