Mercurial
view third_party/ffmpeg/ffmpeg_hls_test.c @ 279:b3b547563ec7
Add Google connector service and agent wiki
Implement the C/Seobeo Google Drive and Gmail connector with encrypted OAuth storage, Zenbu authentication, browser testing, AI tool discovery, chunked HTTP decoding, and Bazel coverage. Consolidate repository guidance into progressive wiki documentation and enforce arena-first allocation for new first-party C code.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 84c338fd-0939-4bb3-b7f3-1062eb213e5d
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 17 Aug 2026 22:22:36 -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; }