Mercurial
view third_party/ffmpeg/ffmpeg_hls_test.c @ 260:1f9877b637e9
Add Copilot-powered cyberpunk JRPG chat
Integrate the production JRPG chat with Seobeo streaming, Deita persistence, and a Bazel-managed Copilot SDK and LiteLLM inference stack.
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <mrjunejune@users.noreply.github.com> |
|---|---|
| date | Wed, 05 Aug 2026 09:19:41 -0700 |
| parents | 543df0fe7168 |
| children |
line wrap: on
line source
#include "third_party/ffmpeg/ffmpeg_cli.h" #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> static char *read_file(const char *path) { FILE *file = fopen(path, "rb"); if (!file) return NULL; fseek(file, 0, SEEK_END); long length = ftell(file); fseek(file, 0, SEEK_SET); char *content = malloc((size_t)length + 1); fread(content, 1, (size_t)length, file); content[length] = '\0'; fclose(file); return content; } int main(int argc, char **argv) { assert(argc == 2); char temporary[] = "/tmp/ffmpeg-hls-test-XXXXXX"; assert(mkdtemp(temporary)); Fmp4HlsOpts options = ffmpeg_fmp4_hls_opts_default(); options.max_width = 480; options.max_height = 360; options.video_bitrate = 350; options.codec = FFMPEG_HLS_VP9_OPUS; FfmpegResult result = ffmpeg_video_to_fmp4_hls( argv[1], temporary, "test", &options); if (result != FFMPEG_OK) { fprintf(stderr, "%s\n", ffmpeg_last_error()); return 1; } char playlist_path[512]; snprintf(playlist_path, sizeof(playlist_path), "%s/test-stream.m3u8", temporary); char *playlist = read_file(playlist_path); assert(playlist); assert(strstr(playlist, "#EXT-X-MAP:URI=\"test-init.mp4\"")); assert(strstr(playlist, "test-segment000.m4s")); assert(strstr(playlist, "#EXT-X-ENDLIST")); free(playlist); options.codec = FFMPEG_HLS_H264_AAC; options.use_mpeg_ts = true; result = ffmpeg_video_to_fmp4_hls( argv[1], temporary, "test-ts", &options); if (result != FFMPEG_OK) { fprintf(stderr, "%s\n", ffmpeg_last_error()); return 1; } snprintf( playlist_path, sizeof(playlist_path), "%s/test-ts-stream.m3u8", temporary); playlist = read_file(playlist_path); assert(playlist); assert(!strstr(playlist, "#EXT-X-MAP")); assert(strstr(playlist, "test-ts-segment000.ts")); assert(strstr(playlist, "#EXT-X-ENDLIST")); free(playlist); char cleanup[640]; snprintf(cleanup, sizeof(cleanup), "rm -rf '%s'", temporary); return system(cleanup) == 0 ? 0 : 1; }