我尝试使用trim effect并传递args。它有时成功地产生修剪过音频文件,有时又不成功。但它会按如下方式打印消息
wav: Premature EOF on .wav input file或
trim: Last 28998360 position(s) not reached (audio shorter than expected).下面是我写的代码
sox_format_t* in = sox_open_read(inputFile, NULL, NULL, NULL);
printFormat(in);
sox_format_t* out = sox_open_write(outputFile, &in->signal, NULL, NULL, NULL, NULL);
sox_effects_chain_t* chain = sox_create_effects_chain(&in->encoding , &out->encoding);
char* args[5];
sox_effect_t* inputEffect = sox_create_effect(sox_find_effect("input"));
args[0] = (char *) in;
sox_effect_options(inputEffect, 1, args);
sox_add_effect(chain, inputEffect, &in->signal, &in->signal);
sox_delete_effect(inputEffect);
sox_effect_t* trimEffect = sox_create_effect(sox_find_effect("trim"));
args[0] = "0";
args[1] = "1";
sox_effect_options(trimEffect, 2, args);
sox_add_effect(chain, trimEffect, &in->signal, &in->signal);
sox_delete_effect(trimEffect);
sox_effect_t* outputEffect = sox_create_effect(sox_find_effect("output"));
args[0] = (char *) out;
sox_effect_options(outputEffect,1, args) ;
sox_add_effect(chain,outputEffect,&in->signal,&out->signal);
sox_delete_effect(outputEffect);
sox_flow_effects(chain,NULL,NULL);我该怎么做才能避免这种情况
发布于 2021-07-16 16:21:28
我想我知道为什么有时不能产生音频文件。这是因为我每次将效果添加到链中时都会删除它。但我仍然不知道如何避免过早的EOF警告
https://stackoverflow.com/questions/68405291
复制相似问题