Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Why low qmax value improve video quality ?

    14 novembre 2013, par theateist

    Maybe my questions doesn't make sense due to not understanding but please explain me what I miss because I did read posts and wiki and still it's not clear to me.

    As I understand setting low value for qmax will improve the quality by increasing the bitrate. Maybe I didn't understood something but isn't lowing the Q(quantization) will decrease the quantization levels and thus the bitrate which means degradation in quality? Or in ffmpeg lowing Q means increasing the quantization levels? If the last is true so it make sense that lower qmax improves the quality.

    If the above is true, so increasing qmax will decrease the quantization levels which means less bits for coding a quantization level. So, if number of bits for a level is lower, so total bits per frame will be lower, so how the encoder manage to get to the desired bitrate?

  • OpenCV libopencv_core.so.2.4.1 File Not Found

    14 novembre 2013, par benrules2

    I am trying to setup OpenCV v2.4.1 with FFMPEG v0.11 support on Scientific Linux SL release 5.0 (Boron), and I am running into a problem with a missing file that seems completely undocumented. The error I am getting is as follows:

    -- Install configuration: "Release"
    
    -- Up-to-date: /home/s18/s1138832/OpenCV/include/opencv/cv.h
    -- Up-to-date: /home/s18/s1138832/OpenCV/include/opencv/cxmisc.h
    -- Up-to-date: /home/s18/s1138832/OpenCV/include/opencv/cvwimage.h
    -- Up-to-date: /home/s18/s1138832/OpenCV/include/opencv2/opencv.hpp
    CMake Error at modules/core/cmake_install.cmake:63 (FILE):
    file INSTALL cannot find file
      "/home/s18/s1138832/OpenCV/lib/libopencv_core.so.2.4.1" to install.
    Call Stack (most recent call first):
      modules/cmake_install.cmake:57 (INCLUDE)
      cmake_install.cmake:56 (INCLUDE)
    

    I honestly don't know where to begin troubleshooting this at this point. I successfully installed without ffmpeg a few days ago, but now I can't even install with ffmpeg support set to off.

    The files that link to the missing library are:

    lrwxrwxrwx 1 s1138832 s18      21 Jun 17 18:26 libopencv_core.so ->    libopencv_core.so.2.4
    lrwxrwxrwx 1 s1138832 s18      23 Jun 17 18:26 libopencv_core.so.2.4 -> libopencv_core.so.2.4.1
    

    Any advice or prods in the right direction would be much appreciated. I would also be happy to provide more info on whatever interesting details I may have omitted.

    UPDATES: This website seems to have the same error, but I can't read it and translations patchy - http://www.opencv.org.cn/forum/viewtopic.php?f=1&t=15664 ( http://translate.google.com/translate?sl=auto&tl=en&js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&u=http%3A%2F%2Fwww.opencv.org.cn%2Fforum%2Fviewtopic.php%3Ff%3D1%26t%3D15664&act=url )

    libopencv_core.so.2.4.1 exists after "make", but "make install" deletes it somehow. I copied it and added it again, but it didn't change anything

  • Opening file with unknown extension (Mjpeg ?) in OpenCV python

    14 novembre 2013, par bw4sz

    I am trying to open a third party video file into OpenCV with python. My camera (plotwatcher camera trap) shoots in a silly proprietary format. The extension is unique (.tlv) but i can play the file in VLC, and using ffmpeg i can see the following encoding:

    C:\Users\Ben>ffmpeg -i C:/Users/Ben/Documents/OpenCV_HummingbirdsMotion/PlotwatcherTest.tlv
    
    ffmpeg version N-58037-g355cea8 Copyright (c) 2000-2013 the FFmpeg developers
    built on Nov 11 2013 18:01:42 with gcc 4.8.2 (GCC)
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
    isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
    le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
    e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
    ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
    ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
    eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
    cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
    ack --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
    libavutil      52. 52.100 / 52. 52.100
    libavcodec     55. 41.100 / 55. 41.100
    libavformat    55. 21.100 / 55. 21.100
    libavdevice    55.  5.100 / 55.  5.100
    libavfilter     3. 90.102 /  3. 90.102
    libswscale      2.  5.101 /  2.  5.101
    libswresample   0. 17.104 /  0. 17.104
    libpostproc    52.  3.100 / 52.  3.100
    Input #0, avi, from 'C:/Users/Ben/Documents/OpenCV_HummingbirdsMotion/Plotwatche
    rTest.tlv':
    Duration: 00:00:05.00, start: 0.000000, bitrate: 14608 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc), 1280x720, 10 tb
    r, 10 tbn, 10 tbc
    

    From this i can see file is encoded into mjpeg format.

    How can i open this file in open cv?

    import cv2
    #import cv2.cv as cv
    import numpy as np
    cap = cv2.VideoCapture("C:/Users/Ben/Documents/OpenCV_HummingbirdsMotion/PlotwatcherTest.mjpg")
    ret, frame = cap.read()
    #show first image
    cv2.imshow('my window',frame)
    cv2.waitKey(0)
    cv2.destroyWindow('my window')
    

    I can see nothing has been loaded. When i try to view the first frame i get the error:

    File "C:\Users\Ben\Documents\OpenCV_HummingbirdsMotion\Test.py", line 21, in 
    cv2.imshow('my window',frame)
    error: ..\..\..\..\opencv\modules\highgui\src\window.cpp:261: error: (-215)
    size.width>0        && size.height>0
    

    I've tried leaving the native .tlv, mjpeg and mjpg, and .MJPG endings following the conceptual idea found here: MJPEG stream fails to open in OpenCV 2.4

    i appreciate all help!

  • iOS FFmpeg : Requested output format 'flv' is not a suitable output format

    14 novembre 2013, par user2992563

    I just upgraded my iOS compiled FFmpeg library to 1.2.1 and now I'm getting the following error message: Requested output format 'flv' is not a suitable output format.

    I tried changing format to 'avi' and 'mov' aswell, but it seems that no matter the format_name I pass I get the same error message.

    This is how I set up the format_name:

    avformat_alloc_output_context2(&file, NULL, "flv", cname)
    

    And this is how I write the stream packets:

    // Appends a data packet to the rtmp stream
    -(bool) writePacket: (Demuxer *) source
    {
    int code = 0;
    
    AVCodecContext
    *videoCodec = [source videoCodec],
    *audioCodec = [source audioCodec];
    
    // Write headers
    if(useHeaders)
    {
        AVStream
        *video = av_new_stream(file, VIDEO_STREAM),
        *audio = av_new_stream(file, AUDIO_STREAM);
    
        if (!video || !audio)
            @throw [NSException exceptionWithName: @"StreamingError" reason: @"Could not allocate streams" userInfo: nil];
    
        // Clone input codecs and extra data
        memcpy(video->codec, videoCodec, sizeof(AVCodecContext));
        memcpy(audio->codec, audioCodec, sizeof(AVCodecContext));
    
        video->codec->extradata = av_malloc(video->codec->extradata_size);
        audio->codec->extradata = av_malloc(audio->codec->extradata_size);
    
        memcpy(video->codec->extradata, videoCodec->extradata, video->codec->extradata_size);
        memcpy(audio->codec->extradata, audioCodec->extradata, audio->codec->extradata_size);
    
        // Use FLV codec tags
        video->codec->codec_tag = FLV_TAG_TYPE_VIDEO;
        audio->codec->codec_tag = FLV_TAG_TYPE_AUDIO;
        video->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
        video->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
        audio->codec->sample_rate = INPUT_AUDIO_SAMPLING_RATE;
    
        // Update time base
        video->codec->time_base.num = 1;
        audio->codec->time_base.den = video->codec->time_base.den = FLV_TIMEBASE;
    
        // Signal bitwise stream copying
        //video->stream_copy = audio->stream_copy = 1;
    
        if((code = avformat_write_header(file, NULL)))
            @throw [NSException exceptionWithName: @"StreamingError" reason: @"Could not write stream headers" userInfo: nil];
        useHeaders = NO;
    }
    bool isVideo;
    AVPacket *packet = [source readPacket: &isVideo];
    
    if(!packet)
        return NO;
    
    if(isVideo)
    {
        packet->stream_index = VIDEO_STREAM;
        packet->dts = packet->pts = videoPosition;
        videoPosition += packet->duration = FLV_TIMEBASE * packet->duration * videoCodec->ticks_per_frame * videoCodec->time_base.num / videoCodec->time_base.den;
    }
    else
    {
        packet->stream_index = AUDIO_STREAM;
        packet->dts = packet->pts = audioPosition;
        audioPosition += packet->duration = FLV_TIMEBASE * packet->duration / INPUT_AUDIO_SAMPLING_RATE;
    }
    
    packet->pos = -1;
    packet->convergence_duration = AV_NOPTS_VALUE;
    
    // This sometimes fails without being a critical error, so no exception is raised
    if((code = av_interleaved_write_frame(file, packet)))
        NSLog(@"Streamer::Couldn't write frame");
    
    av_free_packet(packet);
    return YES;
    }
    

    In the code above I had to comment out this line as stream_copy has been removed from the newest version of FFmpeg:

    video->stream_copy = audio->stream_copy = 1;
    

    Any help would be greatly appreciated!

  • Connecting to RTSP stream via FFMpeg - 'could not find codec parameters for stream 0'

    14 novembre 2013, par user2992545

    I'm a beginner in the FFMpeg world, so please excuse me my overall level of knowledge and any mistakes.

    What I have here is a DVR, made by ITX Security. I have an SDK for it and currently I'm trying to connect to its RTSP using FFMPEG. I've been partially succesfull (i think), the best what I got was:

    `(...)bin>ffplay -user-agent "ITX Security" rtsp://ADMIN:1234@192.168.2.130:5554/live/
    
    [rtsp @ 02a242e0] UDP timeout, retrying with TCPB sq=0B f=0/0
    [rtsp @ 02a242e0] method PAUSE failed: 501 Not Implemented
    [rtsp @ 02a242e0] Could not find codec parameters for stream 0 (Video: h264):unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options
    rtsp://ADMIN:1234@192.168.2.130:5554/live/: could not find codec parameters
    
    nan:  0.000 fd=0 aq=    0KB vq=    0KB sq=    0B f=0/0`
    

    Is it really indicating that it has trouble in playing the stream (because it lacks a proper codec?) - or am I just not getting the point?

    I've captured traffic between my computer and the DVR in question, and something is happening (at least that's what Wireshark says).

    https://www.dropbox.com/s/j65lige244kg8jt/rtsp_ffmpeg.pcap

    What am I doing wrong?

    Regards.