GUACAMOLE-1370: guacenc output to stdout.#687
Conversation
Added a -o option to guacenc allowing the output path to be specified explicitly. It defaults to FILE.m4v as before when unspecified for backwards compatibility. Specifying "-" as the output path streams the encoded video to stdout.
| /* The container format cannot be guessed from a pipe URL and must be | ||
| * specified explicitly. The "ipod" container is used, matching the | ||
| * container that would be guessed from the ".m4v" extension of the output | ||
| * files normally produced */ | ||
| bool is_pipe = (strncmp(path, "pipe:", 5) == 0); | ||
| const char* format_name = is_pipe ? "ipod" : NULL; | ||
|
|
There was a problem hiding this comment.
Is this an appropriate assumption to make universally, or should this be configurable, as well? Are there situations where users may want to stream in a format different than iPod?
There was a problem hiding this comment.
"ipod" was already an assumption being made universally before, just not explicitly. When writing to a file, the third argument to avformat_alloc_output_context2() is NULL so libavformat guesses the container from the extension of the output path. Since that was hardcoded to "FILE.m4v" it was always making the same guess based on ".m4v" -- 'ipod'. This is a pretty universally supported format, even in web browsers, so I think it's a good default. Maybe someone will want it to be configurable in the future, but we can just wait for that feature request.
There was a problem hiding this comment.
I agree that it was assumed by virtue of the fact that all files were necessarily m4v files. Now we're giving folks an option on what to name the files, which implicitly allows them to also adjust the format - and we're giving them an option to pipe everything to stdout, but forcing them to use the ipod format when going to stdout.
I'm not going to block this PR from going through if you don't want to do this, it's just something that seems to be in the same spirit as the ability to send it to stdout, and change the filename.
[It's also worth noting that simply having the ability to send to stdout means that you could also pipe it back into ffmpeg and reformat it that way, but you may start to lose the fidelity of the video that way due to lossy encodings, etc.]
Added a -o option to guacenc allowing the output path to be specified explicitly. It defaults to FILE.m4v as before when unspecified for backwards compatibility. Specifying "-" as the output path streams the encoded video to stdout. Normal MP4 (which is what's being used for file output still) doesn't support streaming, so we use fragmented MP4 here when outputting to stdout. This paves the way to streaming that stdout to a video player or even the browser in real time as it's being encoded.