Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFmpeg - Convert MP4 to Webm very slow

    26 avril 2017, par Luzwitz

    I need convert MP4 to webm with ffmpeg. So, i use :

    ffmpeg -i input.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output.webm
    

    But it's very long.

    Is there faster ?

  • ffmpeg avformat_open_input with custom stream object

    26 avril 2017, par trigger_death

    I'm currently trying to write a custom SoundFileReader for SFML using ffmpeg's libraries. The only thing I have available to use with avcodec and avformat is the class InputStream below which is part of SFML. I've looked at avformat_open_input and AVIOContext and I learned how to use custom stream with a buffer but how do I create an AVIOContext that works with the custom read, seek, and lseek functions?

    class InputStream {
        int64_t getSize()
        int64_t read(void* data, int64_t size);
        int64_t seek(int64_t position);
        int64_t tell(); // Gets the stream position
    };
    
  • OpenCV python, reading video frames from ffmpeg pipe

    26 avril 2017, par codefame

    I'm trying to use ffmpeg to pipe a video to opencv frame by frame.

    Structure:

    1. main script calls threaded process to obtain video & pipe video to image2pipe
    2. main script calls threaded process to read stdout for frame info
    3. main script calls function to continuously check for frame data

    Video Capture Function:

    def recordstream(self):
        global pipe
        # start video capture process
        pipe = Popen([VIDEO_CAPTURE_SOURCE + " | ffmpeg -i pipe:0 -pix_fmt bgr24 -r 1 -f image2pipe -"], stdout = PIPE, bufsize=10**8, shell=True)
    

    This ffmpeg code seems to work just fine when the capture source was tested with a single frame, but it doesn't work using the video stream.

    Buffer Read Function:

    def rawImage(self):
        global pipe, raw_image
        raw_image = pipe.stdout.read() # save output for opencv
    

    I gave this its own thread because it seems to be a blocking function.

    OpenCV Function:

    def checkframe(self):
        time.sleep(2)
        global raw_image
    
        while(True):
            array = numpy.frombuffer(raw_image, dtype='uint8')
            frame = cv2.imdecode(array, 1)
    
            if frame is None:
                print("Image not found")
            else:
                print("FOUND IMAGE")
                cv2.imshow(frame)
                if cv2.waitKey(1) & 0xFF == ord('q'):
                    break
    

    This function fails at frame = cv2.imdecode(array, 1) as the array seems to be empty.

    Error:

    !buf.empty() && buf.isContinuous() in function imdecode_
    

    I see lots of discussion around piping data from OpenCV to ffmpeg, but not much the other way around. What am I missing here?

    Thanks in advance.

  • How to recompile ffmpeg in Ubuntu

    26 avril 2017, par David Page

    I installed ffmpeg in Ubuntu but in a wrong way--I compiled it with only --enable-libass. And now I can not use -crf option so I want to recompile it.

    According to this page I typed these command:

    rm -rf ~/ffmpeg_build ~/ffmpeg_sources~/bin/{ffmpeg,ffprobe,ffplay,ffserver,vsyasm,x264,x265,yasm,ytasm}
    

    then I started compile again:

    cd ~/ffmpeg_sources
    wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
    tar xjvf ffmpeg-snapshot.tar.bz2
    cd ffmpeg
    PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
      --prefix="$HOME/ffmpeg_build" \
      --pkg-config-flags="--static" \
      --extra-cflags="-I$HOME/ffmpeg_build/include" \
      --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
      --bindir="$HOME/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
    PATH="$HOME/bin:$PATH" make
    make install
    make distclean
    hash -r
    

    But when I type ffmpeg it still output:

    ffmpeg version N-77474-g11388b5 Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
      configuration: --enable-libass
      libavutil      55. 11.100 / 55. 11.100
      libavcodec     57. 20.100 / 57. 20.100
      libavformat    57. 20.100 / 57. 20.100
      libavdevice    57.  0.100 / 57.  0.100
      libavfilter     6. 22.100 /  6. 22.100
      libswscale      4.  0.100 /  4.  0.100
      libswresample   2.  0.101 /  2.  0.101
    

    I am puzzled and how to recompile or remove ffmpeg in a right way?

  • Incorrect syntax using FFmpeg

    25 avril 2017, par Halid Kyazim

    Hello guys i am tring to convert videos using FFmpeg...

    1. I moved ffmpeg.exe in same folder with upload.php

    2. I tryed this codes in upload.php:

      $randname = (rand(0,1000));
      $file_data=date("d-m-Y-H-i-s");
      $file_name=$file_data.$randname;
      move_uploaded_file($file_tmp,"vidconvert/".$file_name);
      exec (ffmpeg -i vidconvert/.$file_name videos/.$file_name.mp4);
      echo "Success";
      
    3. I want to get the file in vidconvert folder, and copy converted video to videos folder

    Note: when i check the vidconfert folder, the file is uploaded succesfully