Commit d2afde6e authored by Stefan Westerfeld's avatar Stefan Westerfeld

testhls: improved rounding for ffmpeg frame cut (start/duration)

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 64135429
......@@ -106,13 +106,14 @@ ff_encode (const WavData& wav_data, const string& filename, size_t start_pos, si
double length_s = double (wav_data.n_values()) / wav_data.n_channels() / wav_data.sample_rate();
/* subtracting 0.001 from cut_start_s ensures that rounding performed by printf()
* doesn't accidentally cut one frame more than necessary
/* subtracting/adding 0.000001 from/to cut_start_s ensures that rounding
* performed by printf() doesn't accidentally cut one frame more or less than
* intended
*/
double cut_start_s = cut_start / double (wav_data.sample_rate()) - 0.001;
double cut_start_s = cut_start / double (wav_data.sample_rate());
double cut_end_s = cut_end / double (wav_data.sample_rate());
cmd = string_printf ("ffmpeg -v error -y -i '%s' -ss %.3f -t %.3f -f mpegts -output_ts_offset %f -muxdelay 0 -muxpreload 0 -c copy '%s-tcpy'",
filename.c_str(), cut_start_s, length_s - (cut_start_s + cut_end_s), pts_start, filename.c_str());
cmd = string_printf ("ffmpeg -v error -y -i '%s' -ss %.6f -t %.6f -f mpegts -output_ts_offset %f -muxdelay 0 -muxpreload 0 -c copy '%s-tcpy'",
filename.c_str(), cut_start_s - 0.000001, length_s - (cut_start_s + cut_end_s) + 0.000001, pts_start, filename.c_str());
err = xsystem (cmd);
if (err)
return err;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment