144 Commits
Author SHA1 Message Date
Michael Niedermayer eceaa54a38 ffplay: report an event that could not be pushed
A stream whose event the event loop never hears of stays pending, so
say when that happens.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer 4c838cbfa1 ffplay: list directories and play files chosen from the list
The o key lists the directory of the input, local or remote, in the
list. Enter or a click lists the chosen directory or plays the chosen
file instead of the input once it opened, so a file that is no media
leaves the input playing. Directories come first, hidden entries are
left out, and the popup of a file shows its size.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer 8fdf7f7241 ffplay: keep the list in the window instead of the VideoState
The list is an overlay of the window, so one list serves whatever
stream is playing.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer 2ead3d0bdd cosmetics: ffplay: drop the scope of the audio filter setup
Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer c74f97bcd8 ffplay: factor starting the audio output out of stream_component_open()
The audio device is opened once the audio decoder is set up, and a
failure to start the audio output closes the audio stream again.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer c060100ff3 ffplay: start the packet queue of a decoder when initializing it
This allows queuing the packets of a decoder before its thread starts.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer b6964c210c ffplay: remember the key that pins a list instead of a chapter list flag
Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer e5fc67dd1f ffplay: mark the events of a stream with its id
The event loop quits only on a quit event of the stream playing, so
that events of another stream can be told apart.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer b1277e727a ffplay: keep the audio device and its callback time in the VideoState
So that each open input plays through its own device.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer eb2a565071 ffplay: count the loops of each input
-loop was counted down in the global option, so a later input played
only the loops the first one left.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer c31578d6c3 ffplay: open every input with the given format options
avformat_open_input() replaces the dictionary it is given with the
options it did not use, which left the global format options without
the recognized ones after the first input. Each input is opened with a
copy now.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer b7d7233d4e ffplay: keep the startup volume in percent
stream_open() replaced the -volume percentage with the SDL volume it
computed from it, so a second stream would compute its volume from the
first stream's.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer fdc94e411e ffplay: keep what is decided for an input in its VideoState
The window title taken from the input's metadata, seeking by bytes and
the unlimited buffering of realtime inputs were decided once into
globals; they are kept per VideoState now, so that another input
decides them anew. The title string is freed with the stream.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
Michael Niedermayer bec872cc34 ffplay: move the chapter list into its own file
The list becomes a ListView in ffplay_list.c, which shows entries with
title, artist, length and metadata and reports the entry the user
chooses; ffplay builds the entries from the chapters and seeks to the
chosen one. The sort order moves from globals into the ListView.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
romainhedouin 231ce8136e ffplay: compute 1/sqrt(nb_freq) once outside the row loop
The value is the same for every row. No change in behaviour.

Found during a code review sweep of ffmpeg using an LLM.
2026-10-17 18:41:09 +00:00
Michael Niedermayer 8d4d9e5449 ffplay: un-premultiply the chapter list without dividing every channel
A table of 16.16 reciprocals of the alpha values replaces the three
divisions per pixel and gives the same results.

Assisted-by: Claude
2026-10-13 22:12:55 +00:00
Michael Niedermayer 53ca051ffa ffplay: scroll the chapter list bitmap instead of rendering every row again
When the list scrolls, the pixels of the rows that stay visible are
moved together with their strips, so only the rows scrolling in and
those whose content changed are rendered. Rows the popup covered are
rendered anew, as their pixels moved with the popup's.

Assisted-by: Claude
2026-10-13 22:12:55 +00:00
Michael Niedermayer 6d5667ead8 ffplay: wake up for input events instead of sleeping until the next refresh
The event loop slept up to REFRESH_RATE between refreshes while input
waited in the queue; waiting for an event with the same timeout handles
input as soon as it arrives.

Assisted-by: Claude
2026-10-13 22:12:55 +00:00
Michael Niedermayer 5e3e33501a ffplay: move the chapter list selection without rebuilding the rows
The rows are rebuilt and sorted whenever the list is shown; moving the
selection by key or wheel within the visible list only needs the new
selection, not another rebuild over all chapters.

Assisted-by: Claude
2026-10-13 22:12:55 +00:00
Michael Niedermayer 2b7ca873b5 ffplay: render the chapter list once per frame
Input handlers only ask for a render, which happens once the pending
events are handled, so a burst of wheel clicks or key presses renders
the list once instead of once per event.

Assisted-by: Claude
2026-10-13 22:12:55 +00:00
Michael Niedermayer 72b992934c ffplay: render only the chapter list strips that changed
The list is kept in one bitmap made of horizontal strips: the header,
each row, the bottom padding and each line of the metadata popup. A
strip is rendered through libass on a strip sized canvas, over its
background filled by the color source, only when its script, place or
background changed or when it lies on something cleared or redrawn
before it. Only the changed part of the bitmap is uploaded, on the next
refresh. Moving the mouse across the list thus renders and uploads the
two rows whose highlight changed instead of the whole list on a window
wide canvas.

