Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to compile Youtube WatchMe ?

    8 juillet 2015, par forresthopkinsa

    I am trying to (roughly) replicate the Sony Xperia "Live on Youtube" app. Since it is exclusive to the Xperia line, I am trying to build an app out of the Youtube WatchMe source code.

    All I need is an app that can live stream video from the phone's camera to Youtube, as both of the apps mentioned above do. I know that WatchMe is meant to be nothing more than a reference for developers wanting to make apps that utilize this, but how possible would it be to modify the example code? I don't need a necessarily stable application, but something is better than nothing.

    It would help even more if anyone knew of an app that already contained this functionality.

  • Merge Multiple Videos using node fluent ffmpeg

    8 juillet 2015, par shyamshyre

    requirement is to read all the files in the directory and merge them. I am using node fluent-ffmpeg to achieve this. First of all reading all the files in the directory appending concatenating the string by adding .input.

    var finalresult="E:/ETV/videos/finalresult.mp4"
    outputresult : It consists of all the files read in the directory.
    
    /*Javascript*/
    MergeVideo(outputresult);
    function MergeVideo(outputresult){
    console.log("in merge video");
    var videostring = "";
    
    for(i=1;i<5;i++)
        {
    videostring = videostring+".input("+"'"+outputresult[i]+"'"+")";
    }
    console.log("Video String"+videostring);
        var proc = ffmpeg()+videostring
        .on('end', function() {
          console.log('files have  succesfully Merged');
            })
        .on('error', function(err) {
          console.log('an error happened: ' + err.message);
        })
        .mergeToFile(finalresult);
    }
    

    It gives the following error:

    TypeError: Object .input('ETV 22-02-2015 1-02-25 AM.mp4').input('ETV 22-02-2015
    9-33-15 PM.mp4').input('ETV 22-02-2015 9-32-46 AM.mp4').input('ETV 22-02-2015 8-
    32-44 AM.mp4') has no method 'on'
        at MergeVideo (D:\Development\Node\node-fluent-ffmpeg-master\node-fluent-ffm
    peg-master\examples\demo.js:140:6)
        at Object. (D:\Development\Node\node-fluent-ffmpeg-master\node-fl
    uent-ffmpeg-master\examples\demo.js:129:1)
        at Module._compile (module.js:456:26)
    

    Any help is appreciated.

  • Writing data to a Node.js child process's stdin fails due to ECONNRESET

    8 juillet 2015, par Swoth

    Problem
    Passing data to a child process's stdin seems to fail. It fails due to an ECONNRESET after writing the data.

    Context
    I am developing a small programm that is supposed to render a video, as fast as possible, based on frames captured from a canvas. The animation is rendered to a headless canvas implementation using Rekapi (JavaScript animation framework). The headless canvas is a Node.js module called node-canvas by Automattic. The animation frames are rendered one after another, after each rendering the frame is retrieved using canvas.getImageData().data (Uint8ClampedArray - rgba, faster than canvas.toDataUrl) and put into an array. Every frame is supposed to be send to ffmpeg to create a video.

    Rekapi -> canvas -> getImageData -> array -> ffmpeg

    What I do
    I already tried various possibilities to pipe that data to ffmpeg. In general I created a child process in Node.js executing ffmpeg:

    var spawn = require('child_process').spawn;    
    var child = spawn('ffmpeg', [
            '-pix_fmt', 'rgba',
            '-s','1280x720',
            '-r', 25,
            '-f', 'rawvideo',
            '-vcodec', 'rawvideo',
            '-i', '-', // read frames from stdin
            '-threads', 0, // use all cores
            'test.mpg']);
    

    Now I write my array data to the child's stdin:

    for(var i = 0; i < dataArray.length; ++i){
        var buffer = new Buffer(dataArray[i]);
        child.stdin.write(buffer);
        console.log('wrote: ' + i);
    }
    

    I wrote 25 frames this way. The console displays the following:

    wrote: 24
    wrote: 25
    events.js:85
          throw er; // Unhandled 'error' event
                ^
    Error: read ECONNRESET
        at exports._errnoException (util.js:746:11)
        at Pipe.onread (net.js:559:26)
    

    ffmpeg generated a 0 byte test.mpg. I am very new to Node.js, thus I might not understand the big picture of it's child processes.

  • Saving video using matplotlib results in WinError 5 [duplicate]

    8 juillet 2015, par Chris

    This question already has an answer here:

    Using matplotlib it should be possible to animate videos and save them as mpeg. I have found a few tips and tricks on the web but I was not able to get it to work on my Windows 7 machine running Python 3.4. Here are two examples that I found on the web that both give me an exeption PermissionError: [WinError 5] Permission denied:

    import numpy as np
    from matplotlib import pyplot as plt
    from matplotlib import animation
    plt.rcParams['animation.ffmpeg_path'] = r'C:\Users\me\Desktop\ffmpeg-latest-win64-static\ffmpeg-20150702-git-03b2b40-win64-static\bin'
    
    metadata = dict(title='Movie Test', artist='Matplotlib',
            comment='Movie support!')
    writer = animation.FFMpegWriter(fps=15, metadata=metadata)
    
    fig = plt.figure()
    l, = plt.plot([], [], 'k-o')
    
    plt.xlim(-5, 5)
    plt.ylim(-5, 5)
    
    x0,y0 = 0, 0
    
    with writer.saving(fig, "writer_test.mp4", 100):
        for i in range(100):
            x0 += 0.1 * np.random.randn()
            y0 += 0.1 * np.random.randn()
            l.set_data(x0, y0)
            writer.grab_frame()
    

    And this one throws the same exeption:

    import numpy as np
    from matplotlib import pyplot as plt
    from matplotlib import animation
    plt.rcParams['animation.ffmpeg_path'] = r'C:\Users\wiesmeyrc\Desktop\ffmpeg-latest-win64-static\ffmpeg-20150702-git-03b2b40-win64-static\bin'
    
    fig = plt.figure()
    ax = plt.axes(xlim=(0, 2), ylim=(-2, 2))
    line, = ax.plot([], [], lw=2)
    
    def init():
        line.set_data([], [])
        return line,
    
    def animate(i):
        x = np.linspace(0, 2, 1000)
        y = np.sin(2 * np.pi * (x - 0.01 * i))
        line.set_data(x, y)
        return line,
    
    anim = animation.FuncAnimation(fig, animate, init_func=init, frames=200, interval=20, blit=True)
    
    FFwriter = animation.FFMpegWriter()
    anim.save('basic_animation.mp4', writer = FFwriter, fps=30, extra_args=['-vcodec', 'libx264'])
    

    [EDIT]: Here is the full stack trace:

    Traceback (most recent call last):
      File ".\matplotlib_animation.py", line 37, in 
        with writer.saving(fig, r'C:\Users\wiesmeyrc\Documents\Python Scripts\basic_animation.mp4', 100):
      File "C:\Anaconda3\lib\contextlib.py", line 59, in __enter__
        return next(self.gen)
      File "C:\Anaconda3\lib\site-packages\matplotlib\animation.py", line 186, in saving
        self.setup(*args)
      File "C:\Anaconda3\lib\site-packages\matplotlib\animation.py", line 176, in setup
        self._run()
      File "C:\Anaconda3\lib\site-packages\matplotlib\animation.py", line 204, in _run
        creationflags=subprocess_creation_flags)
      File "C:\Anaconda3\lib\subprocess.py", line 858, in __init__
        restore_signals, start_new_session)
      File "C:\Anaconda3\lib\subprocess.py", line 1111, in _execute_child
        startupinfo)
    PermissionError: [WinError 5] Zugriff verweigert
    
  • I can't overlay and center a video on top of an image with ffmpeg. The output is 0 seconds long

    8 juillet 2015, par Magicomiralles

    I have an mp4 that I want to overlay on top of a jpeg. The command I'm using is:

    Ffmpeg -y -i background.jpg -i video.mp4 -filter_complex "overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -codec:a copy output.mp4
    

    But for some reason, the output is 0 second long but the thumbnail does show the first frame of the video centred on the image properly.

    I have tried using -t 4 to set the output's length to 4 seconds but that does not work.

    I am doing this on windows.