Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • 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.

  • ffmpeg minimal requirements configuration for encoding and decoding h264 files

    14 novembre 2013, par TheSquad

    I'm trying to compile ffmpeg with minimal requirements in order to encode/decode with h264.

    So far my command line configuration is :

    ./configure --disable-yasm --disable-everything --enable-encoder=libx264 --enable-encoder=libfaac --enable-decoder=h264 --enable-muxer=h264 --enable-demuxer=h264 --enable-parser=h264 --enable-protocol=file
    

    once compiled, I try this :

    ./ffmpeg -i ~/Dropbox/TestFile.mov -vcodec libx264 test.mp4
    

    but I get an error :

      ffmpeg version N-58081-g2925571 Copyright (c) 2000-2013 the FFmpeg developers
      built on Nov 14 2013 15:49:58 with Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
      configuration: --disable-yasm --disable-everything --enable-encoder=libx264 --enable-encoder=libfaac --enable-decoder=h264 --enable-muxer=h264 --enable-demuxer=h264 --enable-parser=h264 --enable-protocol=file
      libavutil      52. 52.100 / 52. 52.100
      libavcodec     55. 43.100 / 55. 43.100
      libavformat    55. 21.100 / 55. 21.100
      libavdevice    55.  5.100 / 55.  5.100
      libavfilter     3. 91.100 /  3. 91.100
      libswscale      2.  5.101 /  2.  5.101
      libswresample   0. 17.104 /  0. 17.104
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/mGs/Dropbox/TestFile.mov':
      Metadata:
        major_brand     : qt  
        minor_version   : 0
        compatible_brands: qt  
        creation_time   : 2013-06-23 14:33:09
        model           : iPhone 4S
        model-fra       : iPhone 4S
        encoder         : 6.0
        encoder-fra     : 6.0
        date            : 2013-06-23T16:33:09+0200
        date-fra        : 2013-06-23T16:33:09+0200
        make            : Apple
        make-fra        : Apple
      Duration: 00:00:42.09, start: 0.000000, bitrate: 20960 kb/s
        Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20880 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 1200 tbc (default)
        Metadata:
          rotate          : 180
          creation_time   : 2013-06-23 14:33:09
          handler_name    : Core Media Data Handler
        Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, 63 kb/s (default)
        Metadata:
          creation_time   : 2013-06-23 14:33:09
          handler_name    : Core Media Data Handler
    [NULL @ 0x7fd999802e00] Unable to find a suitable output format for 'test.mp4'
    test.mp4: Invalid argument
    

    This is probably coming from the fact that I have forgot something to enable on the ffmpeg configuration... But I can't found out what.

    The test file is a video got from iPhone 4S Camera.

  • Video Concatnation using javacv

    14 novembre 2013, par bindal

    I have integrated this Javacv for concatenating 2 videos this code works find when i was using 2 videos recorded from rear camera,but when i record 1 video with front cameara and another with rear camera then another half video is rotated upside down Is there any specific settings while recording from front camera,

    I have used this library from github https://github.com/sourab-sharma/TouchToRecord

    Here is the recording file Video Recording

    Please give me some solution on this

    Thanks