Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Build Opencv3.1 with ffmpeg

    10 mai 2018, par batuman

    I tried to build Opencv3.1 at Ubuntu16.04 with ffmpeg. I follow the instructions how to install ffmpeg at here.

    According to this discussion ,I checked.

    >> mediainfo ~/Desktop/grb_2.mp4 
    General
    Complete name                            : /home/nyan/Desktop/grb_2.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media
    Codec ID                                 : isom (isom/iso2/avc1/mp41)
    File size                                : 445 KiB
    Duration                                 : 27s 862ms
    Overall bit rate                         : 131 Kbps
    Encoded date                             : UTC 1904-01-01 00:00:00
    Tagged date                              : UTC 1904-01-01 00:00:00
    Writing application                      : Lavf57.66.105
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L3
    Format settings, CABAC                   : Yes
    Format settings, ReFrames                : 4 frames
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Duration                                 : 27s 862ms
    Bit rate                                 : 128 Kbps
    Width                                    : 720 pixels
    Height                                   : 480 pixels
    Display aspect ratio                     : 4:3
    Original display aspect ratio            : 4:3
    Frame rate mode                          : Constant
    Frame rate                               : 29.970 (30000/1001) fps
    Standard                                 : NTSC
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.012
    Stream size                              : 435 KiB (98%)
    Writing library                          : x264 core 148
    Encoding settings                        : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
    Encoded date                             : UTC 1904-01-01 00:00:00
    Tagged date                              : UTC 1904-01-01 00:00:00 
    
    
    
    
    
    ffmpeg -codecs | grep -i avc
    ffmpeg version N-90982-gb995ec0 Copyright (c) 2000-2018 the FFmpeg developers
      built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
      configuration: --prefix=/home/nyan/ffmpeg_build --enable-shared --extra-cflags=-I/home/nyan/ffmpeg_build/include --extra-ldflags=-L/home/nyan/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/nyan/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
      libavutil      56. 18.100 / 56. 18.100
      libavcodec     58. 19.100 / 58. 19.100
      libavformat    58. 13.101 / 58. 13.101
      libavdevice    58.  4.100 / 58.  4.100
      libavfilter     7. 21.100 /  7. 21.100
      libswscale      5.  2.100 /  5.  2.100
      libswresample   3.  2.100 /  3.  2.100
      libpostproc    55.  2.100 / 55.  2.100
     DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m ) (encoders: libx264 libx264rgb h264_v4l2m2m h264_vaapi )
     D.A.L. avc                  On2 Audio for Video Codec (decoders: on2avc )
    

    So my ffmpeg installation is ok.

    When I cmake to my Opencv, I have set up to ffmpeg as

    enter image description here

    But when I make to compile, I have error as

    make[2]: *** No rule to make target '/home/nyan/ffmpeg_build/lib/libavresample.a', needed by 'lib/libopencv_videoio.so.3.1.0'.  Stop.
    CMakeFiles/Makefile2:8709: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
    make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
    Makefile:160: recipe for target 'all' failed
    make: *** [all] Error 2
    

    How can I fix the problem?

    I install libavresample manually and

    sudo apt-get install libavresample-dev
    [sudo] password for nyan: 
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    libavresample-dev is already the newest version (7:2.8.14-0ubuntu0.16.04.1).
    

    It is newest version.

    EDIT:
    

    Actually libavresample at ffmpeg is deprecated already. So I tried to install Opencv3.4.1 higher version. Compile, build and installation are fine. But VideoCapture cap(0); does not read from the device. So I checked ffmpeg at Opencv3.4.1 installation as

    python -c "import cv2; print(cv2.getBuildInformation())" | grep -i ffmpeg
    

    FFMMPEG IS NO. So build with ffmpeg is not successful even though there was no error at build for Opencv3.4.1.

  • Installing FFMPEG from Conda = not found

    10 mai 2018, par dartdog

    Have installed FFMPEG via conda using conda install -c conda-forge ffmpeg and am getting RuntimeError: Requested MovieWriter (ffmpeg) not available any ideas? a direct Import ffmpeg yields not found as well conda list shows ffmpeg 4.0 installed using Ubuntu 16.04 current conda in an env..

  • Playing javacv-ffmpeg decoded audio in Android with Audiotrack

    10 mai 2018, par Ichigo Kurosaki

    i am developing android application in which i need to play AAC live audio stream coming from Red5 server.
    I have successfully decoded the audio stream by using javacv-ffmpeg.
    But my problem is how to play the audio from decoded samples.
    I have tried by following way

    int len = avcodec.avcodec_decode_audio4( audio_c,  samples_frame,  got_frame,  pkt2);
    if (len <= 0){
        this.pkt2.size(0);
    } else {
        if (this.got_frame[0] != 0) {
                long pts = avutil.av_frame_get_best_effort_timestamp(samples_frame);
                int sample_format = samples_frame.format();
                       int planes = avutil.av_sample_fmt_is_planar(sample_format) != 0 ? samples_frame.channels() : 1;
                       int data_size = avutil.av_samples_get_buffer_size((IntPointer)null, audio_c.channels(), samples_frame.nb_samples(), audio_c.sample_fmt(), 1) / planes;
    
                       if ((samples_buf == null) || (samples_buf.length != planes)) {
    
                           samples_ptr = new BytePointer[planes];
                           samples_buf = new Buffer[planes];
                       }
                               BytePointer ptemp = samples_frame.data(0);
                   BytePointer[] temp_ptr = new BytePointer[1];
                   temp_ptr[0] = ptemp.capacity(sample_size);
                   ByteBuffer btemp = ptemp.asBuffer();
                   byte[] buftemp = new byte[sample_size];
                   btemp.get(buftemp, 0, buftemp.length);
    
                               play the buftemp[] with audiotrack.....
            }
    

    But only noise is heard from speakers, is there any processing is need to be done on AVFrame we get from decode_audio4(...) .
    The Incoming audio stream is correctly encoded with AAC codec.
    Any help, suggestion appreciated.
    Thanks in advance.

  • getting error while converting wav to amr using ffmpeg

    10 mai 2018, par sohilv

    I am using ffmpeg to convert amr to wav and wav to amr.Its successfully converting amr to wav but not viceversa. As ffmpeg is supporting amr encoder decoder, its giving error.

    ffmpeg -i testwav.wav audio.amr

    Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

  • Generate thumbnail for inmemory uploaded video file

    10 mai 2018, par Adarsh

    The client app uploaded a video file and i need to generate a thumbnail and dump it to AWS s3 and return the client the link to the thumbnail. I searched around and found ffmpeg fit for the purpose. The following was the code i could come up with:

    from ffmpy import FFmpeg
    import tempfile
    
    def generate_thumbnails(file_name):
        output_file = tempfile.NamedTemporaryFile(suffix='.jpg', delete=False, prefix=file_name)
        output_file_path = output_file.name
        try:
            # generate the thumbnail using the first frame of the video
            ff = FFmpeg(inputs={file_name: None}, outputs={output_file_path: ['-ss', '00:00:1', '-vframes', '1']})
            ff.run()
    
            # upload generated thumbnail to s3 logic
            # return uploaded s3 path 
        except:
            error = traceback.format_exc()
            write_error_log(error)
        finally:
            os.remove(output_file_path)
        return ''
    

    I was using django and was greeted with permission error for the above. I found out later than ffmpeg requires the file to be on the disk and doesn't just take into account the InMemory uploaded file (I may be wrong as i assumed this).

    Is there a way to read in memory video file likes normal ones using ffmpeg or should i use StringIO and dump it onto a temp. file? I prefer not to do the above as it is an overhead.

    Any alternative solution with a better benchmark also would be appreciated.

    Thanks.

    Update: To save the inmemory uploaded file to disk: How to copy InMemoryUploadedFile object to disk