简体   繁体   English

FFmpeg音频不同步问题

[英]FFmpeg Audio Desync Issue

I've seen tons of threads about these but nothing seems to have changed for my problem. 我已经看到了很多关于这些的线程,但是似乎对于我的问题没有任何改变。

Currently inside my Java program, I am calling the command line and using this command. 当前在我的Java程序中,我正在调用命令行并使用此命令。

ProcessBuilder builder = new 
                 ProcessBuilder(
                         "cmd.exe", "/c", "ffmpeg -y -i " + "\"" + inputFile + "\" -vcodec libx264 -async 1 -f mp4 " + " -ss " + offset + " -c copy -t " + duration + " " + "\"" + outputFile + "\"");

Originally -vcodec, -async, and -f mp4 weren't there but in efforts to hopefully correct the audio, they have been placed there. 最初不存在-vcodec,-async和-f mp4,但是为了希望更正音频,它们已放置在此处。

The audio is lagged by about ~1-2 seconds, I was wondering if anyone had any ideas? 音频滞后了大约1-2秒,我想知道是否有人有任何想法? I've also tried to manually set the frame rate which still hasn't worked. 我也尝试过手动设置仍然无法使用的帧速率。

Here is another failed attempt. 这是另一次失败的尝试。

ProcessBuilder builder = new 
                 ProcessBuilder(
                         "cmd.exe", "/c", "ffmpeg -y -i " + "\"" + inputFile + "\" -vcodec libx264 -async 1 -acodec libfaac -ab 128k -ac 2 -bt 5000k -b 5000k -r 59.940 -threads 0 -f mp4 " + " -ss " + offset + " -c copy -t " + duration + " " + "\"" + outputFile + "\"");

Input & Output files along with Offset and Duration are all fine, please don't question this. 输入和输出文件以及“偏移”和“持续时间”都很好,请不要对此提出疑问。

Quick edit! 快速编辑!

The input file will always have the extension .flv 输入文件将始终具有扩展名.flv

Another EDIT When I remove the offset and duration arguments and use copyts instead, the entire file is converted to mp4 AND the audio is synced. 另一个编辑当我删除offset和duration参数并使用copyts时,整个文件将转换为mp4,并且音频将同步。 The issue seems to lie in the offset and duration since I tried copyts before with the two but it still was desync'd. 问题似乎出在偏移量和持续时间上,因为我之前尝试过两次复制和复制,但是仍然不同步。

Current 当前

ProcessBuilder builder = new 
                 ProcessBuilder(
                         "cmd.exe", "/c", "ffmpeg -y -i " + "\"" + inputFile + "\"" + " -c copy -copyts " + "\"" + outputFile + "\"");

In your original command (the one at the top), replace -c copy with -c:a copy . 在原始命令(顶部的命令)中,将-c copy替换为-c:a copy You can get rid of the -async 1 . 您可以摆脱-async 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM