Recherche avancée

Médias (2)

Mot : - Tags -/map

Autres articles (52)

Sur d’autres sites (8016)

  • How to speed up my video creating/encoding pipeline

    23 septembre 2015, par user606521

    I am creating a video from 120 JPEG images and concatening it with intro video.

    • video (and images) dimmensions : 960x540
    • video/audio output format that I need : mp4 H.264, AAC

    I am creating video from JPEG images using following command :

    ffmpeg -f lavfi -i anullsrc -r 60 -i pipe:0 -y -acodec aac -strict experimental \
    -shortest -movflags frag_keyframe+empty_moov -f mp4 video.mp4

    It creates 2 seconds (120 frames with 60FPS) mp4 video with "silence" (silent audio). video.mp4 size is 94KB. This process takes 1 second. (Note that I am passing images through pipe:0).

    Next I concatenate it with existing intro.mp4 video (H.264, AAC, 931KB, lasts 6 seconds) using following command :

    ffmpeg -i intro.mp4 -i video.mp4 -y \
    -filter_complex "[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]" \
    -map "[v]" -map "[a]" -acodec aac -strict experimental \
    -movflags frag_keyframe+empty_moov -f mp4 final.mp4

    It creates final mp4 H.254, AAC video which lasts 2 + 6 = 8 seconds and it’s size 990KB. This process takes 3.5 seconds.

    So the whole process takes 5.5 seconds on my Mac. I have to speed it up, especially concatening videos. I am not familiar with video encoding and video formats, but I thought that maybe creating first video in mp4 and then concatening it with another mp4 video is not efficient. Are there any other formats in which I could create video (and intro) that will be faster to create/concatenate so I could encode only final video as mp4 ?

    For example I could create video.<format></format>, concatenate it with intro.<format></format> and finally encode it as final.mp4.

    Use case : I have to create videos in almost real time. 5.5 secs is ok on my Mac, but I have to execute my app on a weaker machine on which this process currently takes 3 + 15 = 18 seconds.

    Also maybe there are some cool flags I could pass to ffmpeg to make it faster ?

  • ffmpeg ProcessBuilder No such file or directory

    24 avril 2020, par silentsudo

    I am trying to get media duration using ffmpeg command from a java program. I am calling this method from within spring boot application.&#xA;I am using ProcessBuilder.

    &#xA;&#xA;

    File object is valid and exists for privacy I have replaced file path in error logs.

    &#xA;&#xA;

    My Code is as below :

    &#xA;&#xA;

    private String getMediaDuration(File file) {&#xA;        final String command = "/usr/bin/ffmpeg -version";//-i " &#x2B; file.getAbsolutePath() &#x2B; " 2>&amp;1 | grep Duration | cut -c 13-20";&#xA;        try {&#xA;            ProcessBuilder builder = new ProcessBuilder("/usr/bin/ffmpeg",&#xA;                    "-version");&#xA;            builder.directory(file.getParentFile());&#xA;&#xA;            System.out.println("Directory : " &#x2B; builder.directory().exists());&#xA;            System.out.println("Directory : " &#x2B; builder.directory().getAbsolutePath());&#xA;            final Process process = builder.start();&#xA;            final InputStream is = process.getInputStream();&#xA;            final InputStreamReader isr = new InputStreamReader(is);&#xA;            final BufferedReader br = new BufferedReader(isr);&#xA;            String line;&#xA;            while ((line = br.readLine()) != null) {&#xA;                System.out.println(line);&#xA;            }&#xA;            return line;&#xA;        } catch (Exception e) {&#xA;            e.printStackTrace();&#xA;        }&#xA;        return null;&#xA;    }&#xA;

    &#xA;&#xA;

    Unfortunately nothing seems to be working&#xA;Error below :

    &#xA;&#xA;

    java.io.IOException: Cannot run program "/usr/bin/ffmpeg -version" (in directory "/abc/xyz"): error=2, No such file or directory&#xA;    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)&#xA;    at ....getMediaDuration(FFmpegRunner.java:208)&#xA;    at ....ffmpegprocessor.FFmpegRunner.run(FFmpegRunner.java:61)&#xA;    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)&#xA;    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)&#xA;    at java.lang.Thread.run(Thread.java:748)&#xA;Caused by: java.io.IOException: error=2, No such file or directory&#xA;    at java.lang.UNIXProcess.forkAndExec(Native Method)&#xA;    at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)&#xA;    at java.lang.ProcessImpl.start(ProcessImpl.java:134)&#xA;    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)&#xA;    ... 5 more&#xA;</init>

    &#xA;&#xA;

    Output for whereis ffmpeg

    &#xA;&#xA;

    ffmpeg: /usr/bin/ffmpeg /usr/share/ffmpeg /usr/share/man/man1/ffmpeg.1.gz&#xA;

    &#xA;&#xA;

    Please help me understand where it is going wrong. Thank you.

    &#xA;

  • Can't write video using moviepy. output format error

    23 décembre 2022, par Ronnie Kisor

    I'm trying to concatenate videos in each folder so that I get one video in each folder instead of multiple short ones. This is an external USB drive if that matters.

    &#xA;

    My code seems to iterate over the files as expected, but I keep getting this error after the audio is written, during the "writing video" action, I believe : b"[NULL @ 000002a8340ae640] Unable to find a suitable output format for &#x27;D:\\taxes\\folder\\test&#x27;\r\nD:\\taxes\\folder\\test: Invalid argument\r\n"

    &#xA;

    I haven't found a way to force an output format yet. Any thoughts ?

    &#xA;

    import os&#xA;from moviepy.editor import *&#xA;&#xA;startingDir = r&#x27;D:\taxes&#x27;&#xA;&#xA;avoid = [&#x27;0incomplete&#x27;, &#x27;old&#x27;, &#x27;that&#x27;, &#x27;this&#x27;]&#xA;&#xA;for thing in os.listdir(startingDir):&#xA;    clips = []&#xA;    name = &#x27;&#x27;&#xA;    &#xA;    if thing in avoid:&#xA;        print(&#x27;                              avoided {}&#x27;.format(thing))&#xA;        continue&#xA;&#xA;    folder = os.path.join(startingDir, thing)&#xA;&#xA;    if os.path.isdir(folder):&#xA;        for clip in os.listdir(folder):&#xA;            print (clip)&#xA;            clips.append(VideoFileClip(os.path.join(folder, clip)))&#xA;        print(&#x27;\n&#x27;)&#xA;&#xA;        try:&#xA;            final = concatenate_videoclips(clips)&#xA;            final.write_videofile(os.path.join(folder, &#x27;test&#x27;), audio=True, codec=&#x27;libx264&#x27;, threads=10)&#xA;            final.close() &#xA;        except Exception as e:&#xA;            print (e)&#xA;            print(&#x27;\n Continuing... \n\n&#x27;)&#xA;            continue&#xA;

    &#xA;