Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to convert Live video stream from YUV(HDYC) to RGB

    9 août 2013, par user2499628

    I want to convert video streams from webcam. that video streams are called HDYC. I think it's a little special so I didn't control now.

    My question is How to convert that format to rgb in c++ using ffmpeg? but there are some constraints. I don't want to make a file. in other wors, It needs to convert video streams from webcam. also It's a real time operation.

    Thanks.

  • convert f4v to mp4 with ffmpeg

    9 août 2013, par Winnie Oldright

    Trying to convert f4v to mp4 with ffmpeg

    This file

    FFmpeg :

    ffmpeg -i input.f4v -vcodec copy -acodec copy output.mp4
    

    In output i have black screen in video and no sound but track seconds are incrementing properly.

    What i'm doing wrong? Or maybe i need mpg or some other file type in out put (output file type should supports in android).

  • How to reliably get thumbnail images with libavcodec for H.264 I Frames

    9 août 2013, par Brad Mitchell

    I'm trying to extract out thumbnails using libavcodec from H.264 encoded video in an MP4 file.

    I'm finding that generating an image from an I-Frame every 30 or so seconds, is not resulting in a correct image. Every I-Frame (about every second) is producing a correct image.

    My understanding is that I-Frames can be decoded independently, and although avcodec_decode_video2 is saying that it was decoded, the encoded PNG doesn't look right at all.

    The basic code I'm using:

    AVIOContext* pIOCtx = avio_alloc_context(pBuffer, iBufSize, 0, mp4Obj, ReadFunc, 0, SeekFunc)
    AVFormatContext *pFormatCtx = avformat_alloc_context();
    pFormatCtx->pb - pIOCtx;
    pFormatCtx->flags = AVFMT_FLAG_CUSTOM_IO;
    
    if (avformat_open_input(&pFormatCtx, "", 0, 0) != 0)
        return -1;
    
    if (avformat_find_stream_info(pFormatCtx, NULL) < 0)
        return -1;
    
    AVCodec* videoDec;
    AVCodec* audioDec;
    
    int inputVs = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_VIDEO, -1, -1, &videoDec, 0);
    int inputAs = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, &audioDec, 0);
    AVCodecContext* videoInCodecContext = pFormatCtx->streams[inputVs]->codec;
    AVCodecContext* audioInCodecContext = pFormatCtx->streams[inputAs]->codec;
    
    AVCodec* videoInCodec = avcodec_find_decoder(CODEC_ID_H264);
    avcodec_open2(videoInCodecContext, videoInCodec, NULL);
    
    AVPacket* packet = (AVPacket*)av_mallocz(sizeof(AVPacket));
    while (av_read_frame(pFormatCtx, packet) >= 0)
    {
        AVPacket* pkt = (AVPacket*)av_mallocz(sizeof(AVPacket));
        *pkt = *packet;
        pkt->data = reinterpret_cast(new uint64_t[(packet->size + FF_INPUT_BUFFER_PADDING_SIZE)/sizeof(uint64_t) + 1]);
        // NOTE, copying the packet is for a different purpose, as in the real application
        //       the data is put onto a queue
        memcpy(pkt->data, packet->data, packet->size);
    
        ...
        ...
    
        // check in here if the pts > minimum pts etc,
        // minimum is the last video pts + pkt_timebase.den * 30
    
        if ((videoInCodecContext != NULL) && (firstImage == FALSE ||
                                              firstImage == TRUE && pkt->flags)))
        {
            AVFrame* picture = avcodec_alloc_frame();
            int got_picture = 0;
            int pts = pkt->pts;
            int dts = pkt->dts;
            //pkt->pts = pkt->dts = 0;
    
            int len = avcodec_decode_video2(videoInCodecContext, picture, &got_picture, pkt);
            if (len < 0)
                // error
            else if (got_picture)
            {
                firstImage = TRUE;
    
                // calculate thumbnail dimensions
                // encode thumbnail to png
            }
            av_free(picture);
        }
    }
    
  • Is there an effective and cheap/free way to host video for a mobile app that must be approved by an admin before going live ? [on hold]

    9 août 2013, par user2658775

    We are building a mobile app for the iOS and Android operating systems. The app is to be a communication platform for members within an organization. Content is generated by users and submitted to the admin. Once approved by the admin the content is pushed to the app. One feature of the app is the ability to upload video.

    We are having a tough time attempting to figure out the best way to do this. Because the app will be representing the organization, the organization must have control over the approval process.

    So far we have come up with the following options:

    Option 1: purchase a dedicated server from hosting service provider. The basic package with Blue host is $150/month which is fairly expensive.

    Option 2: have the users post to YouTube using their personal accounts. Upon posting to YouTube (via the app) the app would send a notification to the admin that a new video has been posted. Admin would review the video and if acceptable admin would user url link to post video to app. This option, while free, requires many steps that will bog down the submittal process.

    Does anyone know of an effective way to post video to an app that requires approval by an admin?

  • PHP FFMPEG not working when I upload mp4 file

    9 août 2013, par Chris

    To convert video to formats compatible with HTML5 video I wrote the following script:

        $srcFile = "name/of/the/video.mp4";
        $destFile = "/media/video/newfilename";
        $ffmpegPath = "/usr/local/bin/ffmpeg";
        $flvtool2Path = "/usr/local/bin/flvtool2";
    
        // Create our FFMPEG-PHP class
        $ffmpegObj = new ffmpeg_movie($srcFile);
        // Save our needed variables
        $srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
        $srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
        $srcFPS = $ffmpegObj->getFrameRate();
        $srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
        $srcAR = $ffmpegObj->getAudioSampleRate();
        $srcVB = floor($ffmpegObj->getVideoBitRate()/1000); 
    
    
        // Call our convert using exec() to convert to the three file types needed by HTML5
        exec($ffmpegPath . " -i ". $srcFile ." -vcodec libx264 -vpre hq -vpre ipod640 -b ".$srcVB."k -bt 100k -acodec libfaac -ab " . $srcAB . "k -ac 2 -s " . $srcWidth . "x" . $srcHeight . " ".$destFile.".mp4");
    
        exec($ffmpegPath . " -i ". $srcFile ." -vcodec libvpx -r ".$srcFPS." -b ".$srcVB."k -acodec libvorbis -ab " . $srcAB . " -ac 2 -f webm -g 30 -s " . $srcWidth . "x" . $srcHeight . " ".$destFile.".webm");
    
        exec($ffmpegPath . " -i ". $srcFile ." -vcodec libtheora -r ".$srcFPS." -b ".$srcVB."k -acodec libvorbis -ab " . $srcAB . "k -ac 2 -s " . $srcWidth . "x" . $srcHeight . " ".$destFile.".ogv");
    

    It is supposed to take any input video type and convert it to mp4, ogv and webm. When I run the script on a .mov file it returns a mp4 and ogv file, but not webm. When I run it on a .mp4 file it returns no converted files at all. Is there something wrong with the way I am converting the files? Any help?