Table of Contents

Video Files

A File player plays a video file stored on the display, decoded by the AM67's hardware decoder and rendered on the GPU like the cameras. This page covers where the file comes from, what plays and what is refused, the transport calls, and how to repeat a file.

Table of Contents

What Your Application Does

Choosing the File

Shipping a File with Your Application

What Plays

What Is Refused

Pause, Resume and Restart

The End of a File

When Playback Fails

Repeating a File

Hidden Surfaces

The File Pipeline

Preparing Files

What Your Application Does

The same PlayVideo and StopVideo as for a camera. A File player also takes PauseVideo, ResumeVideo and PositionVideo (restart only), and sends a Stopped notification when the file ends:

client.PlayVideo(new VideoPlaybackRequest { VideoPlayerID = 9, StatusUpdateInMs = 1000 });
client.PauseVideo(new VideoPlayer { VideoPlayerID = 9 });
client.ResumeVideo(new VideoPlayer { VideoPlayerID = 9 });
client.PositionVideo(new VideoPosition { VideoPlayerID = 9, PositionInMs = 0 });   // restart
client.StopVideo(new VideoPlayer { VideoPlayerID = 9 });

File playback runs on OpenView Pro and Flex (OpenViewLinuxPro). There is no bring-up and nothing to commission: the file only has to be on the display.

Choosing the File

In the Toolkit, set the player's Input Type to File (stored as FileSource). The Source column then takes a path instead of a camera port:

Source Plays
A relative path, such as media/intro.mp4 One of the application's own files, resolved against the application folder, /usr/local/Ahsoka/current
An absolute path, such as /run/media/usb0/intro.mp4 Any other file on the display — a USB stick or SD card, for example
Empty — shown as Chosen by app at runtime Whatever the application passes in VideoPlaybackRequest.VideoURL each time it plays

VideoURL also overrides a configured path for that one play, and may be written as a file:// URL. The Toolkit checks the path rules below as you type and marks a path the display would refuse.

Shipping a File with Your Application

To play a file that ships with the application, add it to the project so it is copied to the output, and use the relative path as the player's source:

<ItemGroup>
  <None Update="media\intro.mp4">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  </None>
</ItemGroup>

The file lands at /usr/local/Ahsoka/current/media/intro.mp4. Everything in the application folder travels in every package, so keep large media out of it: put it on external storage, or copy it to the display separately, and use an absolute path.

What Plays

Supported
Containers MP4, MOV (.mp4, .m4v, .mov) and Matroska (.mkv)
Video H.264 Baseline, Main or High; H.265 Main
Size Up to 1920 on either side and no more than 1920×1088 in total, so 1080p landscape or portrait
Audio Ignored

The service reads the file's header before anything runs and builds the pipeline for exactly that container and codec, so a file is always decoded in hardware.

What Is Refused

A file that breaks any of these rules is refused at PlayVideo: the call returns Unavailable straight away, no player process is started, and the application log names the reason.

Rule Reason in the log
A source is configured or passed in VideoURL no file is configured and none was supplied in VideoURL
Letters, digits and / . _ - + only, up to 1024 characters '/media/My Video.mp4' contains characters other than letters, digits and / . _ - +
A plain path or a file:// URL 'rtsp://cam/stream' is a URL, not a file path
Not under /dev, /proc or /sys '/dev/video0.mp4' is under /dev, /proc or /sys
.mp4, .m4v, .mov or .mkv '/usr/local/Ahsoka/current/intro.avi' is not a .mp4, .m4v, .mov or .mkv file
The file exists, is a regular file and is not empty '…' does not exist, '…' is empty or not a regular file. A symbolic link is followed and its target checked the same way.
A supported container, codec, profile and size file '/usr/local/Ahsoka/current/media/x.mp4' refused - it uses H.264 profile 110 (Baseline, Main or High only)

Path problems are logged as PLAYER 9 (Demo clip): file refused - <reason> (player unavailable).; problems found in the file itself as PLAYER 9 (Demo clip): file '<path>' refused - it <reason> (player unavailable).

The path rules are deliberately strict: the path is written into the pipeline, so nothing in it may change what that pipeline does.

Pause, Resume and Restart

