Recherche avancée

Médias (1)

Mot : - Tags -/publier

Sur d’autres sites (120)

  • Filter concat has an unconnected output while Video concatenation in ffmpeg wrapper in java

    28 février, par Thor

    I am trying to stitch variable number of videos using ffmpeg wrapper.

    


    I have this code :

    


    private void videoStich(List<string> videoPaths){&#xA;        FFmpeg ffmpeg = null;&#xA;        FFprobe ffprobe=null;&#xA;        String stitchedOutputPath = outputFolder &#x2B; "/stitched_output.mp4";&#xA;&#xA;        try {&#xA;            ffmpeg = new FFmpeg();&#xA;            ffprobe = new FFprobe();&#xA;        } catch (IOException e) {&#xA;            throw new RuntimeException(e);&#xA;        }&#xA;&#xA;&#xA;        FFmpegBuilder builder = new FFmpegBuilder();&#xA;&#xA;        for (int i = 0; i &lt; videoPaths.size(); i&#x2B;&#x2B;) {&#xA;            String videoPath = videoPaths.get(i);&#xA;            builder.addInput(videoPath);&#xA;        }&#xA;&#xA;        // Add complex filter for concatenation&#xA;        StringBuilder complexFilter = new StringBuilder();&#xA;        for (int i = 0; i &lt; videoPaths.size(); i&#x2B;&#x2B;) {&#xA;            complexFilter.append("[").append(i).append(":v][").append(i).append(":a]");&#xA;//            if (i &lt; videoPaths.size() - 1) {&#xA;//                complexFilter.append("[");&#xA;//            }&#xA;        }&#xA;        complexFilter.append("concat=n=").append(videoPaths.size()).append(":v=1:a=1[v][a]");&#xA;&#xA;        builder.setComplexFilter(complexFilter.toString())&#xA;                .addOutput(stitchedOutputPath)&#xA;                .setFormat("mp4")&#xA;                .done();&#xA;&#xA;        FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);&#xA;        executor.createJob(builder).run();&#xA;    }&#xA;</string>

    &#xA;

    but getting this error :

    &#xA;

    2024-02-28T16:30:53.033&#x2B;05:30  INFO 4711 --- [sample_project] [pool-3-thread-1] net.bramp.ffmpeg.RunProcessFunction      : ffmpeg -version&#xA;2024-02-28T16:30:53.126&#x2B;05:30  INFO 4711 --- [sample_project] [pool-3-thread-1] net.bramp.ffmpeg.RunProcessFunction      : ffmpeg -y -v error -i src/main/resources/cutted_videos/0_trimmed.mp4 -i src/main/resources/cutted_videos/1_trimmed.mp4 -filter_complex [0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[v][a] -f mp4 src/main/resources/cutted_videos/stitched_output.mp4&#xA;Filter concat has an unconnected output&#xA;java.lang.RuntimeException: java.io.IOException: ffmpeg returned non-zero exit status. Check stdout.&#xA;

    &#xA;

    I have been trying to fix this since a long time and didn't find any issue with the filter, it is looking good to me. Can anyone help me with it ?

    &#xA;

    EDIT :&#xA;I found that when I use this command in terminal :

    &#xA;

    ffmpeg -i in1.mp4 -i in2.mp4\&#xA;            -filter_complex "[0:v] [0:a] [1:v] [1:a] \&#xA;concat=n=2:v=1:a=1 [v] [a]" \&#xA;            -f mp4  output_test5.mp4&#xA;

    &#xA;

    it didn ;t work&#xA;while when i used this :

    &#xA;

    ffmpeg -i in1.mp4 -i in2.mp4\&#xA;            -filter_complex "[0:v] [0:a] [1:v] [1:a] \&#xA;concat=n=2:v=1:a=1 [v] [a]" \&#xA;            -f mp4 -map "[v]" -map "[a]" output_test4.mp4&#xA;

    &#xA;

    it worked. I think i need to add -map "[v]" -map "[a]" somehow in the code.

    &#xA;

    but when i try to add :&#xA;builder.setComplexFilter(complexFilter.toString())&#xA;.addOutput(stitchedOutputPath)&#xA;.setFormat("mp4")&#xA;.map()&#xA;.done() ;

    &#xA;

    or

    &#xA;

    builder.setComplexFilter(complexFilter.toString())&#xA;.addOutput(stitchedOutputPath)&#xA;.setFormat("mp4")&#xA;.setMap()&#xA;.done() ;

    &#xA;

    both .set() or setMap() doesn't exist. What to do, how to do ?

    &#xA;

  • Yet another ffmpeg concat audio sync issue [closed]

    15 mars, par Demiurg

    I've read through dozens of posts, tried many suggestions, nothing seems to work for me. The funny part is that the video is fine in some players (e.g. Quicktime) but not the others (e.g. Chrome).

    &#xA;

    This is what I currently use :

    &#xA;

    ffmpeg -i segment.mp4 -q 0 -c copy segment.ts&#xA;ffmpeg -f concat -i videos.txt -c copy -y final.mp4&#xA;

    &#xA;

    This is what ffmpeg shows for the originals

    &#xA;

    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;52M35S_1710280355.mp4&#x27;:&#xA;  Metadata:&#xA;    major_brand     : mp42&#xA;    minor_version   : 0&#xA;    compatible_brands: mp42isom&#xA;    creation_time   : 2024-03-12T21:53:35.000000Z&#xA;  Duration: 00:00:59.86, start: 0.000000, bitrate: 851 kb/s&#xA;  Stream #0:0[0x1](und): Audio: opus (Opus / 0x7375704F), 48000 Hz, mono, fltp, 10 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2024-03-12T21:53:35.000000Z&#xA;      vendor_id       : [0][0][0][0]&#xA;  Stream #0:1[0x2](und): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 1920x1080, 836 kb/s, 10.02 fps, 10 tbr, 90k tbn (default)&#xA;    Metadata:&#xA;      creation_time   : 2024-03-12T21:53:35.000000Z&#xA;      vendor_id       : [0][0][0][0]&#xA;

    &#xA;

  • FFmpeg : Specify pixel format for STD_IN input

    27 février, par ShadowMagic896

    This is the current command :

    &#xA;

    ffmpeg -i pipe:0 -pix_fmt yuv420p -f mp4 -vf "transpose=1" -f matroska pipe:1

    &#xA;

    Essentially, it takes an MP4 file, rotates it 90 degrees, and converts it back to mtk and outputs it to STD_OUT.

    &#xA;

    This is the error :

    &#xA;

    WARNING:root:[mov,mp4,m4a,3gp,3g2,mj2 @ 000001ff9979dd00] stream 0, offset 0x50: partial file&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 000001ff9979dd00] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 170x144, 32 kb/s): unspecified pixel format&#xA;Consider increasing the value for the &#x27;analyzeduration&#x27; (0) and &#x27;probesize&#x27; (5000000) options&#xA;Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;pipe:0&#x27;:&#xA;  Metadata:&#xA;    major_brand     : mp42&#xA;    minor_version   : 0&#xA;    compatible_brands: mp41isom&#xA;    creation_time   : 2024-02-26T20:53:03.000000Z&#xA;  Duration: 00:00:03.88, start: 0.000000, bitrate: N/A&#xA;  Stream #0:0[0x1](und): Video: h264 (avc1 / 0x31637661), none, 170x144, 32 kb/s, 30 fps, 30 tbr, 30k tbn (default)&#xA;      Metadata:&#xA;        creation_time   : 2024-02-26T20:53:03.000000Z&#xA;        handler_name    : VideoHandler&#xA;        vendor_id       : [0][0][0][0]&#xA;        encoder         : AVC Coding&#xA;  Stream #0:1[0x2](und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s (default)&#xA;      Metadata:&#xA;        creation_time   : 2024-02-26T20:53:03.000000Z&#xA;        handler_name    : SoundHandler&#xA;        vendor_id       : [0][0][0][0]&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))&#xA;  Stream #0:1 -> #0:1 (aac (native) -> vorbis (libvorbis))&#xA;[mov,mp4,m4a,3gp,3g2,mj2 @ 000001ff9979dd00] stream 0, offset 0x50: partial file&#xA;[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 000001ff9978b080] Error during demuxing: Invalid data found when processing input&#xA;Cannot determine format of input 0:0 after EOF&#xA;[vf#0:0 @ 000001ff997d6040] Task finished with error code: -1094995529 (Invalid data found when processing input)&#xA;[vf#0:0 @ 000001ff997d6040] Terminating thread with return code -1094995529 (Invalid data found when processing input)&#xA;[aost#0:1/libvorbis @ 000001ff99cd1780] No filtered frames for output stream, trying to initialize anyway.&#xA;[vost#0:0/libx264 @ 000001ff997d4fc0] Could not open encoder before EOF&#xA;[vost#0:0/libx264 @ 000001ff997d4fc0] Task finished with error code: -22 (Invalid argument)&#xA;[vost#0:0/libx264 @ 000001ff997d4fc0] Terminating thread with return code -22 (Invalid argument)&#xA;[out#0/matroska @ 000001ff997a6180] Nothing was written into output file, because at least one of its streams received no packets.&#xA;frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/A    &#xA;Conversion failed!&#xA;

    &#xA;

    I am running this via Python, this is the script :

    &#xA;

        async def send_proc_pipe(self) -> bytes:&#xA;&#xA;        command = f"ffmpeg -hide_banner -loglevel error -i pipe:0 -pix_fmt yuv420p -f mp4 -vf \"transpose=1\" -f matroska pipe:1"&#xA;&#xA;        proc = await asyncio.create_subprocess_shell(&#xA;            cmd=command,&#xA;            stdin=asyncio.subprocess.PIPE,&#xA;            stdout=asyncio.subprocess.PIPE,&#xA;            stderr=asyncio.subprocess.PIPE&#xA;        )&#xA;        &#xA;        std_in = self.blob&#xA;&#xA;        c_out, c_err = await proc.communicate(std_in)&#xA;        if c_err:&#xA;            logging.warning(c_err.decode("utf-8"))&#xA;&#xA;        return c_out&#xA;

    &#xA;

    I'm not really use what else to try here. I've re-ordered the parameters and tried different pixel formats with no success.

    &#xA;