The popup over the rows of a narrow window now covers them instead of
letting their text show through.

Assisted-by: Claude
2026-10-13 22:12:55 +00:00
Michael Niedermayer 4b5c351f9a ffplay: round the chapter length without overflowing
A chapter length near INT64_MAX overflowed the rounding, the hour count
was also truncated to int.

Fixes: signed integer overflow
Fixes: 7JHyBJsQ7bNE
Regression since: 80a55704b7
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24589
Signed integer overflow Replicated through UnModified FFmpeg with UBSAN
2026-10-12 21:18:53 +00:00
James Almer 7c140b5f06 fftools/ffplay: stop using deprecated AVStreamGroup fields
Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-12 10:36:26 -03:00
Michael Niedermayer b139ba11d8 ffplay: show a chapter's metadata when the mouse is over its symbol
A symbol at the right of each entry pops up every tag of the chapter
beside the list, or over its rows when the window leaves no room there.
Clicking the symbol does not seek.

Assisted-by: Claude
2026-09-26 11:36:30 +00:00
Michael Niedermayer 5e217ff6a3 ffplay: shuffle the chapter list
A shuffle button orders the list by a pseudo-random rank of each
chapter derived from a seed, so the order is reproducible and the
other keys still resolve ties. Clicking the left half of the button
lowers the seed, the right half raises it, either way giving a new
order.

Assisted-by: Claude
2026-09-26 11:36:30 +00:00
Michael Niedermayer 31b2c648da ffplay: highlight the chapter list entry and button under the mouse
The position of the mouse is kept from its motion events and every
render of the list looks up what lies under it, so the highlight always
matches the rows being drawn even after they were rebuilt. Mouse motion
only asks for a render when the hovered row or button changes, and the
render happens once the pending events are handled, so sweeping the
mouse across the list renders once instead of once per row. Leaving
the window drops the highlight.

Assisted-by: Claude
2026-09-26 11:36:30 +00:00
Michael Niedermayer d2a7ee3ed7 ffplay: factor the chapter list hit test out of the click handler
Assisted-by: Claude
2026-09-26 11:36:30 +00:00
Michael Niedermayer 24ae807872 ffplay: filter the chapter list by typing while it is pinned
While the list is pinned it owns the keyboard: typed text narrows the
entries to those whose artist or title contains it, backspace erases,
escape closes the list. The list is pinned on the release of its key so
that the key's own text input does not start the search, and the
canvas keeps its full size so a changing row count does not alter the
script resolution libass scales to.

Assisted-by: Claude
2026-09-26 11:36:30 +00:00
Michael Niedermayer 80a55704b7 ffplay: sort the chapter list by clickable column buttons
Buttons above the list order it by chapter number, artist, title or
duration. Clicking a column makes it the first sort key ahead of the
ones clicked before, which still resolve ties, so # then Title orders
by title with equal titles in chapter order. Clicking the first key
again flips its order, shown by an arrow on its button.

The rows become an array in display order, rebuilt whenever the list is
shown, so the selection can survive a re-sort and chapters a demuxer
adds during playback are picked up. The length of each chapter is kept
with its row for the display and the sort to share; the sort compares
the exact length while the display rounds it to seconds.

Assisted-by: Claude
2026-09-26 11:36:30 +00:00
Michael Niedermayer 684b84e36d ffplay: seek to a chapter list entry by clicking it
Assisted-by: Claude
2026-09-26 11:36:30 +00:00
Michael Niedermayer 15586ccb36 ffplay: show a list of the chapters on screen
Page up/down fade in a list of the chapters around the current one and
fade it out again half a second after the last key press, "l" keeps it
on screen, and while it is kept down/up move the selection. Enter seeks
to the selected chapter and the mouse wheel moves the selection whenever
the list is visible. Each entry shows the chapter's number, its title
with the artist beneath it, both clipped to their column, and its
length; a bar at the left edge marks the chapter being played and moves
along with playback.

The ass filter renders the list onto a transparent canvas the size of
the panel, only when its content changes, and SDL composites the result
as a texture whose alpha modulation does the fading. The video path is
untouched and nothing is drawn while the list is hidden. The list is not
available with the Vulkan renderer, which bypasses SDL rendering.

Assisted-by: Claude
2026-09-26 11:36:30 +00:00
Michael Niedermayer a7d8698617 ffplay: make seek_chapter take the chapter index
The callers pass the index relative to the current chapter themselves,
so the function can serve seeks to an arbitrary chapter too.

