Newest 'ffmpeg' Questions - Stack Overflow

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

Articles published on the website

  • How to stretch the WAV file to the same video length?

    5 October 2016, by Michael Heuberger

    So yeah, having a tricky ffmpeg issue here.

    In my app I'm encoding a video based on image frames and add a WAV file for the sound from the same source but through a different web socket. It can happen that the WAV file doesn't always have exactly the same length as the video based on those images + fps (plus minus few seconds).

    How can I tell ffmpeg to "stretch" the input WAV file to have it the same length as the video?

    In short: images (i) + WAV (w) = final video (v)

    length(w) != length (v) ... which is causing problems.

    Here an example ffmpeg command I am currently using:

    ffmpeg -f image2 -thread_queue_size 512 -framerate 21.5 -i /frames/%d.webp -i videomail_preview.wav -y -acodec aac -strict experimental -ac 1 -vcodec libx264 -crf 16 -preset fast -profile:v baseline -pix_fmt yuv420p -loglevel warning -movflags +faststart videomail_good.mp4 -acodec libvorbis -ac 1 -vcodec libvpx -crf 8 -deadline good -cpu-used 1 -pix_fmt yuv420p -loglevel warning -movflags +faststart videomail_good.webm

    Any suggestions/trick I am unaware of?

  • ffmpeg batch reencode with subfolders

    4 October 2016, by Alan

    I am trying to reencode a few hundred videos to X265 but there are many directories that have spaces in the filenames as do some of the files. I have looked at a bunch of scripts and am struggling to find one that works with the spaces and the different directory levels.

    This one works, as long as there is no sub directories:

    #!/bin/bash
    for i in *.avi;
    do 
        ffmpeg -i "$i" -c:v libx265 -c:a copy X265_"$i"
    done
    

    I have been trying to work with this bash script, but it fails with the whitespaces I am guessing.

    #!/bin/bash
    inputdir=$PWD
    outputdir=$PWD
    while IFS= read -r file ; do
      video=`basename "$file"`
      dir=`dirname "$file"`
     ffmpeg -fflags +genpts -i "$file" -c:v libx265 -c:a copy "$dir"/X265_"$video"
    done < <(find "$inputdir" -name "*.avi" | head -100)
    

    On this thread it looks like a good solution for windows users, but not linux. FFMPEG - Batch convert subfolders

    FOR /r %%i in (*.mp4) DO ffmpeg32 -i "%%~fi" -map 0:0 -map 0:1 -map 0:1 -c:v copy -c:a:0 aac -b:a 128k -ac 2 -strict -2 -cutoff 15000 -c:a:1 copy "%%~dpni(2)%%~xi"

    If you can point me to the right solution that is appropriate for bash, I would appreciate it.

  • VLC snytax to transcode & stream to stdout?

    4 October 2016, by Will Tower

    Goal: I am trying to use VLC as a local server to expand the video capabilities of an app created with Adobe AIR, Flex and Actionscript. I am using VLC to stream to stdoutand reading that output from within my app.

    VLC Streaming capabilities
    VLC Flash Video

    Status: I am able to launch VLC as a background process and control it through its remote control interface (more detail). I can load, transcode and stream a local video file. The example app below is a barebones testbed demonstrating this.

    Issue: I am getting data in to my app but it is not rendering as video. I don't know if it is a problem with my VLC commands or with writing to/reading from stdout. This technique of reading from stdout in AIR works (with ffmpeg for example).

    One of the various transcoding commands I have tried:

    -I rc  // remote control interface  
    -vvv   // verbose debuging  
    --sout  // transcode, stream to stdout 
    "#transcode{vcodec=FLV1}:std{access=file,mux=ffmpeg{mux=flv},dst=-}"
    

    This results in data coming into to my app but for some reason it is not rendering as video when using appendBytes with the NetStream instance.

    If instead I write the data to an .flv file, a valid file is created – so the broken part seems to be writing it to stdout. One thing I have noticed: I am not getting metadata through the stdout`method. If I play the file created with the command below, I do see metadata.

    Hoping someone sees where I am going wrong here.


    // writing to a file
    var output:File = File.desktopDirectory.resolvePath("stream.flv");
    var outputPath:String = output.nativePath;
    "#transcode{vcodec=FLV1}:std{access=file,mux=ffmpeg{mux=flv},dst=" + outputPath + "}");
    

    Note: In order to get this to work in AIR, you need to define the app profile as "extendedDesktop"


      <?xml version="1.0" encoding="utf-8"?>
      
    
        
            
        
    
        
    
    
  • Failed to build opencv for conda

    4 October 2016, by Caenorst

    I'm on Ubuntu 16.04 64 bits, using Anaconda2.

    I'm trying to install Opencv for conda with FFMPEG support (for VideoCapture).

    I followed this tutorial: http://dhaneshr.net/2016/06/03/installing-opencv-2-4-x-with-ffmpeg-python-on-anaconda/

    changed cmake to 3.3.1 and -DWITH_FFMPEG=1 but when I execute $ conda build conda

    It fails at the test to import cv2

    You can find the whole log in this file: https://gist.github.com/Caenorst/e6bce629178540f30818a66e2f3a8663

  • "opaque" pointer in ffmpeg AVFrame

    4 October 2016, by R2-D2

    In ffmpeg there is a structure AVFrame describing decoded video or audio data.

    It has a void pointer opaque. The documentation claims it is "for some private data of the user".

    What does this mean? Can it be used to transport any additional data as per-frame metadata?