To prepare for playing a video track, you must follow the same steps as when setting up audio playback. But you must use the Screen API instead of mm-renderer to configure output parameters; doing so gives you control over how and when content is displayed.
The code excerpts below show how to give mm-renderer an output URL of screen: to render video content on the full display, and an input URL that names a local video file or a network-accessible stream for playback. These scenarios demonstate a simple case when you want to use the full display because no other UI apps are running. At other times, you may want to restrict the content to a particular area, which requires using the Screen API and is demonstrated in Managing video windows.
You can add subtitles to the video; this is explained in Playing video with subtitles.
/* Code to connect to mm-renderer and create a context goes here (see "Playing audio content" for an example of doing this) */ const mmr_error_info_t* errorInfo; // Attach a video output with a URL of "screen:" to use the full display int outputID = mmr_output_attach( ctxt_videorec, "screen:", "video" ); if (outputID == -1) { errorInfo = mmr_error_info(ctxt_videorec); /* Remaining error-handling code goes here */ return EXIT_FAILURE; }
// Attach an audio output with a URL of "snd:" to use the preferred device audio_device_output_id = mmr_output_attach( ctxt_videorec, "snd:", "audio" ); if (audio_device_output_id == -1) { errorInfo = mmr_error_info(ctxt_videorec); /* Remaining error-handling code goes here */ return EXIT_FAILURE; }
Using mmr_output_parameters(), you can configure any of the audio output parameters described in Parameters that affect how the output is delivered.
// Attach a local file as the input; use "track" as the type because // we're playing a single video track int inputID = mmr_input_attach( ctxt_videorec, "/fs/usb0/dontcry_official_video.mpg", "track" ); if (inputID == -1) { /* Error-handling code goes here */ return EXIT_FAILURE; } // Start playback if ( mmr_play( ctxt_videorec ) < 0 ) { /* Error-handling code goes here */ return EXIT_FAILURE; }
For the input URL, we provide a hard-coded path to a local MPEG video file. In your program, you may likely need to use a variable; for example, if the track to be played is based on user selection. Also, when naming a file as input, you can prepend the URL with file: to make it clear that you're accessing a file. For the list of supported file extensions and associated video formats, see the product release notes.
HLS playlists, which can be M3U files, must be attached as track inputs, not playlist inputs. The reason is that such playlists are basically references to small chunks of a long audio or video file and therefore must be played as one long track.
rtp://@:49152
rtsp://username:password@10.222.97.225/axis-media/media_demo_a1.amp
rtpts://@:10000The difference is that RTPTS carries the stream's properties with it, meaning it's easier to set up than RTP or RTSP. This URL syntax was developed for mm-renderer to indicate an RTP stream carrying Transport Stream (TS) packets. The TS container multiplexes audio and video streams and hence, allows a single RTP stream to carry both, instead of carrying only raw audio or raw video.
When playing a video file, we can manage playback in the same way as when playing an audio file.