Assisted-by: Claude
2026-09-26 11:36:30 +00:00
Michael Niedermayer ef8c89863d ffplay: factor the current chapter lookup out of seek_chapter
Assisted-by: Claude
2026-09-26 11:36:30 +00:00
Michael Niedermayer cf3d016982 ffplay: seek to the previous chapter from the last one as well
The chapter lookup left the index one past the end when the position
lay inside the last chapter, so page down restarted that chapter
instead of moving to the previous one like it does everywhere else.

Assisted-by: Claude
2026-09-26 11:36:30 +00:00
James Almer 7499a8ba58 fftools/ffplay: check that AVFormatContext is set in VideState before deferencing it
Fixes segfault in scenarios like trying to open an invalid path.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-09-22 15:02:45 -03:00
James Almer 23b79c0428 ffplay: merge LCEVC streams into the base stream
Signed-off-by: James Almer <jamrial@gmail.com>
2026-09-21 18:07:40 -03:00
Thomas Devoogdt 62508d7629 fftools/ffplay: exit via do_exit() on termination signal
sigterm_handler() called exit(123) directly, bypassing
avformat_close_input() and therefore any protocol level shutdown, such as
the RTSP TEARDOWN.  Set a flag instead and let the event loop leave
through do_exit(), which keeps the 123 exit status.

Add a hard exit on the 4th sigterm, similar to ffmpeg.

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
2026-09-16 17:03:53 +00:00
Kacper Michajłow d3fbc13429 fftools/ffplay: annotate intentional switch fall-throughs
Both fall-throughs are deliberate: SDL_MOUSEBUTTONDOWN shares the cursor
and seek handling of SDL_MOUSEMOTION, and a resize also needs the refresh
done by SDL_WINDOWEVENT_EXPOSED. Silences -Wimplicit-fallthrough.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-08-10 19:52:19 +02:00
Hunter Kvalevog 6d72600a30 fftools/ffplay: remove SDL_AUDIO_ALSA_SET_BUFFER_SIZE
SDL_AUDIO_ALSA_SET_BUFFER_SIZE was removed in SDL 2.0.9:
https://github.com/libsdl-org/SDL/commit/c591429542f429aac4979fb6ae9bbe024491a1f

Signed-off-by: Hunter Kvalevog <hunter@kvog.sh>
2026-07-03 12:49:56 +00:00
Romain Beauxis 9dc44b43b2 fftools/ffplay.c: Also print demuxer-level metadata updates. 2026-03-12 02:45:13 +00:00
zhanghongyuan e686f53424 fftools/ffplay: improve keyboard shortcut documentation
Clarify the behavior of seek keyboard shortcuts in both the
documentation and command-line help text. Specifically:
- left/right: mention custom interval option support
- page down/up: improve wording for chapter seeking fallback
2026-03-04 21:30:40 +00:00
Marton Balint 0ba9e272fa fftools/ffplay: add support for rendering without alpha
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Marton Balint e76c73afaf fftools/ffplay: add video_bg and aspect ratio support to vulkan renderer
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Marton Balint 50671a018d fftools/ffplay: add a new -video_bg option for transparent video
It allows controlling the background of a transparent video. Default is a
checker board pattern.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Romain Beauxis c75ada5040 ffplay: print new metadata 2025-11-22 18:38:40 +00:00
James Almer 05b6b30ee1 fftools/ffplay: set the alphamodes buffersink array option instead of the binary one
And add the missing goto fail. This should ensure the alpha mode is set and remove
bogus warnings printed by ffplay.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-08 18:38:16 -03:00
Niklas Haas 4f99026c9f fftools/ffplay: add alpha_mode support
SDL seems to hard-code straight alpha compositing.
2025-09-02 17:06:25 +02:00
Leandro Santiago fd0cacc472 fftools/ffplay: fix crash when vk renderer is null
When vulkan rendering is requested by the user and fails, ffplay should
exit graciously instead of crash due to a null pointer deref.

Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-11-06 16:34:02 +08:00
Anton Khirnov b97ccc537d fftools/ffplay: switch to new buffersink options 2024-09-30 09:14:04 +02:00
Anton Khirnov 577708a70a fftools/ffplay: stop using avfilter_graph_create_filter() incorrectly
This function creates AND initializes a filter, so setting any filter
options after it is wrong. It happens to work when the filter's init
function does not touch the options in question, but is forbidden by the
API and is not guaranteed to remain functional.

Instead, use avfilter_graph_alloc_filter(), followed by setting the
options, and avfilter_init_dict().
2024-09-28 17:04:33 +02:00