Skip to content

ip/ffmpeg: fix seeking and compiler warning about %lld - #1454

Merged
flyingmutant merged 2 commits into
cmus:masterfrom
ihy123:ffmpeg
Oct 5, 2025
Merged

flyingmutant merged 2 commits into
cmus:masterfrom
ihy123:ffmpeg

Conversation

@ihy123

@ihy123 ihy123 commented Sep 28, 2025

Copy link
Copy Markdown
Contributor

About %lld

3157b78 introduced a warning about %lld on GCC. @thecloudexpanse try this PR with your compiler please

Results of the seeking fix

Before:

ffmpeg_calc_skip_samples: seek_ts: 98.673288s, frame_ts: 97.985306s
ffmpeg_skip_frame_part: skipping frame: 1152 samples
... 24 more ...
ffmpeg_skip_frame_part: skipping frame: 1152 samples
ffmpeg_skip_frame_part: skipping 388 samples

After:

ffmpeg_calc_skip_samples: seek_ts: 98.673288s, frame_ts: 98.664490s
ffmpeg_skip_frame_part: skipping 388 samples

%lld expects long long but int64_t may be long. And GCC warns about that

@thecloudexpanse thecloudexpanse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly casting to (long long) fixes the issue, so the value will match the format specifier. Apologies for missing that. I verified that this compiles cleanly with clang.

For what it's worth, changing the format specifier back to %ld and casting the value to (long) also eliminates the original warning on clang. However, since the value is a 64-bit int, I think (long long) is probably preferred.

@pgaskin pgaskin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeking works fine with fewer discards required. If I'm understanding/observing it correctly, it's more of an optimization than a fix (so I'd probably recommend updating the commit message to say that). Thoughts, @ihy123?

Format string thing is fine (and it's for debug logs only anyways). The correct solution would be to use PRId64, but cmus doesn't really do that.

@ihy123

ihy123 commented Oct 4, 2025

Copy link
Copy Markdown
Contributor Author

changing the format specifier back to %ld and casting the value to (long)

The correct solution would be to use PRId64

IMO it's what works best for compatibility. skip_samples would easily fit into an int and %d could be used. I honestly don't care, so whatever you say, @pgaskin.

so I'd probably recommend updating the commit message to say that

No problem

av_rescale() accepts int64_t, so offset was implicitly converted
and rounded down to an integer number of seconds which has been causing
more samples to be discarded to reach the wanted time.
@flyingmutant
flyingmutant merged commit 2c9c109 into cmus:master Oct 5, 2025
@ihy123
ihy123 deleted the ffmpeg branch October 25, 2025 15:49
@BrewTestBot BrewTestBot mentioned this pull request Oct 28, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants