Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to Capture the Desktop and System Sounds using FFMPEG and C ?

    3 décembre 2014, par CaptainObvious

    I'm new to multimedia programming, but have lots of experience in programming in C in general. I want to develop my own program to capture( record ) the desktop and save it to a youtube compatible file using the ffmpeg API. Due to my inexperience in the multimedia field, I don't know where to start looking in the ffmpeg API for such a function or the terminology commonly used to refer to such functionality. I've tried googling to see if I could find any examples or tutorials or how to use ffmpeg to do something similar to this, but I have found nothing except the ways it can be done using the pre-compiled programs on the command line. The only tutorial I have found relating to ffmpeg and C was Dranger's tutorial, but that only covers how to make a simple video player. Can someone provide an example or direct me to the correct line of API calls in order to implement such a program?

  • ffmpeg progess bar not giving percent

    3 décembre 2014, par Brett

    Hi im trying to create a java program that shows the percent of a ffmpeg command , Im not sure where i am going wrong.

    Its keeps giving me these results

    run: Total duration: 857.44 seconds. Progress: 0.85% Progress: 1.76% Progress: 2.79% Progress: 3.93% Progress: 5.04% Progress: 6.21% Progress: 6000.27% Progress: 6001.29% Progress: 6002.46% Progress: 6003.58% Progress: 6004.59% Progress: 6005.70% Progress: 6006.77% Progress: 12000.86% Progress: 12001.97% Progress: 12002.97% Progress: 12004.03% Progress: 12005.15% Progress: 12006.27% Progress: 18000.34% Progress: 18001.46% Progress: 18002.29% Progress: 18003.41% Progress: 18004.41% Progress: 18005.50% Progress: 18006.55% Progress: 24000.52% Progress: 24001.62% Progress: 24002.74% Progress: 24003.69% Progress: 24004.76% Progress: 24005.88% Progress: 24006.94% Progress: 30001.01% Progress: 30002.16% Progress: 30003.24% Progress: 30004.25% Progress: 30005.37% Progress: 30006.44% Progress: 36000.56% Progress: 36001.60% Progress: 36002.69% Progress: 36003.73% Progress: 36004.81% Progress: 36005.93% Progress: 42000.05% Progress: 42001.18% Progress: 42002.30% Progress: 42003.41% Progress: 42004.50% Progress: 42005.60% Progress: 42006.72% Progress: 48000.84% Progress: 48001.96% Progress: 48003.08% Progress: 48004.18% Progress: 48005.09% Progress: 48006.16% Progress: 54000.22% Progress: 54001.15% Progress: 54002.20% Progress: 54003.30% Progress: 54004.42% Progress: 54005.49% Progress: 54006.38% Progress: 60000.45% Progress: 60001.57% Progress: 60002.55% Progress: 60003.64% Progress: 60004.66% Progress: 60005.62% Progress: 60006.72% Progress: 66000.67% Progress: 66001.73% Progress: 66002.75% Progress: 66003.61% Progress: 66004.71% Progress: 66005.82% Progress: 66006.81% Progress: 72000.67% Progress: 72001.73% Progress: 72002.80% Progress: 72003.87% Progress: 72004.81% Progress: 72005.71% Progress: 72006.69% Progress: 78000.73% Progress: 78001.82% Progress: 78002.91% Progress: 78003.91% Progress: 78004.98% Progress: 78005.88% Progress: 78006.49% Progress: 84000.37% Progress: 84001.12% Progress: 84002.04% BUILD SUCCESSFUL (total time: 49 seconds)

    But the file is created , i don't know why im getting 0.00% any help would be awsome .. It also complains some imports a not being used here are the imports.

    here is my code

    import java.io.IOException;
    import java.util.Scanner;
    import static java.util.logging.Level.parse;
    import java.util.regex.Pattern;
    import javafx.util.Duration;
    import static javax.management.Query.lt;
    /**
     *
     * @author brett
     */
    
    public class MashMeUp {
    
        public static void main(String[] args) throws IOException {
            ProcessBuilder pb = new ProcessBuilder("ffmpeg", "-i", "C:\\Users\\brett\\Documents\\Telegraph_Road.mp4", "C:\\Users\\brett\\Documents\\out.mp4");
    
            // ProcessBuilder pb = new ProcessBuilder(args);  
            final Process p = pb.start();
    
        // create a new thread to get progress from ffmpeg command , override  
            // it's run method, and start it!  
            new Thread() {
                public void run() {
    
                    Scanner sc = new Scanner(p.getErrorStream());
    
                    // Find duration  
                    Pattern durPattern = Pattern.compile("(?<=Duration: )[^,]*");
                    String dur = sc.findWithinHorizon(durPattern, 0);
                    if (dur == null) {
                        throw new RuntimeException("Could not parse duration.");
                    }
                    String[] hms = dur.split(":");
                    double totalSecs = Integer.parseInt(hms[0]) * 3600
                            + Integer.parseInt(hms[1]) * 60
                            + Double.parseDouble(hms[2]);
                    System.out.println("Total duration: " + totalSecs + " seconds.");
    
                    // Find time as long as possible.  
                    Pattern timePattern = Pattern.compile("(?<=time=)[\\d:.]*");
                    // TODO make regex that works with ffmpeg static build  
                    String match;
                    String[] matchSplit;
    while (null != (match = sc.findWithinHorizon(timePattern, 0))) {
        matchSplit = match.split(":");
        double progress = Double.parseDouble(matchSplit[2]) / totalSecs +  Integer.parseInt(matchSplit[0]) * 3600 + Integer.parseInt(matchSplit[1]) * 60;
                        System.out.printf("Progress: %.2f%%%n", progress * 100);
                    }
                }
            }.start();
        }
    }
    
  • concatenate video files using ffmpeg - garbled images but audio okay

    2 décembre 2014, par anonygrits

    I am trying to concatenate video files so that next one follows the one before it when it is played. The formatting for all of the files are the same. The files all have audio & video.

    I think I am very close (hopefully!) to getting this to work, but I have one final problem. The command below takes all of the mp4 files in my folder and creates a big mp4 file, which is the right size in total MB, but the images for all videos after the first video are garbled. The audio is okay (continues just fine from video to video). Also, I don't get any error messages.

    ffmpeg -f concat -i <(for f in /folder1/*.mp4; do echo "file '$f'"; done) -c copy /folder1/all.mp4
    

    I'm not very familiar with ffmpeg yet, so I've just been trying the different suggestions I've found on the web. Can anyone suggest other things for me to try? (I've tried reading the FAQs, but I have to confess that I don't fully understand it. Also, there seems to be some posts about audio being missing after concatenation, but I haven't seen anything on images being garbled.) Thx in advance!

  • how to create video thumbnail on shared server with ffmpeg ?

    2 décembre 2014, par Manjeet Barnala

    hiii .. this code is working on my localhost for creating video thumbnail. plz tell me how to enable the FFMPEG on shared server where to place FFMPEG files any idea ????

    <?php 
    $ffmpeg = 'ffmpeg.exe';
     // the input video file
    $video = 'video/test_video.flv';
     // where you'll save the image
    $image = 'thumb/test_thumb.jpg';
    //time to take screenshot at  
    $interval = 5;  
    //screenshot size  
    $size = '500x500';  
    //ffmpeg command  
    $cmd = "$ffmpeg -i $video -deinterlace -an -ss $interval -f mjpeg -t 1 -r 1 -y -s $size $image 2>&1";
    exec($cmd);
    echo 'done!';
    ?>
    
  • Android and JNI, pipe data to FFmpeg

    2 décembre 2014, par William Seemann

    I'm trying to create a metadata retriever based on FFmpeg. Since raw Android application resources are often only accessible using a file descriptor I need a way to pipe this data to FFmpeg via JNI. I know FFmpeg supports a "pipe" protocol:

    UNIX pipe access protocol.
    
    Allow to read and write from UNIX pipes.
    
    The accepted syntax is: 
    
        pipe:[number]
    
    number is the number corresponding to the file descriptor of the pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr). If number is not specified, by default the stdout file descriptor will be used for writing, stdin for reading.
    
    For example: cat test.wav | ffmpeg -i pipe:0
    

    My question is, how do I programmatically emulate cat test.wav | ffmpeg -i pipe:0 using JNI and avformat_open_input using a FileDescriptor? Is this possible?