Call Effect
PauseVideo Pauses on the current frame. The player reports Paused.
ResumeVideo Continues from where it paused.
PositionVideo with PositionInMs = 0 Restarts from the beginning. A paused player stays paused.
PositionVideo with any other position Not supported yet. The request is logged and ignored, and the current status is returned.
PlayVideo on a paused player Starts the file over, playing.

PauseVideo on a player that is not playing, ResumeVideo on one that is not paused, and a restart of a player that has ended or been stopped are logged and ignored; the current status is returned. To play an ended file again, call PlayVideo.

A restart does not seek: it stops the player and starts a fresh one, so expect about a second before the first frame. Seeking within a file is held back because flushing the hardware decoder in the middle of a stream can lock it up on the current Pro BSP.

While playing or paused, StatusUpdated carries the file's PositionInMs and TotalTimeInMs every StatusUpdateInMs. With StatusUpdateInMs = 0 nothing is pushed, but RequestVideoStatus still reports a position that is updated every second.

The End of a File

At the end of the file the player stops on its own. The surface is cleared — exactly as if the application had called StopVideo — and the application receives a StatusUpdated notification with Stopped, whatever its StatusUpdateInMs.

When Playback Fails

If the pipeline fails after PlayVideo has returned Playing — a file whose video header passes the check but cannot be decoded, for example — the player stops, the surface is cleared, and the application receives a StatusUpdated notification with Unavailable. The log has the GStreamer error at high severity, followed by PLAYER 9 (Demo clip): playback failed (player unavailable). A player that exits without reporting an error logs player exited unexpectedly with exit code … instead.

Don't repeat a file on Unavailable as you would on Stopped: the same file would fail again. A file cut short (an interrupted copy, say) is not a failure: it plays up to the cut and ends with Stopped.

Repeating a File

The service does not loop a file. To repeat one, play it again when its Stopped notification arrives — but only while the application still wants it, because a StopVideo of your own also leaves the player Stopped:

static volatile bool repeatFile;

void OnVideoNotification(object sender, AhsokaClientBase<VideoMessageTypes.Ids>.AhsokaNotificationArgs e)
{
    if (e.NotificationObject is VideoStatus { VideoPlayerID: 9, VideoState: PlaybackState.Stopped } && repeatFile)
        Task.Run(() => client.PlayVideo(new VideoPlaybackRequest { VideoPlayerID = 9, StatusUpdateInMs = 1000 }));
}

Set repeatFile before the first play and clear it before calling StopVideo. Each repeat starts a fresh player, so there is about a second between passes. Both demos do this on their Video File page; see The Demos.

Hidden Surfaces

A File player keeps playing in real time while its surface is hidden, and is at the right place when the surface is shown again. If you want hidden to mean paused, call PauseVideo when you hide it. The reported position can stall while the surface is hidden.

The File Pipeline

filesrc location=/usr/local/Ahsoka/current/media/intro.mp4
  ! qtdemux name=demux demux.video_0 ! queue ! h264parse
  ! v4l2h264dec capture-io-mode=4
  ! identity sync=true
  ! queue leaky=downstream max-size-buffers=3 max-size-time=0 max-size-bytes=0
  ! glimagesink sync=false

Matroska files use matroskademux, and H.265 files h265parse and v4l2h265dec. Decoded frames go to the GPU without a copy. identity sync=true paces playback to the clock, and the leaky queue lets the decoder carry on when a hidden surface stops glimagesink presenting — which is also what lets a stop drain the decoder promptly.

When renderWidth and renderHeight are both set — on the player, or per play on the request — the frame is scaled to that size on the GPU before it reaches the compositor. Otherwise it is presented at its decoded size and the compositor scales it into the surface rectangle.

Stopping a File player first drains the hardware decoder, as for VCIC, and then ends the process.

Preparing Files

For the smoothest playback:

Aim for Why
A constant 30 or 60 fps The panels refresh at 60 Hz; 24 or 25 fps content shows an uneven cadence
A size no larger than the surface needs A 1080p file shown in a small rectangle decodes and draws pixels nobody sees
Width and height multiples of 8 A requirement of the hardware decoder
A keyframe every second or two, and MP4 written with the index at the front Not needed today, but ready for seeking when it arrives
Note

The demo clip, media/demo.mp4, is a 10-second 1024×576 H.264 file of about 450 KB, which is small enough to ship inside an application package.