HOME PCB
..HLSStream.javaMPEGDashStream.javaStream.javaVideoStream.javaVideoStreamDirectory.java
package FFMPEG;

import java.io.IOException;
import java.nio.file.Path;

@VideoStreamDirectory(manifestExtension = "mdp")
public class MPEGDashStream extends VideoStream
{
    public MPEGDashStream()
    {
        super("manifest");
    }

    public Process createStream(Path dir) throws IOException
    {
        return new ProcessBuilder(
                "/usr/bin/ffmpeg",
                "-y",                                                       // Overwrite output files without asking
                "-f", "v4l2",                                               // Input format
                "-video_size", "1280x720",                                  // Input video size
                "-framerate", "25",                                         // Input framerate
                "-i", "/dev/video0",                                        // Input device
                "-vcodec", "h264_omx",                                      // Encoding codec
                "-keyint_min", "0",                                         // Allow every frame to be a key frame
                "-g", "100",                                                // But at most every 100 frames will be a key frame
                "-map", "0:v",                                              // Map input stream 0 to the video of this stream
                "-b:v", "1000k",                                            // Set the bitrate to 1000k
                "-f", "dash",                                               // Output format
                "-min_seg_duration", this.getSegmentLengthMilli().toString(),         // Segment into ~4 second parts
                "-use_template", "1",                                       // Use templated names for output
                "-use_timeline", "0",                                       // Dont use the segment time in the template
                "-remove_at_exit", "0",                                     // Do Not Remove all files when stopping
                "-window_size", "20",                                       // Keep 20 segments on disk
                dir.resolve(this.getManifest()).toString()                  // Dash manifest name
        ).inheritIO().start();
    }

    @Override
    public Integer getSegmentLengthMilli()
    {
        return 4000;
    }
}