media: probe lists every stream; decoders check what is mapped
Plan 3 Task 3, fix round 1 (Astra P1 and two P2s, Fable I1, I2 and minors), checked against Debian 13's ffmpeg 7.1.5. ffprobe 7.1 opens a decoder for every stream and exits when one is off -codec_whitelist, so cover art or a subtitle stream made a source unreadable. The probe now runs without the decoder allow-list; ffmpeg keeps it, on the streams the encode maps (ffmpegInputArgs). audio-aac takes no video stream at all: its duration and packet pass are the audio's. The packet pass reads the first two CSV fields, so a packet with side data counts. runChild kills the child's pid as well as its group. Both binaries take -max_pixels, set to MaxSide squared: at media.MaxPixels a portrait 2160x3840 fails to decode (aligned to 2176x3840). ffprobe prints only the fields parseProbe reads, and a failed probe logs the last 4 KiB of its stderr. Fixtures are now made by the real ffmpeg; the real-binary tests skip unless CARLOS_MEDIA_FFMPEG and CARLOS_MEDIA_FFPROBE are set.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 files changed,
+1,331
−315
docs/superpowers/notes/media-conversion-copy-deck.md+3 −2internal/media/media.go+3 −0internal/mediahandler/probe.go+111 −57internal/mediahandler/probe_test.go+152 −63internal/mediahandler/procs_linux.go+6 −2internal/mediahandler/procs_test.go+50 −0internal/mediahandler/realffmpeg_test.go+440 −0internal/mediahandler/testdata/probe/aac-6ch.json+14 −9internal/mediahandler/testdata/probe/av-no-duration.json+42 −0internal/mediahandler/testdata/probe/av-no-duration.packets.csv+151 −0internal/mediahandler/testdata/probe/bomb-30000.json+6 −6internal/mediahandler/testdata/probe/chrome-webm-opus.json+13 −11internal/mediahandler/testdata/probe/chrome-webm-opus.packets.csv+51 −7internal/mediahandler/testdata/probe/dolby-vision-5.json+10 −7internal/mediahandler/testdata/probe/dolby-vision-8-4.json+20 −14internal/mediahandler/testdata/probe/h264-120fps.json+16 −10internal/mediahandler/testdata/probe/h264-4k60.json+21 −11internal/mediahandler/testdata/probe/h264-subtitle.json+58 −0internal/mediahandler/testdata/probe/iphone-hevc-hlg-portrait.json+25 −33internal/mediahandler/testdata/probe/lying-10h.json+6 −6internal/mediahandler/testdata/probe/m4a-cover-art.json+22 −13internal/mediahandler/testdata/probe/mka-cover-art.json+29 −16internal/mediahandler/testdata/probe/mp3-cover-art.json+21 −14internal/mediahandler/testdata/probe/provenance.txt+33 −0internal/mediahandler/testdata/probe/stand-ins.txt+0 −13internal/mediahandler/testdata/probe/vfr-screen-recording.json+17 −12internal/mediahandler/testdata/probe/wav-mono.json+11 −9
CI passed — run details
diff --git a/docs/superpowers/notes/media-conversion-copy-deck.md b/docs/superpowers/notes/media-conversion-copy-deck.md| index 34411c0a5..3909de6fc 100644 |
| --- a/docs/superpowers/notes/media-conversion-copy-deck.md |
| +++ b/docs/superpowers/notes/media-conversion-copy-deck.md |
| @@ -549,13 +549,14 @@ prints nothing. |
| | `engine.download.resume` | `source download: broke after %d bytes; resume %d of %d` (pending Luna pass; plan 3 Task 2) | |
| | `engine.download.gave_up` | `source download: broke %d times; giving up` (pending Luna pass; plan 3 Task 2) | |
| | `engine.codec.source_unopenable` | `codec: the downloaded source cannot be read: %s` (pending Luna pass; plan 3 Task 3). `%s` is the system's error for the scratch source path | |
| -| `engine.probe.failed` | `codec: ffprobe failed: %q` (pending Luna pass; plan 3 Task 3). `%q` is the last 64 KiB of ffprobe's stderr at `-loglevel error`, quoted so it stays one line | |
| +| `engine.probe.failed` | `codec: ffprobe failed: %q` (pending Luna pass; plan 3 Task 3). `%q` is the last 4 KiB of ffprobe's stderr at `-loglevel error`, quoted so it stays one line | |
| | `engine.probe.timeout` | `codec: ffprobe did not finish in time` (pending Luna pass; plan 3 Task 3) | |
| | `engine.probe.unusable` | `codec: ffprobe's answer is over %d bytes` (pending Luna pass; plan 3 Task 3). `%d` is 1048576 | |
| | `engine.probe.unparsable` | `codec: ffprobe's answer is unusable: %s` (pending Luna pass; plan 3 Task 3). `%s` is one of `engine.probe.reason.*` | |
| | `engine.probe.reason.not_json` | `not ffprobe's JSON` (pending Luna pass; plan 3 Task 3) | |
| | `engine.probe.reason.trailing` | `data after ffprobe's JSON` (pending Luna pass; plan 3 Task 3) | |
| -| `engine.probe.reason.negative` | `stream %d has a negative field` (pending Luna pass; plan 3 Task 3). `%d` is the stream's position | |
| +| `engine.probe.reason.negative` | `stream %d has a negative field` (pending Luna pass; plan 3 Task 3). `%d` is the stream's index | |
| +| `engine.probe.reason.preset` | `unknown preset` (pending Luna pass; plan 3 Task 3 fix 1). Never reached through `Run`: sniff refuses an unknown preset first | |
| | `engine.probe.reason.rate` | `stream %d avg_frame_rate: not a rational of non-negative integers`, and the same with `r_frame_rate` (pending Luna pass; plan 3 Task 3) | |
| | `engine.probe.reason.rotate` | `stream %d rotate tag is not an integer` (pending Luna pass; plan 3 Task 3) | |
| | `engine.probe.reason.duration` | `format duration: not a duration`, `stream %d duration: not a duration` (pending Luna pass; plan 3 Task 3) | |
diff --git a/internal/media/media.go b/internal/media/media.go| index 6bf6205f5..07c5c421c 100644 |
| --- a/internal/media/media.go |
| +++ b/internal/media/media.go |
| @@ -199,6 +199,9 @@ const ( |
| MaxDimensions = "3840x2160" |
| MaxSide = 4096 |
| MaxFPS = 60 |
| + // MaxPixels is MaxDimensions' pixel count: a source with more is |
| + // source_dimensions. |
| + MaxPixels = 3840 * 2160 |
| ) |
| // Above1080p reports whether a video source is above 1080p in either |
diff --git a/internal/mediahandler/probe.go b/internal/mediahandler/probe.go| index 946ef43ae..d861a4614 100644 |
| --- a/internal/mediahandler/probe.go |
| +++ b/internal/mediahandler/probe.go |
| @@ -24,8 +24,13 @@ const probeTimeout = 60 * time.Second |
| // is unreadable. |
| const maxProbeOutput = 1 << 20 |
| -// codecWhitelist is every run's -codec_whitelist (plan 3's Global |
| -// Constraints): the decoders for the codecs check accepts. |
| +// codecWhitelist is every ffmpeg run's -codec_whitelist (plan 3's |
| +// Global Constraints): the decoders for the codecs check accepts. It is |
| +// enforced where frames are decoded for an output, on the streams the |
| +// encode maps (ffmpegInputArgs), and not on ffprobe: ffprobe 7.1 opens a |
| +// decoder for every stream and exits when one is not on the list, so an |
| +// MP3 with JPEG cover art or a video with a subtitle stream would be |
| +// unreadable (plan 3 Task 3 fix 1, Astra P1; shown on Debian's 7.1.5). |
| const codecWhitelist = "h264,hevc,vp8,vp9,av1,libdav1d,aac,opus,libopus,vorbis,libvorbis,mp3,mp3float,flac," + |
| "pcm_u8,pcm_s16le,pcm_s16be,pcm_s24le,pcm_s24be,pcm_s32le,pcm_s32be,pcm_f32le,pcm_f32be,pcm_f64le,pcm_f64be,pcm_alaw,pcm_mulaw" |
| @@ -46,16 +51,24 @@ var audioCodecs = func() map[string]bool { |
| return m |
| }() |
| -// maxPixels is media.MaxDimensions' width times height. |
| -var maxPixels = func() int64 { |
| - w, h, _ := strings.Cut(media.MaxDimensions, "x") |
| - wn, err1 := strconv.ParseInt(w, 10, 64) |
| - hn, err2 := strconv.ParseInt(h, 10, 64) |
| - if err1 != nil || err2 != nil { |
| - panic("media.MaxDimensions is not <w>x<h>") |
| - } |
| - return wn * hn |
| -}() |
| +// maxDecodePixels is every ffprobe and ffmpeg run's -max_pixels: the |
| +// decoders refuse a frame with more, so a bomb's header cannot make |
| +// them allocate it, during the probe or the encode. It is not |
| +// media.MaxPixels (check holds sources to that): libavcodec checks the |
| +// stride-aligned size, so at exactly 3840x2160 a portrait 2160x3840 |
| +// H.264, which check accepts, is refused as 2176x3840 (shown on |
| +// Debian's 7.1.5). MaxSide squared leaves room for any alignment of a |
| +// source check accepts. A source over it is unreadable, as ffprobe |
| +// fails on it, rather than source_dimensions. |
| +const maxDecodePixels = media.MaxSide * media.MaxSide |
| + |
| +// probeEntries are the fields ffprobe prints: what parseProbe reads and |
| +// nothing else, so the source's tags (a title, a location), but for a |
| +// stream's rotate tag, never reach the handler's memory. |
| +const probeEntries = "format=duration" + |
| + ":stream=index,codec_type,codec_name,width,height,avg_frame_rate,r_frame_rate,color_transfer,channels,duration" + |
| + ":stream_disposition=attached_pic:stream_tags=rotate" + |
| + ":stream_side_data=side_data_type,rotation,dv_profile" |
| // grantedByClass is JobLimits.GrantedBy when the class's granted |
| // duration bounds the job (internal/mediajobs/dispatch.go); anything |
| @@ -88,25 +101,44 @@ type probeFacts struct { |
| DurationMS int64 |
| } |
| +// inputArgs are the input options every ffprobe and ffmpeg run shares: |
| +// only the file protocol, the sniffed demuxer forced, external |
| +// references off for mov, and the decoders' pixel bound. |
| +func inputArgs(demuxer string) []string { |
| + args := []string{"-protocol_whitelist", "file", "-f", demuxer} |
| + if demuxer == "mov" { |
| + args = append(args, "-enable_drefs", "0") |
| + } |
| + return append(args, "-max_pixels", strconv.Itoa(maxDecodePixels)) |
| +} |
| + |
| // probeArgs are ffprobe's arguments for the source: the shared input |
| // options, then extra, then the fixed input path. -loglevel error |
| // keeps the source's metadata (a title, a comment, a location) off |
| -// stderr and so out of the task's log (preflight F19). ffprobe prints |
| -// no progress, so it takes no -nostats. |
| +// stderr and so out of the task's log (preflight F19). ffprobe has no |
| +// -nostats (it refuses the option: Debian's 7.1.5) and prints no |
| +// progress. |
| func probeArgs(cfg Config, demuxer string, extra ...string) []string { |
| - args := []string{"-hide_banner", "-loglevel", "error", "-protocol_whitelist", "file", "-f", demuxer} |
| - if demuxer == "mov" { |
| - args = append(args, "-enable_drefs", "0") |
| - } |
| - args = append(args, "-codec_whitelist", codecWhitelist) |
| + args := append([]string{"-hide_banner", "-loglevel", "error"}, inputArgs(demuxer)...) |
| args = append(args, extra...) |
| return append(args, "-i", sourcePath(cfg)) |
| } |
| +// ffmpegInputArgs are an ffmpeg run's arguments up to and including the |
| +// input: quiet (-loglevel error, preflight F19), no stdin, the shared |
| +// input options and the decoder allow-list. The encodes (plan 3 Tasks 4 |
| +// and 5) follow them with an explicit -map of the chosen streams only, |
| +// so a stream ffmpeg would refuse to decode is one nothing maps. |
| +func ffmpegInputArgs(cfg Config, demuxer string) []string { |
| + args := append([]string{"-hide_banner", "-nostats", "-loglevel", "error", "-nostdin"}, inputArgs(demuxer)...) |
| + return append(args, "-codec_whitelist", codecWhitelist, "-i", sourcePath(cfg)) |
| +} |
| + |
| // probe runs ffprobe on the source with the sniffed demuxer forced and |
| -// answers its facts. The duration is the header's (parseProbe); when it |
| -// has none, a second pass reads the chosen stream's packets (the video, |
| -// else the audio) and takes the largest pts+duration. The two passes |
| +// answers its facts for preset. The duration is the header's |
| +// (parseProbe); when it has none, a second pass reads the chosen |
| +// stream's packets (video-720p: the video; audio-aac: the audio) and |
| +// takes the largest pts+duration. The two passes |
| // share one probeTimeout. Failures: |
| // |
| // - ffprobe failing, overrunning maxProbeOutput, answering what |
| @@ -114,7 +146,7 @@ func probeArgs(cfg Config, demuxer string, extra ...string) []string { |
| // - a stream to time but no packet time: unreadable; |
| // - ffprobe not starting, or its cleanup failing: engine_failed; |
| // - ctx ending (the task stopping): ctx's error. |
| -func probe(ctx context.Context, cfg Config, demuxer string) (probeFacts, error) { |
| +func probe(ctx context.Context, cfg Config, demuxer, preset string) (probeFacts, error) { |
| timeout := cfg.probeTimeout |
| if timeout <= 0 { |
| timeout = probeTimeout |
| @@ -124,7 +156,7 @@ func probe(ctx context.Context, cfg Config, demuxer string) (probeFacts, error) |
| dir := filepath.Join(cfg.Scratch, "tmp") |
| out := &capBuffer{max: maxProbeOutput} |
| - tail, err := runChildTo(pctx, cfg, cfg.FFprobe, probeArgs(cfg, demuxer, "-show_format", "-show_streams", "-of", "json"), dir, out) |
| + tail, err := runChildTo(pctx, cfg, cfg.FFprobe, probeArgs(cfg, demuxer, "-show_entries", probeEntries, "-of", "json"), dir, out) |
| if err := probeFailed(ctx, cfg, tail, err); err != nil { |
| return probeFacts{}, err |
| } |
| @@ -133,7 +165,7 @@ func probe(ctx context.Context, cfg Config, demuxer string) (probeFacts, error) |
| cfg.Logf("codec: ffprobe's answer is over %d bytes", maxProbeOutput) |
| return probeFacts{}, jobError{media.CodeUnreadable} |
| } |
| - f, err := parseProbe(out.buf.Bytes()) |
| + f, err := parseProbe(out.buf.Bytes(), preset) |
| if err != nil { |
| // engine.probe.unparsable (pending Luna pass). err names a |
| // field or a fixed reason, never a value. |
| @@ -143,6 +175,9 @@ func probe(ctx context.Context, cfg Config, demuxer string) (probeFacts, error) |
| if f.DurationMS > 0 { |
| return f, nil |
| } |
| + // The chosen stream: under audio-aac parseProbe takes no video, so |
| + // this is the audio there, and the video (else the audio) under |
| + // video-720p. |
| index := f.VideoIndex |
| if index < 0 { |
| index = f.AudioIndex |
| @@ -165,10 +200,14 @@ func probe(ctx context.Context, cfg Config, demuxer string) (probeFacts, error) |
| return f, nil |
| } |
| +// probeLogTail is how much of a failed ffprobe's stderr reaches the log. |
| +const probeLogTail = 4 << 10 |
| + |
| // probeFailed maps one ffprobe run's outcome: nil for a clean exit; |
| // ctx's error when the task is stopping; engine_failed as runChild |
| -// gave it; anything else unreadable, logged with ffprobe's stderr tail |
| -// (quoted, so it stays one line and cannot forge another). |
| +// gave it; anything else unreadable, logged with the last probeLogTail |
| +// bytes of ffprobe's stderr (quoted, so it stays one line and cannot |
| +// forge another). |
| func probeFailed(ctx context.Context, cfg Config, tail []byte, err error) error { |
| var je jobError |
| switch { |
| @@ -185,7 +224,7 @@ func probeFailed(ctx context.Context, cfg Config, tail []byte, err error) error |
| } |
| // engine.probe.failed (pending Luna pass). The tail is ffprobe's |
| // stderr at -loglevel error: its errors, never the payload. |
| - cfg.Logf("codec: ffprobe failed: %q", tail) |
| + cfg.Logf("codec: ffprobe failed: %q", tail[max(0, len(tail)-probeLogTail):]) |
| return jobError{media.CodeUnreadable} |
| } |
| @@ -227,14 +266,17 @@ const ( |
| sideDolbyVision = "DOVI configuration record" |
| ) |
| -// parseProbe reads ffprobe's -show_format -show_streams -of json |
| -// answer. ffprobe is trusted to answer in its shape, but it has read |
| -// hostile input, so parseProbe refuses anything negative or malformed |
| -// rather than pass it on. Rules (plan 3 Task 3): |
| +// parseProbe reads ffprobe's -show_entries probeEntries -of json answer |
| +// for preset. ffprobe is trusted to answer in its shape, but it has |
| +// read hostile input, so parseProbe refuses anything negative or |
| +// malformed in what it takes rather than pass it on. Rules (plan 3 |
| +// Task 3): |
| // |
| // - streams whose disposition.attached_pic is 1 (cover art) are |
| -// skipped; the first remaining video and the first audio stream are |
| -// taken, and every other stream is ignored; |
| +// skipped; the first remaining video (video-720p only: audio-aac |
| +// takes no video, so nothing of a video stream can refuse an audio |
| +// job) and the first audio stream are taken, and every other stream |
| +// is ignored, unread; |
| // - rotation from the display matrix side data, else the rotate tag |
| // (clockwise, so negated), rounded to a multiple of 90; |
| // - FPS from avg_frame_rate, r_frame_rate only when the average is |
| @@ -242,9 +284,15 @@ const ( |
| // - HDR when color_transfer is smpte2084 or arib-std-b67, or Dolby |
| // Vision side data is present; |
| // - duration from format.duration, else the longest of the taken |
| -// streams' durations, else 0 (probe's packet pass), rounded up to |
| -// the millisecond. |
| -func parseProbe(b []byte) (probeFacts, error) { |
| +// streams' durations (audio-aac: the audio's), else 0 (probe's |
| +// packet pass), rounded up to the millisecond. |
| +// |
| +// An unknown preset is an error. |
| +func parseProbe(b []byte, preset string) (probeFacts, error) { |
| + video := preset == media.PresetVideo720p |
| + if !video && preset != media.PresetAudioAAC { |
| + return probeFacts{}, errors.New("unknown preset") |
| + } |
| var out ffOutput |
| dec := json.NewDecoder(bytes.NewReader(b)) |
| if err := dec.Decode(&out); err != nil { |
| @@ -255,36 +303,38 @@ func parseProbe(b []byte) (probeFacts, error) { |
| return probeFacts{}, errors.New("data after ffprobe's JSON") |
| } |
| f := probeFacts{VideoIndex: -1, AudioIndex: -1} |
| - var video, audio *ffStream |
| + var vs, as *ffStream |
| for i := range out.Streams { |
| s := &out.Streams[i] |
| - if s.Index < 0 || s.Width < 0 || s.Height < 0 || s.Channels < 0 { |
| - return probeFacts{}, fmt.Errorf("stream %d has a negative field", i) |
| - } |
| if s.Disposition.AttachedPic == 1 { |
| continue |
| } |
| switch { |
| - case s.CodecType == "video" && video == nil: |
| - video = s |
| - case s.CodecType == "audio" && audio == nil: |
| - audio = s |
| + case s.CodecType == "video" && video && vs == nil: |
| + vs = s |
| + case s.CodecType == "audio" && as == nil: |
| + as = s |
| + } |
| + } |
| + for _, s := range []*ffStream{vs, as} { |
| + if s != nil && (s.Index < 0 || s.Width < 0 || s.Height < 0 || s.Channels < 0) { |
| + return probeFacts{}, fmt.Errorf("stream %d has a negative field", max(s.Index, 0)) |
| } |
| } |
| var err error |
| - if video != nil { |
| - if err = videoFacts(&f, video); err != nil { |
| + if vs != nil { |
| + if err = videoFacts(&f, vs); err != nil { |
| return probeFacts{}, err |
| } |
| } |
| - if audio != nil { |
| - f.AudioIndex, f.AudioCodec, f.Channels = audio.Index, audio.CodecName, audio.Channels |
| + if as != nil { |
| + f.AudioIndex, f.AudioCodec, f.Channels = as.Index, as.CodecName, as.Channels |
| } |
| if f.DurationMS, err = parseSecondsMS(out.Format.Duration); err != nil { |
| return probeFacts{}, fmt.Errorf("format duration: %w", err) |
| } |
| if f.DurationMS == 0 { |
| - for _, s := range []*ffStream{video, audio} { |
| + for _, s := range []*ffStream{vs, as} { |
| if s == nil { |
| continue |
| } |
| @@ -476,7 +526,7 @@ func check(f probeFacts, preset string, l media.JobLimits) error { |
| switch { |
| case f.Width <= 0 || f.Height <= 0: |
| return jobError{media.CodeUnreadable} |
| - case f.Width > media.MaxSide || f.Height > media.MaxSide || int64(f.Width)*int64(f.Height) > maxPixels: |
| + case f.Width > media.MaxSide || f.Height > media.MaxSide || int64(f.Width)*int64(f.Height) > media.MaxPixels: |
| return jobError{media.CodeSourceDimensions} |
| case f.FPS < 0: |
| return jobError{media.CodeUnreadable} |
| @@ -521,7 +571,7 @@ func inspectSource(ctx context.Context, cfg Config, p media.Payload) (string, pr |
| if err != nil { |
| return "", probeFacts{}, err |
| } |
| - f, err := probe(ctx, cfg, demuxer) |
| + f, err := probe(ctx, cfg, demuxer, p.Preset) |
| if err != nil { |
| return "", probeFacts{}, err |
| } |
| @@ -554,9 +604,9 @@ func (c *capBuffer) Write(p []byte) (int, error) { |
| // one is skipped. |
| const maxPacketLine = 128 |
| -// packetMax reads the packet pass's "pts_time,duration_time" lines as |
| -// they stream and keeps the largest pts+duration, in microseconds; a |
| -// line that does not parse is skipped. It holds one line at a time, |
| +// packetMax reads the packet pass's "pts_time,duration_time[,...]" |
| +// lines as they stream and keeps the largest pts+duration, in |
| +// microseconds; a line whose two fields do not parse is skipped. It holds one line at a time, |
| // whatever the stream's length. |
| type packetMax struct { |
| line []byte |
| @@ -586,10 +636,14 @@ func (p *packetMax) endLine() { |
| if long { |
| return |
| } |
| - pts, dur, ok := strings.Cut(line, ",") |
| - if !ok || strings.Contains(dur, ",") { |
| + // The first two fields; anything after them (ffprobe ends a packet |
| + // that carries side data with an empty field, "0.994000,0.020000," |
| + // on Debian's 7.1.5) is not read. |
| + fields := strings.SplitN(line, ",", 3) |
| + if len(fields) < 2 { |
| return |
| } |
| + pts, dur := fields[0], fields[1] |
| end, ok := parseMicros(pts) |
| if !ok { |
| return |
diff --git a/internal/mediahandler/probe_test.go b/internal/mediahandler/probe_test.go| index af193624f..d567ce8d7 100644 |
| --- a/internal/mediahandler/probe_test.go |
| +++ b/internal/mediahandler/probe_test.go |
| @@ -25,25 +25,32 @@ func fixture(t testing.TB, name string) []byte { |
| return b |
| } |
| -// TestParseProbeFixtures: the facts each fixture yields. The chrome |
| -// WebM has no duration in its header: parseProbe answers 0 and probe |
| -// runs the packet pass (TestDurationFromPacketsWhenTheHeaderHasNone). |
| +// TestParseProbeFixtures: the facts each fixture yields under its |
| +// preset. Most are the real ffprobe's answers (TestRealProbeMatchesFixtures |
| +// keeps them so); the Chrome WebM and av-no-duration have no duration in |
| +// their header, so parseProbe answers 0 and probe runs the packet pass. |
| func TestParseProbeFixtures(t *testing.T) { |
| - cases := map[string]probeFacts{ |
| - "iphone-hevc-hlg-portrait": {VideoIndex: 0, AudioIndex: 1, Width: 1920, Height: 1080, Rotation: -90, FPS: 30, HDR: true, VideoCodec: "hevc", AudioCodec: "aac", Channels: 2, DurationMS: 12345}, |
| - "dolby-vision-8-4": {VideoIndex: 0, AudioIndex: 1, Width: 3840, Height: 2160, Rotation: -90, FPS: 60, HDR: true, DolbyVisionProfile: 8, VideoCodec: "hevc", AudioCodec: "aac", Channels: 2, DurationMS: 8000}, |
| - "vfr-screen-recording": {VideoIndex: 0, AudioIndex: -1, Width: 2880, Height: 1800, FPS: 30000.0 / 1001, VideoCodec: "h264", DurationMS: 95200}, |
| - "chrome-webm-opus": {VideoIndex: -1, AudioIndex: 0, AudioCodec: "opus", Channels: 1, DurationMS: 0}, |
| - "dolby-vision-5": {VideoIndex: 0, AudioIndex: -1, Width: 1920, Height: 1080, FPS: 24000.0 / 1001, HDR: true, DolbyVisionProfile: 5, VideoCodec: "hevc", DurationMS: 20020}, |
| - "mp3-cover-art": {VideoIndex: -1, AudioIndex: 0, AudioCodec: "mp3", Channels: 2, DurationMS: 215485}, |
| - "m4a-cover-art": {VideoIndex: -1, AudioIndex: 0, AudioCodec: "aac", Channels: 2, DurationMS: 180000}, |
| - "mka-cover-art": {VideoIndex: -1, AudioIndex: 1, AudioCodec: "flac", Channels: 2, DurationMS: 240500}, |
| - "h264-4k60": {VideoIndex: 0, AudioIndex: 1, Width: 3840, Height: 2160, FPS: 60, VideoCodec: "h264", AudioCodec: "aac", Channels: 2, DurationMS: 30000}, |
| - "h264-120fps": {VideoIndex: 0, AudioIndex: -1, Width: 1920, Height: 1080, FPS: 120, VideoCodec: "h264", DurationMS: 10000}, |
| - "bomb-30000": {VideoIndex: 0, AudioIndex: -1, Width: 30000, Height: 30000, FPS: 1, VideoCodec: "h264", DurationMS: 1000}, |
| - "lying-10h": {VideoIndex: 0, AudioIndex: -1, Width: 1280, Height: 720, FPS: 30, VideoCodec: "h264", DurationMS: 36000000}, |
| - "wav-mono": {VideoIndex: -1, AudioIndex: 0, AudioCodec: "pcm_s16le", Channels: 1, DurationMS: 62500}, |
| - "aac-6ch": {VideoIndex: -1, AudioIndex: 0, AudioCodec: "aac", Channels: 6, DurationMS: 300011}, |
| + v, a := media.PresetVideo720p, media.PresetAudioAAC |
| + cases := map[string]struct { |
| + preset string |
| + want probeFacts |
| + }{ |
| + "iphone-hevc-hlg-portrait": {v, probeFacts{VideoIndex: 0, AudioIndex: 1, Width: 1920, Height: 1080, Rotation: -90, FPS: 30, HDR: true, VideoCodec: "hevc", AudioCodec: "aac", Channels: 2, DurationMS: 1000}}, |
| + "dolby-vision-8-4": {v, probeFacts{VideoIndex: 0, AudioIndex: 1, Width: 3840, Height: 2160, Rotation: -90, FPS: 60, HDR: true, DolbyVisionProfile: 8, VideoCodec: "hevc", AudioCodec: "aac", Channels: 2, DurationMS: 8000}}, |
| + "vfr-screen-recording": {v, probeFacts{VideoIndex: 0, AudioIndex: -1, Width: 640, Height: 400, FPS: 1800.0 / 59, VideoCodec: "h264", DurationMS: 1967}}, |
| + "chrome-webm-opus": {a, probeFacts{VideoIndex: -1, AudioIndex: 0, AudioCodec: "opus", Channels: 1}}, |
| + "av-no-duration": {a, probeFacts{VideoIndex: -1, AudioIndex: 1, AudioCodec: "opus", Channels: 1}}, |
| + "dolby-vision-5": {v, probeFacts{VideoIndex: 0, AudioIndex: -1, Width: 1920, Height: 1080, FPS: 24000.0 / 1001, HDR: true, DolbyVisionProfile: 5, VideoCodec: "hevc", DurationMS: 20020}}, |
| + "mp3-cover-art": {a, probeFacts{VideoIndex: -1, AudioIndex: 0, AudioCodec: "mp3", Channels: 1, DurationMS: 3031}}, |
| + "m4a-cover-art": {a, probeFacts{VideoIndex: -1, AudioIndex: 0, AudioCodec: "aac", Channels: 1, DurationMS: 3000}}, |
| + "mka-cover-art": {a, probeFacts{VideoIndex: -1, AudioIndex: 0, AudioCodec: "flac", Channels: 1, DurationMS: 2000}}, |
| + "h264-subtitle": {v, probeFacts{VideoIndex: 0, AudioIndex: 1, Width: 160, Height: 90, FPS: 10, VideoCodec: "h264", AudioCodec: "aac", Channels: 1, DurationMS: 2000}}, |
| + "h264-4k60": {v, probeFacts{VideoIndex: 0, AudioIndex: 1, Width: 3840, Height: 2160, FPS: 60, VideoCodec: "h264", AudioCodec: "aac", Channels: 2, DurationMS: 50}}, |
| + "h264-120fps": {v, probeFacts{VideoIndex: 0, AudioIndex: -1, Width: 320, Height: 180, FPS: 120, VideoCodec: "h264", DurationMS: 1000}}, |
| + "bomb-30000": {v, probeFacts{VideoIndex: 0, AudioIndex: -1, Width: 30000, Height: 30000, FPS: 1, VideoCodec: "h264", DurationMS: 1000}}, |
| + "lying-10h": {v, probeFacts{VideoIndex: 0, AudioIndex: -1, Width: 1280, Height: 720, FPS: 30, VideoCodec: "h264", DurationMS: 36000000}}, |
| + "wav-mono": {a, probeFacts{VideoIndex: -1, AudioIndex: 0, AudioCodec: "pcm_s16le", Channels: 1, DurationMS: 2500}}, |
| + "aac-6ch": {a, probeFacts{VideoIndex: -1, AudioIndex: 0, AudioCodec: "aac", Channels: 6, DurationMS: 2000}}, |
| } |
| entries, err := probeFixtures.ReadDir("testdata/probe") |
| if err != nil { |
| @@ -56,18 +63,18 @@ func TestParseProbeFixtures(t *testing.T) { |
| continue |
| } |
| seen++ |
| - want, ok := cases[name] |
| + c, ok := cases[name] |
| if !ok { |
| t.Errorf("fixture %s has no expected facts", name) |
| continue |
| } |
| - got, err := parseProbe(fixture(t, name)) |
| + got, err := parseProbe(fixture(t, name), c.preset) |
| if err != nil { |
| t.Errorf("%s: %v", name, err) |
| continue |
| } |
| - if got != want { |
| - t.Errorf("%s:\n got %+v\nwant %+v", name, got, want) |
| + if got != c.want { |
| + t.Errorf("%s:\n got %+v\nwant %+v", name, got, c.want) |
| } |
| } |
| if seen != len(cases) { |
| @@ -112,7 +119,7 @@ func TestParseProbeRules(t *testing.T) { |
| {"second video ignored", `{"streams":[{"index":0,"codec_type":"video","codec_name":"av1","width":10,"height":20},{"index":1,"codec_type":"video","codec_name":"mpeg2video","width":30000,"height":30000}],"format":{"duration":"1"}}`, func(f probeFacts) bool { return f.VideoCodec == "av1" && f.Width == 10 }}, |
| } |
| for _, c := range cases { |
| - f, err := parseProbe([]byte(c.json)) |
| + f, err := parseProbe([]byte(c.json), media.PresetVideo720p) |
| if err != nil { |
| t.Errorf("%s: %v", c.name, err) |
| continue |
| @@ -141,7 +148,7 @@ func TestParseProbeRules(t *testing.T) { |
| "bad rotate tag": `{"streams":[{"index":0,"codec_type":"video","codec_name":"h264","width":2,"height":2,"tags":{"rotate":"up"}}]}`, |
| "a top-level array": `[]`, |
| } { |
| - if f, err := parseProbe([]byte(j)); err == nil { |
| + if f, err := parseProbe([]byte(j), media.PresetVideo720p); err == nil { |
| t.Errorf("%s: parseProbe accepted it: %+v", name, f) |
| } |
| } |
| @@ -153,14 +160,14 @@ func TestParseProbeRules(t *testing.T) { |
| // is 0/0. |
| func TestFrameRateUsesTheAverage(t *testing.T) { |
| l := media.JobLimits{GrantedMS: 600000, GrantedBy: grantedByClass, MaxMS: 7200000, MaxHiMS: 1800000} |
| - vfr, err := parseProbe(fixture(t, "vfr-screen-recording")) |
| + vfr, err := parseProbe(fixture(t, "vfr-screen-recording"), media.PresetVideo720p) |
| if err != nil { |
| t.Fatal(err) |
| } |
| if err := check(vfr, media.PresetVideo720p, l); err != nil { |
| t.Errorf("VFR recording (avg 29.97, r 120): %v, want it to convert", err) |
| } |
| - fast, err := parseProbe(fixture(t, "h264-120fps")) |
| + fast, err := parseProbe(fixture(t, "h264-120fps"), media.PresetVideo720p) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -178,7 +185,7 @@ func TestFrameRateUsesTheAverage(t *testing.T) { |
| {"60/1", "90000/1", 60}, |
| } { |
| j := `{"streams":[{"index":0,"codec_type":"video","codec_name":"h264","width":2,"height":2,"avg_frame_rate":"` + c.avg + `","r_frame_rate":"` + c.r + `"}]}` |
| - f, err := parseProbe([]byte(j)) |
| + f, err := parseProbe([]byte(j), media.PresetVideo720p) |
| if err != nil || f.FPS != c.want { |
| t.Errorf("avg %q r %q: FPS %v, %v; want %v", c.avg, c.r, f.FPS, err, c.want) |
| } |
| @@ -192,7 +199,7 @@ func TestFrameRateUsesTheAverage(t *testing.T) { |
| func TestAttachedPictureIsNotVideo(t *testing.T) { |
| l := media.JobLimits{GrantedMS: 7200000, GrantedBy: grantedByClass, MaxMS: 28800000} |
| for _, name := range []string{"m4a-cover-art", "mka-cover-art"} { |
| - f, err := parseProbe(fixture(t, name)) |
| + f, err := parseProbe(fixture(t, name), media.PresetVideo720p) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -201,7 +208,7 @@ func TestAttachedPictureIsNotVideo(t *testing.T) { |
| } |
| } |
| for _, name := range []string{"m4a-cover-art", "mka-cover-art", "mp3-cover-art"} { |
| - f, err := parseProbe(fixture(t, name)) |
| + f, err := parseProbe(fixture(t, name), media.PresetAudioAAC) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -323,14 +330,14 @@ func TestDolbyVision5RefusedWhenTheSpikeSaysSo(t *testing.T) { |
| old := refuseDolbyVision5 |
| refuseDolbyVision5 = true |
| t.Cleanup(func() { refuseDolbyVision5 = old }) |
| - dv5, err := parseProbe(fixture(t, "dolby-vision-5")) |
| + dv5, err := parseProbe(fixture(t, "dolby-vision-5"), media.PresetVideo720p) |
| if err != nil { |
| t.Fatal(err) |
| } |
| if code := codeOf(check(dv5, media.PresetVideo720p, limitsFor(media.PresetVideo720p))); code != media.CodeUnsupportedHDR { |
| t.Errorf("dolby vision 5: %s, want unsupported_hdr", code) |
| } |
| - dv8, err := parseProbe(fixture(t, "dolby-vision-8-4")) |
| + dv8, err := parseProbe(fixture(t, "dolby-vision-8-4"), media.PresetVideo720p) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -384,7 +391,7 @@ func TestCheckOrder(t *testing.T) { |
| // 4-second stream is believed (the header is what the job is held to), |
| // and is source_too_long, not converted. |
| func TestLyingDurationIsTooLong(t *testing.T) { |
| - f, err := parseProbe(fixture(t, "lying-10h")) |
| + f, err := parseProbe(fixture(t, "lying-10h"), media.PresetVideo720p) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -397,18 +404,18 @@ func TestLyingDurationIsTooLong(t *testing.T) { |
| // before anything decodes it; so are a side over MaxSide and a frame |
| // over MaxDimensions' pixels. |
| func TestBombIsDimensions(t *testing.T) { |
| - f, err := parseProbe(fixture(t, "bomb-30000")) |
| + f, err := parseProbe(fixture(t, "bomb-30000"), media.PresetVideo720p) |
| if err != nil { |
| t.Fatal(err) |
| } |
| if code := codeOf(check(f, media.PresetVideo720p, limitsFor(media.PresetVideo720p))); code != media.CodeSourceDimensions { |
| t.Errorf("30000x30000: %s, want source_dimensions", code) |
| } |
| - if maxPixels != 3840*2160 { |
| - t.Errorf("maxPixels = %d, want media.MaxDimensions' 3840x2160", maxPixels) |
| + if fmt.Sprintf("%dx%d", 3840, 2160) != media.MaxDimensions || media.MaxPixels != 3840*2160 { |
| + t.Errorf("media.MaxPixels %d is not media.MaxDimensions %s", media.MaxPixels, media.MaxDimensions) |
| } |
| // The 4K60 fixture is at every video limit, and converts. |
| - ok, err := parseProbe(fixture(t, "h264-4k60")) |
| + ok, err := parseProbe(fixture(t, "h264-4k60"), media.PresetVideo720p) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -432,14 +439,17 @@ func FuzzParseProbe(f *testing.F) { |
| } |
| f.Add([]byte(`{"streams":[{"index":0,"codec_type":"video","codec_name":"h264","width":-1,"height":-1}],"format":{"duration":"-1"}}`)) |
| f.Fuzz(func(t *testing.T, b []byte) { |
| - facts, err := parseProbe(b) |
| - if err != nil { |
| - return |
| - } |
| - if facts.Channels < 0 || facts.DurationMS < 0 || facts.FPS < 0 || facts.Width < 0 || facts.Height < 0 { |
| - t.Fatalf("parseProbe yielded %+v", facts) |
| - } |
| for _, preset := range []string{media.PresetVideo720p, media.PresetAudioAAC} { |
| + facts, err := parseProbe(b, preset) |
| + if err != nil { |
| + continue |
| + } |
| + if facts.Channels < 0 || facts.DurationMS < 0 || facts.FPS < 0 || facts.Width < 0 || facts.Height < 0 { |
| + t.Fatalf("%s: parseProbe yielded %+v", preset, facts) |
| + } |
| + if preset == media.PresetAudioAAC && facts.VideoIndex != -1 { |
| + t.Fatalf("audio-aac took a video stream: %+v", facts) |
| + } |
| if check(facts, preset, limitsFor(preset)) != nil { |
| continue |
| } |
| @@ -473,29 +483,33 @@ func TestProbeArgs(t *testing.T) { |
| needChildren(t) |
| t.Setenv(media.PayloadEnv, "a payload that must not reach the child") |
| cfg, record := fakeConfig(t, "probe-iphone-hevc-hlg-portrait") |
| - if _, err := probe(context.Background(), cfg, "mov"); err != nil { |
| + if _, err := probe(context.Background(), cfg, "mov", media.PresetVideo720p); err != nil { |
| t.Fatal(err) |
| } |
| cfg2, record2 := fakeConfig(t, "probe-chrome-webm-opus") |
| - if _, err := probe(context.Background(), cfg2, "matroska"); err != nil { |
| + if _, err := probe(context.Background(), cfg2, "matroska", media.PresetAudioAAC); err != nil { |
| t.Fatal(err) |
| } |
| runs := append(fakeRuns(t, record), fakeRuns(t, record2)...) |
| if len(runs) != 3 { |
| t.Fatalf("%d ffprobe runs, want 3 (the mov, the webm and its packet pass)", len(runs)) |
| } |
| + // No -codec_whitelist (fix 1: ffprobe opens a decoder for every |
| + // stream and exits on one off the list), no -nostats (ffprobe has |
| + // none), and -show_entries naming only what parseProbe reads. |
| want := func(demuxer string, cfg Config, extra ...string) []string { |
| a := []string{"-hide_banner", "-loglevel", "error", "-protocol_whitelist", "file", "-f", demuxer} |
| if demuxer == "mov" { |
| a = append(a, "-enable_drefs", "0") |
| } |
| - a = append(a, "-codec_whitelist", "h264,hevc,vp8,vp9,av1,libdav1d,aac,opus,libopus,vorbis,libvorbis,mp3,mp3float,flac,pcm_u8,pcm_s16le,pcm_s16be,pcm_s24le,pcm_s24be,pcm_s32le,pcm_s32be,pcm_f32le,pcm_f32be,pcm_f64le,pcm_f64be,pcm_alaw,pcm_mulaw") |
| + a = append(a, "-max_pixels", "16777216") |
| a = append(a, extra...) |
| return append(a, "-i", filepath.Join(cfg.Scratch, "in", "source")) |
| } |
| + entries := "format=duration:stream=index,codec_type,codec_name,width,height,avg_frame_rate,r_frame_rate,color_transfer,channels,duration:stream_disposition=attached_pic:stream_tags=rotate:stream_side_data=side_data_type,rotation,dv_profile" |
| for i, w := range [][]string{ |
| - want("mov", cfg, "-show_format", "-show_streams", "-of", "json"), |
| - want("matroska", cfg2, "-show_format", "-show_streams", "-of", "json"), |
| + want("mov", cfg, "-show_entries", entries, "-of", "json"), |
| + want("matroska", cfg2, "-show_entries", entries, "-of", "json"), |
| want("matroska", cfg2, "-select_streams", "0", "-show_entries", "packet=pts_time,duration_time", "-of", "csv=p=0"), |
| } { |
| if !slices.Equal(runs[i].Args, w) { |
| @@ -507,6 +521,80 @@ func TestProbeArgs(t *testing.T) { |
| } |
| } |
| } |
| + // ffmpeg's input: the same shared options, quiet, no stdin, and the |
| + // decoder allow-list. |
| + wantFF := []string{"-hide_banner", "-nostats", "-loglevel", "error", "-nostdin", |
| + "-protocol_whitelist", "file", "-f", "mov", "-enable_drefs", "0", "-max_pixels", "16777216", |
| + "-codec_whitelist", "h264,hevc,vp8,vp9,av1,libdav1d,aac,opus,libopus,vorbis,libvorbis,mp3,mp3float,flac,pcm_u8,pcm_s16le,pcm_s16be,pcm_s24le,pcm_s24be,pcm_s32le,pcm_s32be,pcm_f32le,pcm_f32be,pcm_f64le,pcm_f64be,pcm_alaw,pcm_mulaw", |
| + "-i", filepath.Join(cfg.Scratch, "in", "source")} |
| + if got := ffmpegInputArgs(cfg, "mov"); !slices.Equal(got, wantFF) { |
| + t.Errorf("ffmpegInputArgs:\n got %q\nwant %q", got, wantFF) |
| + } |
| + if maxDecodePixels != media.MaxSide*media.MaxSide || maxDecodePixels <= media.MaxPixels { |
| + t.Errorf("maxDecodePixels = %d", maxDecodePixels) |
| + } |
| +} |
| + |
| +// TestPacketPassStreamFollowsThePreset (Astra P2, Fable): with no |
| +// duration in the header, the packet pass reads the audio stream under |
| +// audio-aac and the video stream under video-720p. |
| +func TestPacketPassStreamFollowsThePreset(t *testing.T) { |
| + needChildren(t) |
| + for _, c := range []struct{ preset, stream string }{{media.PresetAudioAAC, "1"}, {media.PresetVideo720p, "0"}} { |
| + cfg, record := fakeConfig(t, "probe-av-no-duration") |
| + if _, err := probe(context.Background(), cfg, "matroska", c.preset); err != nil { |
| + t.Fatalf("%s: %v", c.preset, err) |
| + } |
| + runs := fakeRuns(t, record) |
| + if len(runs) != 2 { |
| + t.Fatalf("%s: %d runs", c.preset, len(runs)) |
| + } |
| + i := slices.Index(runs[1].Args, "-select_streams") |
| + if i < 0 || runs[1].Args[i+1] != c.stream { |
| + t.Errorf("%s: packet pass %q, want stream %s", c.preset, runs[1].Args, c.stream) |
| + } |
| + } |
| +} |
| + |
| +// TestParseProbeAudioIgnoresVideo (Astra P2, Fable): under audio-aac |
| +// the video stream is not read at all: a malformed frame rate, a |
| +// negative size or a longer duration on it changes nothing. Under |
| +// video-720p the same answer is refused. Streams neither preset takes |
| +// are never validated. |
| +func TestParseProbeAudioIgnoresVideo(t *testing.T) { |
| + j := []byte(`{"streams":[` + |
| + `{"index":0,"codec_type":"video","codec_name":"h264","width":-1,"height":2,"avg_frame_rate":"thirty","duration":"9.0"},` + |
| + `{"index":1,"codec_type":"audio","codec_name":"opus","channels":2,"duration":"3.0"},` + |
| + `{"index":2,"codec_type":"data","width":-5,"channels":-1}],"format":{}}`) |
| + f, err := parseProbe(j, media.PresetAudioAAC) |
| + if err != nil { |
| + t.Fatalf("audio-aac: %v", err) |
| + } |
| + if want := (probeFacts{VideoIndex: -1, AudioIndex: 1, AudioCodec: "opus", Channels: 2, DurationMS: 3000}); f != want { |
| + t.Errorf("audio-aac: %+v, want %+v", f, want) |
| + } |
| + if _, err := parseProbe(j, media.PresetVideo720p); err == nil { |
| + t.Error("video-720p accepted a negative width and a malformed frame rate") |
| + } |
| + // Unequal stream durations, no header: video-720p takes the longest |
| + // taken stream, audio-aac the audio's. |
| + j = []byte(`{"streams":[{"index":0,"codec_type":"video","codec_name":"h264","width":2,"height":2,"duration":"1.0"},` + |
| + `{"index":1,"codec_type":"audio","codec_name":"aac","duration":"3.0"},{"index":2,"codec_type":"subtitle","duration":"99.0"}],"format":{}}`) |
| + for preset, want := range map[string]int64{media.PresetAudioAAC: 3000, media.PresetVideo720p: 3000} { |
| + if f, err := parseProbe(j, preset); err != nil || f.DurationMS != want { |
| + t.Errorf("%s: %d, %v; want %d", preset, f.DurationMS, err, want) |
| + } |
| + } |
| + j = []byte(`{"streams":[{"index":0,"codec_type":"video","codec_name":"h264","width":2,"height":2,"duration":"5.0"},` + |
| + `{"index":1,"codec_type":"audio","codec_name":"aac","duration":"3.0"}],"format":{}}`) |
| + for preset, want := range map[string]int64{media.PresetAudioAAC: 3000, media.PresetVideo720p: 5000} { |
| + if f, err := parseProbe(j, preset); err != nil || f.DurationMS != want { |
| + t.Errorf("%s: %d, %v; want %d", preset, f.DurationMS, err, want) |
| + } |
| + } |
| + if _, err := parseProbe(j, "video-4k"); err == nil { |
| + t.Error("an unknown preset parsed") |
| + } |
| } |
| // TestDurationFromPacketsWhenTheHeaderHasNone (Review Focus 3): a |
| @@ -517,13 +605,13 @@ func TestProbeArgs(t *testing.T) { |
| func TestDurationFromPacketsWhenTheHeaderHasNone(t *testing.T) { |
| needChildren(t) |
| cfg, record := fakeConfig(t, "probe-chrome-webm-opus") |
| - f, err := probe(context.Background(), cfg, "matroska") |
| + f, err := probe(context.Background(), cfg, "matroska", media.PresetAudioAAC) |
| if err != nil { |
| t.Fatal(err) |
| } |
| - // 5.980000 + 0.020000 = 6.000000 s. |
| - if f.DurationMS != 6000 { |
| - t.Errorf("DurationMS = %d, want 6000", f.DurationMS) |
| + // The last packet, "0.994000,0.020000," (it carries side data): 1.014 s. |
| + if f.DurationMS != 1014 { |
| + t.Errorf("DurationMS = %d, want 1014", f.DurationMS) |
| } |
| if err := check(f, media.PresetAudioAAC, limitsFor(media.PresetAudioAAC)); err != nil { |
| t.Errorf("check: %v, want it to convert", err) |
| @@ -533,7 +621,7 @@ func TestDurationFromPacketsWhenTheHeaderHasNone(t *testing.T) { |
| } |
| // A source whose header has a duration gets one pass only. |
| cfg, record = fakeConfig(t, "probe-wav-mono") |
| - if _, err := probe(context.Background(), cfg, "wav"); err != nil { |
| + if _, err := probe(context.Background(), cfg, "wav", media.PresetAudioAAC); err != nil { |
| t.Fatal(err) |
| } |
| if n := len(fakeRuns(t, record)); n != 1 { |
| @@ -552,7 +640,8 @@ func TestPacketDuration(t *testing.T) { |
| {"-0.021333,0.021333\n0.000000,0.021333\n", 22}, |
| {"garbage\n2.0,0.5\nNaN,1\n1e9,1\n", 2500}, |
| {"2.0,0.5", 2500}, // no final newline |
| - {"3.0,0.25,side\n", 0}, |
| + {"3.0,0.25,side\n", 3250}, |
| + {"0.994000,0.020000,\n", 1014}, // a packet with side data (Debian 7.1.5) |
| {strings.Repeat("9", 300) + ",1\n1.0,0.0\n", 1000}, // an overlong line is skipped |
| {"", 0}, |
| {"N/A,N/A\n", 0}, |
| @@ -586,13 +675,13 @@ func TestProbeFailuresAreUnreadable(t *testing.T) { |
| // The JSON of the webm, whose packet pass then fails. |
| cfg.extraEnv = []string{fakeEnv + "=probe-chrome-webm-opus", fakeNoPacketsEnv + "=1"} |
| } |
| - if _, err := probe(context.Background(), cfg, "matroska"); codeOf(err) != media.CodeUnreadable { |
| + if _, err := probe(context.Background(), cfg, "matroska", media.PresetAudioAAC); codeOf(err) != media.CodeUnreadable { |
| t.Errorf("%s: %s, want unreadable", scenario, codeOf(err)) |
| } |
| } |
| cfg, _ := fakeConfig(t, "probe-wav-mono") |
| cfg.FFprobe = filepath.Join(t.TempDir(), "no-ffprobe") |
| - if _, err := probe(context.Background(), cfg, "wav"); codeOf(err) != media.CodeEngineFailed { |
| + if _, err := probe(context.Background(), cfg, "wav", media.PresetAudioAAC); codeOf(err) != media.CodeEngineFailed { |
| t.Errorf("missing ffprobe: %s, want engine_failed", codeOf(err)) |
| } |
| } |
| @@ -611,7 +700,7 @@ func TestProbeTimeoutIsUnreadable(t *testing.T) { |
| var logs []string |
| cfg.Logf = func(format string, args ...any) { logs = append(logs, fmt.Sprintf(format, args...)) } |
| start := time.Now() |
| - _, err := probe(context.Background(), cfg, "mov") |
| + _, err := probe(context.Background(), cfg, "mov", media.PresetVideo720p) |
| if codeOf(err) != media.CodeUnreadable { |
| t.Errorf("timeout: %s, want unreadable", codeOf(err)) |
| } |
| @@ -625,7 +714,7 @@ func TestProbeTimeoutIsUnreadable(t *testing.T) { |
| cfg.probeTimeout = time.Hour |
| ctx, cancel := context.WithCancel(context.Background()) |
| done := make(chan error, 1) |
| - go func() { _, err := probe(ctx, cfg, "mov"); done <- err }() |
| + go func() { _, err := probe(ctx, cfg, "mov", media.PresetVideo720p); done <- err }() |
| cancel() |
| select { |
| case err := <-done: |
| @@ -638,20 +727,20 @@ func TestProbeTimeoutIsUnreadable(t *testing.T) { |
| } |
| // TestProbeLogsTheStderrTail: a failing ffprobe's stderr reaches the |
| -// log on one line, quoted, at most 64 KiB, its last lines kept. |
| +// log on one line, quoted, its last 4 KiB only. |
| func TestProbeLogsTheStderrTail(t *testing.T) { |
| needChildren(t) |
| cfg, _ := fakeConfig(t, "noisy") |
| var logs []string |
| cfg.Logf = func(format string, args ...any) { logs = append(logs, strings.TrimSpace(fmt.Sprintf(format, args...))) } |
| - if _, err := probe(context.Background(), cfg, "mov"); codeOf(err) != media.CodeUnreadable { |
| + if _, err := probe(context.Background(), cfg, "mov", media.PresetVideo720p); codeOf(err) != media.CodeUnreadable { |
| t.Fatalf("%s, want unreadable", codeOf(err)) |
| } |
| if len(logs) != 1 { |
| t.Fatalf("logs %q, want one line", logs) |
| } |
| l := logs[0] |
| - if strings.Contains(l, "\n") || len(l) > stderrTailBytes*2+100 { |
| + if strings.Contains(l, "\n") || len(l) > probeLogTail*2+100 || len(l) < probeLogTail { |
| t.Errorf("log line: %d bytes, newline %v", len(l), strings.Contains(l, "\n")) |
| } |
| if !strings.Contains(l, "line 0999") || strings.Contains(l, "line 0000") { |
| @@ -716,7 +805,7 @@ func TestCodecWhitelistMatchesTheChecks(t *testing.T) { |
| t.Errorf("allow-listed %s is refused by check", name) |
| } |
| } |
| - if _, err := os.Stat("testdata/probe/stand-ins.txt"); err != nil { |
| - t.Errorf("the stand-in fixtures are not marked: %v", err) |
| + if _, err := os.Stat("testdata/probe/provenance.txt"); err != nil { |
| + t.Errorf("the fixtures' provenance is not recorded: %v", err) |
| } |
| } |
diff --git a/internal/mediahandler/procs_linux.go b/internal/mediahandler/procs_linux.go| index 43cb5e186..4deb4b7c4 100644 |
| --- a/internal/mediahandler/procs_linux.go |
| +++ b/internal/mediahandler/procs_linux.go |
| @@ -45,8 +45,9 @@ func runChild(ctx context.Context, cfg Config, name string, args []string, dir s |
| // that started it ends (Pdeathsig; that thread is locked to this |
| // goroutine from Start to the end of the wait, preflight F35), and |
| // has an explicit, minimal environment (childEnv) and no stdin; |
| -// - when it exits or ctx ends: SIGKILL to its process group (the |
| -// group cannot be reused while the unreaped child holds it), the |
| +// - when it exits or ctx ends: SIGKILL to its process group and to |
| +// the child itself (neither pid nor group can be reused while the |
| +// unreaped child holds them), the |
| // direct child reaped by cmd.Wait first (F35), then, repeatedly, |
| // SIGKILL to every remaining child of the handler (from |
| // /proc/*/stat) and wait4(-1, WNOHANG), until ECHILD; all of it |
| @@ -120,7 +121,10 @@ func runChildTo(ctx context.Context, cfg Config, name string, args []string, dir |
| } |
| budget := time.NewTimer(reapBudget) |
| defer budget.Stop() |
| + // The group, and the child itself: a child that moved itself into |
| + // another process group (setpgid) is not in its own (Fable I1). |
| _ = unix.Kill(-pid, unix.SIGKILL) |
| + _ = unix.Kill(pid, unix.SIGKILL) |
| select { |
| case <-exited: |
| case <-budget.C: |
diff --git a/internal/mediahandler/procs_test.go b/internal/mediahandler/procs_test.go| index ebae010c6..08516e10d 100644 |
| --- a/internal/mediahandler/procs_test.go |
| +++ b/internal/mediahandler/procs_test.go |
| @@ -37,6 +37,17 @@ func init() { |
| fakeScenarios["escape"] = func([]string) int { return fakeEscape(false) } |
| fakeScenarios["escape-block"] = func([]string) int { return fakeEscape(true) } |
| fakeScenarios["escape-grandchild"] = fakeEscapeGrandchild |
| + // join-parent-group moves itself into its parent's process group |
| + // (out of the one runChild gave it), prints its pid and "ready", |
| + // and blocks. |
| + fakeScenarios["join-parent-group"] = func([]string) int { |
| + pgid, err := unix.Getpgid(os.Getppid()) |
| + if err != nil || unix.Setpgid(0, pgid) != nil { |
| + return 1 |
| + } |
| + fmt.Printf("pid %d\nready\n", os.Getpid()) |
| + return blockForever() |
| + } |
| // pid-block prints its pid and blocks. |
| fakeScenarios["pid-block"] = func([]string) int { |
| fmt.Printf("pid %d\n", os.Getpid()) |
| @@ -237,6 +248,45 @@ func TestRunChildKillsEscapedDescendants(t *testing.T) { |
| } |
| } |
| +// TestRunChildKillsAChildThatLeftItsGroup (Fable I1): a child that |
| +// moved itself into the handler's process group escapes the group |
| +// kill; runChild kills the pid too, so cancelling returns |
| +// context.Canceled at once and leaves nothing behind. |
| +func TestRunChildKillsAChildThatLeftItsGroup(t *testing.T) { |
| + cfg, _ := fakeConfig(t, "join-parent-group") |
| + ctx, cancel := context.WithCancel(context.Background()) |
| + defer cancel() |
| + var mu sync.Mutex |
| + pid := 0 |
| + w := &lineWriter{onLine: func(l string) { |
| + if n, ok := strings.CutPrefix(l, "pid "); ok { |
| + mu.Lock() |
| + pid, _ = strconv.Atoi(n) |
| + mu.Unlock() |
| + } |
| + if l == "ready" { |
| + cancel() |
| + } |
| + }} |
| + start := time.Now() |
| + _, err := runChildTo(ctx, cfg, cfg.FFmpeg, nil, "", w) |
| + if !errors.Is(err, context.Canceled) { |
| + t.Errorf("runChild = %v, want context.Canceled", err) |
| + } |
| + if d := time.Since(start); d > reapBudget/2 { |
| + t.Errorf("runChild took %s", d) |
| + } |
| + mu.Lock() |
| + defer mu.Unlock() |
| + if pid == 0 { |
| + t.Fatal("the fake printed no pid") |
| + } |
| + if exists(pid) { |
| + t.Errorf("the child (%d) still exists", pid) |
| + _ = unix.Kill(pid, unix.SIGKILL) |
| + } |
| +} |
| + |
| // TestRunChildPdeathsig: when the handler itself dies (SIGKILL, so it |
| // cleans up nothing), the child it started dies too: Pdeathsig. |
| func TestRunChildPdeathsig(t *testing.T) { |
diff --git a/internal/mediahandler/realffmpeg_test.go b/internal/mediahandler/realffmpeg_test.go| new file mode 100644 |
| index 000000000..99e64931e |
| --- /dev/null |
| +++ b/internal/mediahandler/realffmpeg_test.go |
| @@ -0,0 +1,440 @@ |
| +//go:build linux |
| + |
| +package mediahandler |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "fmt" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strconv" |
| + "strings" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/media" |
| +) |
| + |
| +// Tests against a real ffmpeg and ffprobe. They skip unless |
| +// CARLOS_MEDIA_FFMPEG and CARLOS_MEDIA_FFPROBE name the binaries, so CI |
| +// stays green without ffmpeg; Debian 13's 7.1.5, unpacked without root, |
| +// is what they were written against (plan 3 Task 3 fix 1 report). An |
| +// LD_LIBRARY_PATH in the test's environment is passed to the children. |
| +// |
| +// Every source is made here by the real ffmpeg, from lavfi's test |
| +// patterns, so nothing in them is hand-written. With |
| +// CARLOS_MEDIA_REGEN_FIXTURES=1, TestRegenerateProbeFixtures rewrites |
| +// testdata/probe from them. |
| +const ( |
| + realFFmpegEnv = "CARLOS_MEDIA_FFMPEG" |
| + realFFprobeEnv = "CARLOS_MEDIA_FFPROBE" |
| + regenEnv = "CARLOS_MEDIA_REGEN_FIXTURES" |
| +) |
| + |
| +// realConfig is a Config on the real binaries with a prepared scratch, |
| +// or skips t. |
| +func realConfig(t *testing.T) Config { |
| + t.Helper() |
| + ffmpeg, ffprobe := os.Getenv(realFFmpegEnv), os.Getenv(realFFprobeEnv) |
| + if ffmpeg == "" || ffprobe == "" { |
| + t.Skipf("set %s and %s to run against a real ffmpeg", realFFmpegEnv, realFFprobeEnv) |
| + } |
| + cfg := Config{FFmpeg: ffmpeg, FFprobe: ffprobe, Scratch: t.TempDir(), Logf: t.Logf} |
| + if v := os.Getenv("LD_LIBRARY_PATH"); v != "" { |
| + cfg.extraEnv = []string{"LD_LIBRARY_PATH=" + v} |
| + } |
| + if err := prepareScratch(cfg.Scratch); err != nil { |
| + t.Fatal(err) |
| + } |
| + return cfg.withDefaults() |
| +} |
| + |
| +// recipe makes one source with the real ffmpeg: args after the global |
| +// options; "OUT" is the output path, "COVER" a 64x64 JPEG. pipe sends |
| +// the output through a pipe, so the muxer cannot seek back and write a |
| +// duration (as a browser's MediaRecorder does not). |
| +type recipe struct { |
| + demuxer, preset string |
| + args string |
| + pipe bool |
| +} |
| + |
| +var recipes = map[string]recipe{ |
| + // The four stand-ins for Paul's files, made by ffmpeg. |
| + "iphone-hevc-hlg-portrait": {"mov", media.PresetVideo720p, |
| + "-f lavfi -i testsrc2=size=1920x1080:rate=30:d=1 -f lavfi -i sine=d=1:sample_rate=44100 -ac 2 " + |
| + "-c:v libx265 -preset ultrafast -x265-params log-level=error:colorprim=bt2020:transfer=arib-std-b67:colormatrix=bt2020nc -pix_fmt yuv420p10le -color_primaries bt2020 -color_trc arib-std-b67 -colorspace bt2020nc " + |
| + "-c:a aac -b:a 64k -metadata location=+48.8584+002.2945/ -f mp4 OUT.tmp.mp4 && -display_rotation:v:0 -90 -i OUT.tmp.mp4 -c copy -f mp4 OUT", false}, |
| + "vfr-screen-recording": {"mov", media.PresetVideo720p, |
| + "-f lavfi -i testsrc=size=640x400:rate=120:d=2 -vf select='eq(mod(n\\,8)\\,0)+eq(mod(n\\,8)\\,3)' -fps_mode vfr -c:v libx264 -preset ultrafast -f mp4 OUT", false}, |
| + "chrome-webm-opus": {"matroska", media.PresetAudioAAC, |
| + "-f lavfi -i sine=d=1.01 -c:a libopus -f webm OUT", true}, |
| + // No header durations, video 1 s and audio 3 s. |
| + "av-no-duration": {"matroska", media.PresetAudioAAC, |
| + "-f lavfi -i testsrc=size=160x90:rate=10:d=1 -f lavfi -i sine=d=3 -c:v libvpx -deadline realtime -c:a libopus -f matroska OUT", true}, |
| + "mp3-cover-art": {"mp3", media.PresetAudioAAC, |
| + "-f lavfi -i sine=d=3 -i COVER -map 0:a -map 1:v -c:a libmp3lame -b:a 32k -c:v copy -disposition:v attached_pic -id3v2_version 3 -f mp3 OUT", false}, |
| + "m4a-cover-art": {"mov", media.PresetAudioAAC, |
| + "-f lavfi -i sine=d=3 -i COVER -map 0:a -map 1:v -c:a aac -b:a 32k -c:v copy -disposition:v attached_pic -f ipod OUT", false}, |
| + "mka-cover-art": {"matroska", media.PresetAudioAAC, |
| + "-f lavfi -i sine=d=2 -c:a flac -attach COVER -metadata:s:t:0 mimetype=image/jpeg -metadata:s:t:0 filename=cover.jpg -f matroska OUT", false}, |
| + "h264-subtitle": {"mov", media.PresetVideo720p, |
| + "-f lavfi -i testsrc=size=160x90:rate=10:d=2 -f lavfi -i sine=d=2 -f srt -i SUBS -map 0 -map 1 -map 2 -c:v libx264 -preset ultrafast -c:a aac -c:s mov_text -f mp4 OUT", false}, |
| + "h264-4k60": {"mov", media.PresetVideo720p, |
| + "-f lavfi -i testsrc=size=3840x2160:rate=60:d=0.05 -f lavfi -i sine=d=0.05 -ac 2 -c:v libx264 -preset ultrafast -c:a aac -f mp4 OUT", false}, |
| + "h264-120fps": {"mov", media.PresetVideo720p, |
| + "-f lavfi -i testsrc=size=320x180:rate=120:d=1 -c:v libx264 -preset ultrafast -f mp4 OUT", false}, |
| + "wav-mono": {"wav", media.PresetAudioAAC, |
| + "-f lavfi -i sine=d=2.5 -ac 1 -c:a pcm_s16le -f wav OUT", false}, |
| + "aac-6ch": {"mov", media.PresetAudioAAC, |
| + "-f lavfi -i sine=d=2 -af pan=5.1|c0=c0|c1=c0|c2=c0|c3=c0|c4=c0|c5=c0 -c:a aac -f ipod OUT", false}, |
| + // For the pixel bounds: a portrait 4K, which check accepts and whose |
| + // aligned size is over media.MaxPixels; over media.MaxPixels; over |
| + // the decoders' bound. |
| + "uhd-portrait": {"mov", media.PresetVideo720p, "-f lavfi -i testsrc=size=2160x3840:rate=1:d=1 -c:v libx264 -preset ultrafast -f mp4 OUT", false}, |
| + "over-pixels": {"mov", media.PresetVideo720p, "-f lavfi -i testsrc=size=4096x2304:rate=1:d=1 -c:v libx264 -preset ultrafast -f mp4 OUT", false}, |
| + "over-decoders": {"mov", media.PresetVideo720p, "-f lavfi -i testsrc=size=4352x4352:rate=1:d=1 -c:v libx264 -preset ultrafast -f mp4 OUT", false}, |
| + // Metadata that must never reach a log (preflight F19). |
| + "location": {"mov", media.PresetVideo720p, |
| + "-f lavfi -i testsrc=size=160x90:rate=10:d=1 -c:v libx264 -preset ultrafast -metadata location=+48.8584+002.2945/ -metadata title=TITLE-SECRET-7 -metadata comment=COMMENT-SECRET-7 -f mov OUT", false}, |
| +} |
| + |
| +// makeSource makes name's source with the real ffmpeg at |
| +// <scratch>/in/source, replacing what is there. |
| +func makeSource(t *testing.T, cfg Config, name string) recipe { |
| + t.Helper() |
| + r, ok := recipes[name] |
| + if !ok { |
| + t.Fatalf("no recipe %s", name) |
| + } |
| + dir := t.TempDir() |
| + out := sourcePath(cfg) |
| + _ = os.Remove(out) |
| + cover := filepath.Join(dir, "cover.jpg") |
| + subs := filepath.Join(dir, "subs.srt") |
| + if err := os.WriteFile(subs, []byte("1\n00:00:00,000 --> 00:00:01,000\nhello\n"), 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + runFFmpeg(t, cfg, nil, "-f lavfi -i testsrc=size=64x64:rate=1 -frames:v 1 -f image2 "+cover) |
| + for i, step := range strings.Split(r.args, " && ") { |
| + step = strings.NewReplacer("OUT.tmp", filepath.Join(dir, "tmp"), "COVER", cover, "SUBS", subs).Replace(step) |
| + last := i == len(strings.Split(r.args, " && "))-1 |
| + if !last { |
| + runFFmpeg(t, cfg, nil, step) |
| + continue |
| + } |
| + if r.pipe { |
| + var b bytes.Buffer |
| + runFFmpeg(t, cfg, &b, strings.Replace(step, "OUT", "pipe:1", 1)) |
| + if err := os.WriteFile(out, b.Bytes(), 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + } else { |
| + runFFmpeg(t, cfg, nil, strings.Replace(step, "OUT", out, 1)) |
| + } |
| + } |
| + return r |
| +} |
| + |
| +// runFFmpeg runs the real ffmpeg directly (not through runChild: this |
| +// makes test sources) with args split on spaces. |
| +func runFFmpeg(t *testing.T, cfg Config, stdout *bytes.Buffer, args string) { |
| + t.Helper() |
| + cmd := exec.Command(cfg.FFmpeg, append([]string{"-hide_banner", "-loglevel", "error", "-nostdin", "-y"}, strings.Fields(args)...)...) |
| + var stderr bytes.Buffer |
| + cmd.Stderr = &stderr |
| + if stdout != nil { |
| + cmd.Stdout = stdout |
| + } |
| + if err := cmd.Run(); err != nil { |
| + t.Fatalf("ffmpeg %s: %v\n%s", args, err, stderr.String()) |
| + } |
| +} |
| + |
| +// realProbeOutput runs the real ffprobe as probe does and answers its |
| +// JSON, and the packet pass's CSV over stream (when >= 0). |
| +func realProbeOutput(t *testing.T, cfg Config, demuxer string, stream int) (jsonOut, csvOut []byte) { |
| + t.Helper() |
| + var j, c bytes.Buffer |
| + if _, err := runChildTo(context.Background(), cfg, cfg.FFprobe, probeArgs(cfg, demuxer, "-show_entries", probeEntries, "-of", "json"), "", &j); err != nil { |
| + t.Fatalf("ffprobe: %v", err) |
| + } |
| + if stream >= 0 { |
| + if _, err := runChildTo(context.Background(), cfg, cfg.FFprobe, probeArgs(cfg, demuxer, |
| + "-select_streams", strconv.Itoa(stream), "-show_entries", "packet=pts_time,duration_time", "-of", "csv=p=0"), "", &c); err != nil { |
| + t.Fatalf("ffprobe packets: %v", err) |
| + } |
| + } |
| + return j.Bytes(), c.Bytes() |
| +} |
| + |
| +// generatedFixtures are the testdata/probe fixtures made from recipes; |
| +// the rest are hand-written (testdata/probe/provenance.txt). |
| +var generatedFixtures = []string{ |
| + "iphone-hevc-hlg-portrait", "vfr-screen-recording", "chrome-webm-opus", "av-no-duration", |
| + "mp3-cover-art", "m4a-cover-art", "mka-cover-art", "h264-subtitle", "h264-4k60", "h264-120fps", "wav-mono", "aac-6ch", |
| +} |
| + |
| +// TestRegenerateProbeFixtures rewrites the generated fixtures from the |
| +// real ffprobe's answers when CARLOS_MEDIA_REGEN_FIXTURES=1. Fixtures |
| +// without a header duration get the packet pass's CSV beside them. |
| +func TestRegenerateProbeFixtures(t *testing.T) { |
| + if os.Getenv(regenEnv) != "1" { |
| + t.Skipf("set %s=1 to rewrite testdata/probe", regenEnv) |
| + } |
| + cfg := realConfig(t) |
| + for _, name := range generatedFixtures { |
| + r := makeSource(t, cfg, name) |
| + j, _ := realProbeOutput(t, cfg, r.demuxer, -1) |
| + if err := os.WriteFile(filepath.Join("testdata", "probe", name+".json"), j, 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + f, err := parseProbe(j, r.preset) |
| + if err != nil { |
| + t.Fatalf("%s: %v", name, err) |
| + } |
| + if f.DurationMS > 0 { |
| + continue |
| + } |
| + stream := f.VideoIndex |
| + if r.preset == media.PresetAudioAAC { |
| + stream = f.AudioIndex |
| + } |
| + _, c := realProbeOutput(t, cfg, r.demuxer, stream) |
| + if err := os.WriteFile(filepath.Join("testdata", "probe", name+".packets.csv"), c, 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| +} |
| + |
| +// TestRealProbeMatchesFixtures: each generated fixture is what the real |
| +// ffprobe answers for its recipe today (the facts, not the bytes). |
| +func TestRealProbeMatchesFixtures(t *testing.T) { |
| + cfg := realConfig(t) |
| + for _, name := range generatedFixtures { |
| + r := makeSource(t, cfg, name) |
| + j, _ := realProbeOutput(t, cfg, r.demuxer, -1) |
| + got, err := parseProbe(j, r.preset) |
| + if err != nil { |
| + t.Fatalf("%s: %v", name, err) |
| + } |
| + want, err := parseProbe(fixture(t, name), r.preset) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if got != want { |
| + t.Errorf("%s: real ffprobe\n got %+v\nfixture %+v", name, got, want) |
| + } |
| + } |
| +} |
| + |
| +// realInspect makes name's source and runs inspectSource on it under |
| +// preset. |
| +func realInspect(t *testing.T, cfg Config, name, preset string) (probeFacts, error) { |
| + t.Helper() |
| + makeSource(t, cfg, name) |
| + p := media.Payload{Preset: preset, Limits: limitsFor(preset)} |
| + _, f, err := inspectSource(context.Background(), cfg, p) |
| + return f, err |
| +} |
| + |
| +// TestRealProbeIgnoresCoverArtAndSubtitles (Astra P1): ffprobe runs |
| +// without the decoder allow-list, so cover art and a subtitle stream |
| +// are listed, not refused; the allow-list holds where frames are |
| +// decoded, on the streams the encode maps. Mapping the cover art |
| +// itself is refused by it. |
| +func TestRealProbeIgnoresCoverArtAndSubtitles(t *testing.T) { |
| + cfg := realConfig(t) |
| + for _, c := range []struct { |
| + name, preset, want string |
| + }{ |
| + {"mp3-cover-art", media.PresetAudioAAC, ""}, |
| + {"m4a-cover-art", media.PresetAudioAAC, ""}, |
| + {"m4a-cover-art", media.PresetVideo720p, media.CodeNoVideo}, |
| + {"mka-cover-art", media.PresetAudioAAC, ""}, |
| + {"mka-cover-art", media.PresetVideo720p, media.CodeNoVideo}, |
| + {"h264-subtitle", media.PresetVideo720p, ""}, |
| + {"h264-subtitle", media.PresetAudioAAC, ""}, |
| + } { |
| + f, err := realInspect(t, cfg, c.name, c.preset) |
| + got := "" |
| + if err != nil { |
| + got = codeOf(err) |
| + } |
| + if got != c.want { |
| + t.Errorf("%s under %s: %q, want %q", c.name, c.preset, got, c.want) |
| + continue |
| + } |
| + if err != nil { |
| + continue |
| + } |
| + // The encode's decoders, with the allow-list, on the chosen |
| + // streams only. |
| + args := ffmpegInputArgs(cfg, recipes[c.name].demuxer) |
| + if c.preset == media.PresetVideo720p { |
| + args = append(args, "-map", "0:"+strconv.Itoa(f.VideoIndex)) |
| + } |
| + if f.AudioIndex >= 0 { |
| + args = append(args, "-map", "0:"+strconv.Itoa(f.AudioIndex)) |
| + } |
| + args = append(args, "-f", "null", "-") |
| + if tail, err := runChild(context.Background(), cfg, cfg.FFmpeg, args, ""); err != nil { |
| + t.Errorf("%s under %s: decoding the chosen streams: %v %q", c.name, c.preset, err, tail) |
| + } |
| + } |
| + // Mapping the cover art: its decoder is not on the allow-list. |
| + makeSource(t, cfg, "mp3-cover-art") |
| + args := append(ffmpegInputArgs(cfg, "mp3"), "-map", "0:1", "-frames:v", "1", "-f", "null", "-") |
| + tail, err := runChild(context.Background(), cfg, cfg.FFmpeg, args, "") |
| + if codeOf(err) != media.CodeUnreadable || !bytes.Contains(tail, []byte("not on whitelist")) { |
| + t.Errorf("decoding the cover art: %s, %q; want the allow-list to refuse it", codeOf(err), tail) |
| + } |
| +} |
| + |
| +// TestRealAudioIgnoresVideo (Astra P2, Fable): a Matroska written to a |
| +// pipe has no header duration; its video lasts 1 s and its audio 3 s. |
| +// audio-aac times the audio's packets, video-720p the video's. |
| +func TestRealAudioIgnoresVideo(t *testing.T) { |
| + cfg := realConfig(t) |
| + for _, c := range []struct { |
| + preset string |
| + lo, hi int64 |
| + streamName string |
| + }{ |
| + {media.PresetAudioAAC, 2990, 3100, "audio"}, |
| + {media.PresetVideo720p, 990, 1100, "video"}, |
| + } { |
| + makeSource(t, cfg, "av-no-duration") |
| + j, _ := realProbeOutput(t, cfg, "matroska", -1) |
| + if bytes.Contains(j, []byte(`"duration"`)) { |
| + t.Fatalf("the source has a header duration: %s", j) |
| + } |
| + f, err := probe(context.Background(), cfg, "matroska", c.preset) |
| + if err != nil { |
| + t.Fatalf("%s: %v", c.preset, err) |
| + } |
| + if f.DurationMS < c.lo || f.DurationMS > c.hi { |
| + t.Errorf("%s: DurationMS %d, want the %s's, %d..%d", c.preset, f.DurationMS, c.streamName, c.lo, c.hi) |
| + } |
| + } |
| +} |
| + |
| +// TestRealPacketSideData (Astra P2, Fable I2): the last packet of an |
| +// Opus WebM carries side data, and ffprobe ends its CSV line with an |
| +// extra field; the packet pass still reads it. |
| +func TestRealPacketSideData(t *testing.T) { |
| + cfg := realConfig(t) |
| + makeSource(t, cfg, "chrome-webm-opus") |
| + _, c := realProbeOutput(t, cfg, "matroska", 0) |
| + lines := strings.Split(strings.TrimSpace(string(c)), "\n") |
| + last := lines[len(lines)-1] |
| + if strings.Count(last, ",") < 2 { |
| + t.Fatalf("the last packet line %q has no extra field: the fixture no longer tests it", last) |
| + } |
| + f, err := probe(context.Background(), cfg, "matroska", media.PresetAudioAAC) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + fields := strings.Split(last, ",") |
| + pts, _ := parseMicros(fields[0]) |
| + dur, _ := parseMicros(fields[1]) |
| + if want := microsToMS(pts + dur); f.DurationMS != want { |
| + t.Errorf("DurationMS %d, want %d from the last line %q", f.DurationMS, want, last) |
| + } |
| +} |
| + |
| +// TestRealPixelBounds: -max_pixels is accepted by ffprobe and ffmpeg. A |
| +// portrait 2160x3840, which check accepts, decodes under |
| +// maxDecodePixels but not under media.MaxPixels (its aligned size is |
| +// 2176x3840); 4096x2304 probes and is source_dimensions; a frame over |
| +// maxDecodePixels is refused by the decoders, so it is unreadable. |
| +func TestRealPixelBounds(t *testing.T) { |
| + cfg := realConfig(t) |
| + if _, err := realInspect(t, cfg, "uhd-portrait", media.PresetVideo720p); err != nil { |
| + t.Errorf("portrait 2160x3840: %v", err) |
| + } |
| + decode := func(maxPixels int) error { |
| + args := ffmpegInputArgs(cfg, "mov") |
| + for i, a := range args { |
| + if a == "-max_pixels" { |
| + args[i+1] = strconv.Itoa(maxPixels) |
| + } |
| + } |
| + _, err := runChild(context.Background(), cfg, cfg.FFmpeg, append(args, "-map", "0:0", "-f", "null", "-"), "") |
| + return err |
| + } |
| + if err := decode(maxDecodePixels); err != nil { |
| + t.Errorf("portrait 2160x3840 under maxDecodePixels: %v", err) |
| + } |
| + if err := decode(media.MaxPixels); err == nil { |
| + t.Errorf("portrait 2160x3840 decoded under -max_pixels %d: maxDecodePixels may not need its headroom", media.MaxPixels) |
| + } |
| + if _, err := realInspect(t, cfg, "over-pixels", media.PresetVideo720p); codeOf(err) != media.CodeSourceDimensions { |
| + t.Errorf("4096x2304: %s, want source_dimensions", codeOf(err)) |
| + } |
| + if _, err := realInspect(t, cfg, "over-decoders", media.PresetVideo720p); codeOf(err) != media.CodeUnreadable { |
| + t.Errorf("4352x4352: %s, want unreadable", codeOf(err)) |
| + } |
| +} |
| + |
| +// TestRealLocationTagNeverLogged (preflight F19): a file with a |
| +// location, a title and a comment. Probing it and decoding it at |
| +// -loglevel error put none of them on stderr; the probe's answer |
| +// (-show_entries) carries none of them into memory; a failing probe's |
| +// log line carries none of them. |
| +func TestRealLocationTagNeverLogged(t *testing.T) { |
| + cfg := realConfig(t) |
| + var logs []string |
| + cfg.Logf = func(format string, args ...any) { logs = append(logs, fmt.Sprintf(format, args...)) } |
| + secrets := []string{"48.8584", "002.2945", "TITLE-SECRET", "COMMENT-SECRET"} |
| + leaks := func(where string, b []byte) { |
| + for _, s := range secrets { |
| + if bytes.Contains(b, []byte(s)) { |
| + t.Errorf("%s holds %q: %q", where, s, b) |
| + } |
| + } |
| + } |
| + for _, name := range []string{"location", "iphone-hevc-hlg-portrait"} { |
| + makeSource(t, cfg, name) |
| + var out bytes.Buffer |
| + tail, err := runChildTo(context.Background(), cfg, cfg.FFprobe, probeArgs(cfg, "mov", "-show_entries", probeEntries, "-of", "json"), "", &out) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + leaks(name+": ffprobe's answer", out.Bytes()) |
| + leaks(name+": ffprobe's stderr", tail) |
| + tail, err = runChild(context.Background(), cfg, cfg.FFmpeg, append(ffmpegInputArgs(cfg, "mov"), "-map", "0:0", "-f", "null", "-"), "") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + leaks(name+": ffmpeg's stderr", tail) |
| + if _, err := probe(context.Background(), cfg, "mov", media.PresetVideo720p); err != nil { |
| + t.Fatal(err) |
| + } |
| + // A probe that fails: the wrong demuxer forced. |
| + if _, err := probe(context.Background(), cfg, "matroska", media.PresetVideo720p); codeOf(err) != media.CodeUnreadable { |
| + t.Errorf("%s as matroska: %s", name, codeOf(err)) |
| + } |
| + } |
| + leaks("the log", []byte(strings.Join(logs, "\n"))) |
| + if len(logs) == 0 { |
| + t.Error("the failing probes logged nothing: the log was not tested") |
| + } |
| +} |
| + |
| +// TestRealOptions: ffprobe refuses -nostats (so probeArgs has none) and |
| +// ffmpeg takes it; both take -enable_drefs, -max_pixels and the |
| +// protocol allow-list (every mov run above). |
| +func TestRealOptions(t *testing.T) { |
| + cfg := realConfig(t) |
| + makeSource(t, cfg, "location") |
| + args := append([]string{"-nostats"}, probeArgs(cfg, "mov", "-show_entries", "format=duration", "-of", "json")...) |
| + tail, err := runChild(context.Background(), cfg, cfg.FFprobe, args, "") |
| + if codeOf(err) != media.CodeUnreadable || !bytes.Contains(tail, []byte("nostats")) { |
| + t.Errorf("ffprobe -nostats: %s %q; want it refused", codeOf(err), tail) |
| + } |
| + if _, err := runChild(context.Background(), cfg, cfg.FFmpeg, append(ffmpegInputArgs(cfg, "mov"), "-map", "0:0", "-f", "null", "-"), ""); err != nil { |
| + t.Errorf("ffmpeg with -nostats, -enable_drefs, -max_pixels: %v", err) |
| + } |
| +} |
diff --git a/internal/mediahandler/testdata/probe/aac-6ch.json b/internal/mediahandler/testdata/probe/aac-6ch.json| index 44e3023e3..93017df1b 100644 |
| --- a/internal/mediahandler/testdata/probe/aac-6ch.json |
| +++ b/internal/mediahandler/testdata/probe/aac-6ch.json |
| @@ -1,23 +1,28 @@ |
| { |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "aac", |
| - "profile": "LC", |
| "codec_type": "audio", |
| - "sample_rate": "48000", |
| "channels": 6, |
| - "channel_layout": "5.1", |
| "r_frame_rate": "0/0", |
| "avg_frame_rate": "0/0", |
| - "duration": "300.010667", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "duration": "2.000000", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 1, |
| - "format_name": "mov,mp4,m4a,3gp,3g2,mj2", |
| - "duration": "300.010667" |
| + "duration": "2.000000" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/av-no-duration.json b/internal/mediahandler/testdata/probe/av-no-duration.json| new file mode 100644 |
| index 000000000..2c7a3436a |
| --- /dev/null |
| +++ b/internal/mediahandler/testdata/probe/av-no-duration.json |
| @@ -0,0 +1,42 @@ |
| +{ |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| + "streams": [ |
| + { |
| + "index": 0, |
| + "codec_name": "vp8", |
| + "codec_type": "video", |
| + "width": 160, |
| + "height": 90, |
| + "r_frame_rate": "10/1", |
| + "avg_frame_rate": "10/1", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| + }, |
| + { |
| + "index": 1, |
| + "codec_name": "opus", |
| + "codec_type": "audio", |
| + "channels": 1, |
| + "r_frame_rate": "0/0", |
| + "avg_frame_rate": "0/0", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| + } |
| + ], |
| + "format": { |
| + |
| + } |
| +} |
diff --git a/internal/mediahandler/testdata/probe/av-no-duration.packets.csv b/internal/mediahandler/testdata/probe/av-no-duration.packets.csv| new file mode 100644 |
| index 000000000..387de3465 |
| --- /dev/null |
| +++ b/internal/mediahandler/testdata/probe/av-no-duration.packets.csv |
| @@ -0,0 +1,151 @@ |
| +-0.007000,0.020000 |
| +0.014000,0.020000 |
| +0.034000,0.020000 |
| +0.054000,0.020000 |
| +0.074000,0.020000 |
| +0.094000,0.020000 |
| +0.114000,0.020000 |
| +0.134000,0.020000 |
| +0.154000,0.020000 |
| +0.174000,0.020000 |
| +0.194000,0.020000 |
| +0.214000,0.020000 |
| +0.234000,0.020000 |
| +0.254000,0.020000 |
| +0.274000,0.020000 |
| +0.294000,0.020000 |
| +0.314000,0.020000 |
| +0.334000,0.020000 |
| +0.354000,0.020000 |
| +0.374000,0.020000 |
| +0.394000,0.020000 |
| +0.414000,0.020000 |
| +0.434000,0.020000 |
| +0.454000,0.020000 |
| +0.474000,0.020000 |
| +0.494000,0.020000 |
| +0.514000,0.020000 |
| +0.534000,0.020000 |
| +0.554000,0.020000 |
| +0.574000,0.020000 |
| +0.594000,0.020000 |
| +0.614000,0.020000 |
| +0.634000,0.020000 |
| +0.654000,0.020000 |
| +0.674000,0.020000 |
| +0.694000,0.020000 |
| +0.714000,0.020000 |
| +0.734000,0.020000 |
| +0.754000,0.020000 |
| +0.774000,0.020000 |
| +0.794000,0.020000 |
| +0.814000,0.020000 |
| +0.834000,0.020000 |
| +0.854000,0.020000 |
| +0.874000,0.020000 |
| +0.894000,0.020000 |
| +0.914000,0.020000 |
| +0.934000,0.020000 |
| +0.954000,0.020000 |
| +0.974000,0.020000 |
| +0.994000,0.020000 |
| +1.014000,0.020000 |
| +1.034000,0.020000 |
| +1.054000,0.020000 |
| +1.074000,0.020000 |
| +1.094000,0.020000 |
| +1.114000,0.020000 |
| +1.134000,0.020000 |
| +1.154000,0.020000 |
| +1.174000,0.020000 |
| +1.194000,0.020000 |
| +1.214000,0.020000 |
| +1.234000,0.020000 |
| +1.254000,0.020000 |
| +1.274000,0.020000 |
| +1.294000,0.020000 |
| +1.314000,0.020000 |
| +1.334000,0.020000 |
| +1.354000,0.020000 |
| +1.374000,0.020000 |
| +1.394000,0.020000 |
| +1.414000,0.020000 |
| +1.434000,0.020000 |
| +1.454000,0.020000 |
| +1.474000,0.020000 |
| +1.494000,0.020000 |
| +1.514000,0.020000 |
| +1.534000,0.020000 |
| +1.554000,0.020000 |
| +1.574000,0.020000 |
| +1.594000,0.020000 |
| +1.614000,0.020000 |
| +1.634000,0.020000 |
| +1.654000,0.020000 |
| +1.674000,0.020000 |
| +1.694000,0.020000 |
| +1.714000,0.020000 |
| +1.734000,0.020000 |
| +1.754000,0.020000 |
| +1.774000,0.020000 |
| +1.794000,0.020000 |
| +1.814000,0.020000 |
| +1.834000,0.020000 |
| +1.854000,0.020000 |
| +1.874000,0.020000 |
| +1.894000,0.020000 |
| +1.914000,0.020000 |
| +1.934000,0.020000 |
| +1.954000,0.020000 |
| +1.974000,0.020000 |
| +1.994000,0.020000 |
| +2.014000,0.020000 |
| +2.034000,0.020000 |
| +2.054000,0.020000 |
| +2.074000,0.020000 |
| +2.094000,0.020000 |
| +2.114000,0.020000 |
| +2.134000,0.020000 |
| +2.154000,0.020000 |
| +2.174000,0.020000 |
| +2.194000,0.020000 |
| +2.214000,0.020000 |
| +2.234000,0.020000 |
| +2.254000,0.020000 |
| +2.274000,0.020000 |
| +2.294000,0.020000 |
| +2.314000,0.020000 |
| +2.334000,0.020000 |
| +2.354000,0.020000 |
| +2.374000,0.020000 |
| +2.394000,0.020000 |
| +2.414000,0.020000 |
| +2.434000,0.020000 |
| +2.454000,0.020000 |
| +2.474000,0.020000 |
| +2.494000,0.020000 |
| +2.514000,0.020000 |
| +2.534000,0.020000 |
| +2.554000,0.020000 |
| +2.574000,0.020000 |
| +2.594000,0.020000 |
| +2.614000,0.020000 |
| +2.634000,0.020000 |
| +2.654000,0.020000 |
| +2.674000,0.020000 |
| +2.694000,0.020000 |
| +2.714000,0.020000 |
| +2.734000,0.020000 |
| +2.754000,0.020000 |
| +2.774000,0.020000 |
| +2.794000,0.020000 |
| +2.814000,0.020000 |
| +2.834000,0.020000 |
| +2.854000,0.020000 |
| +2.874000,0.020000 |
| +2.894000,0.020000 |
| +2.914000,0.020000 |
| +2.934000,0.020000 |
| +2.954000,0.020000 |
| +2.974000,0.020000 |
| +2.994000,0.020000, |
diff --git a/internal/mediahandler/testdata/probe/bomb-30000.json b/internal/mediahandler/testdata/probe/bomb-30000.json| index d7539c0ad..398ede7ae 100644 |
| --- a/internal/mediahandler/testdata/probe/bomb-30000.json |
| +++ b/internal/mediahandler/testdata/probe/bomb-30000.json |
| @@ -1,23 +1,23 @@ |
| { |
| + "programs": [], |
| + "stream_groups": [], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "h264", |
| - "profile": "High", |
| "codec_type": "video", |
| "width": 30000, |
| "height": 30000, |
| - "pix_fmt": "yuv420p", |
| "r_frame_rate": "1/1", |
| "avg_frame_rate": "1/1", |
| "duration": "1.000000", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": {} |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 1, |
| - "format_name": "mov,mp4,m4a,3gp,3g2,mj2", |
| "duration": "1.000000" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/chrome-webm-opus.json b/internal/mediahandler/testdata/probe/chrome-webm-opus.json| index 412000367..202d03581 100644 |
| --- a/internal/mediahandler/testdata/probe/chrome-webm-opus.json |
| +++ b/internal/mediahandler/testdata/probe/chrome-webm-opus.json |
| @@ -1,25 +1,27 @@ |
| { |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "opus", |
| "codec_type": "audio", |
| - "sample_fmt": "fltp", |
| - "sample_rate": "48000", |
| "channels": 1, |
| - "channel_layout": "mono", |
| "r_frame_rate": "0/0", |
| "avg_frame_rate": "0/0", |
| - "time_base": "1/1000", |
| - "start_pts": 0, |
| - "start_time": "0.000000", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 1, |
| - "format_name": "matroska,webm", |
| - "start_time": "0.000000" |
| + |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/chrome-webm-opus.packets.csv b/internal/mediahandler/testdata/probe/chrome-webm-opus.packets.csv| index 251c9c4af..0cf3e29f6 100644 |
| --- a/internal/mediahandler/testdata/probe/chrome-webm-opus.packets.csv |
| +++ b/internal/mediahandler/testdata/probe/chrome-webm-opus.packets.csv |
| @@ -1,7 +1,51 @@ |
| -0.000000,0.020000 |
| -0.020000,0.020000 |
| -0.040000,0.020000 |
| -5.960000,N/A |
| -5.980000,0.020000 |
| -4.000000,0.020000 |
| -N/A,0.020000 |
| +-0.007000,0.020000 |
| +0.014000,0.020000 |
| +0.034000,0.020000 |
| +0.054000,0.020000 |
| +0.074000,0.020000 |
| +0.094000,0.020000 |
| +0.114000,0.020000 |
| +0.134000,0.020000 |
| +0.154000,0.020000 |
| +0.174000,0.020000 |
| +0.194000,0.020000 |
| +0.214000,0.020000 |
| +0.234000,0.020000 |
| +0.254000,0.020000 |
| +0.274000,0.020000 |
| +0.294000,0.020000 |
| +0.314000,0.020000 |
| +0.334000,0.020000 |
| +0.354000,0.020000 |
| +0.374000,0.020000 |
| +0.394000,0.020000 |
| +0.414000,0.020000 |
| +0.434000,0.020000 |
| +0.454000,0.020000 |
| +0.474000,0.020000 |
| +0.494000,0.020000 |
| +0.514000,0.020000 |
| +0.534000,0.020000 |
| +0.554000,0.020000 |
| +0.574000,0.020000 |
| +0.594000,0.020000 |
| +0.614000,0.020000 |
| +0.634000,0.020000 |
| +0.654000,0.020000 |
| +0.674000,0.020000 |
| +0.694000,0.020000 |
| +0.714000,0.020000 |
| +0.734000,0.020000 |
| +0.754000,0.020000 |
| +0.774000,0.020000 |
| +0.794000,0.020000 |
| +0.814000,0.020000 |
| +0.834000,0.020000 |
| +0.854000,0.020000 |
| +0.874000,0.020000 |
| +0.894000,0.020000 |
| +0.914000,0.020000 |
| +0.934000,0.020000 |
| +0.954000,0.020000 |
| +0.974000,0.020000 |
| +0.994000,0.020000, |
diff --git a/internal/mediahandler/testdata/probe/dolby-vision-5.json b/internal/mediahandler/testdata/probe/dolby-vision-5.json| index 4ca7643b5..0ee735924 100644 |
| --- a/internal/mediahandler/testdata/probe/dolby-vision-5.json |
| +++ b/internal/mediahandler/testdata/probe/dolby-vision-5.json |
| @@ -1,26 +1,29 @@ |
| { |
| + "programs": [], |
| + "stream_groups": [], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "hevc", |
| - "profile": "Main 10", |
| "codec_type": "video", |
| "width": 1920, |
| "height": 1080, |
| - "pix_fmt": "yuv420p10le", |
| "r_frame_rate": "24000/1001", |
| "avg_frame_rate": "24000/1001", |
| "duration": "20.020000", |
| - "disposition": {"default": 1, "attached_pic": 0}, |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": {}, |
| "side_data_list": [ |
| - {"side_data_type": "DOVI configuration record", "dv_version_major": 1, "dv_version_minor": 0, "dv_profile": 5, "dv_level": 6, "rpu_present_flag": 1, "el_present_flag": 0, "bl_present_flag": 1, "dv_bl_signal_compatibility_id": 0} |
| + { |
| + "side_data_type": "DOVI configuration record", |
| + "dv_profile": 5 |
| + } |
| ] |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 1, |
| - "format_name": "mov,mp4,m4a,3gp,3g2,mj2", |
| "duration": "20.020000" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/dolby-vision-8-4.json b/internal/mediahandler/testdata/probe/dolby-vision-8-4.json| index 258bf5db7..84a3ad761 100644 |
| --- a/internal/mediahandler/testdata/probe/dolby-vision-8-4.json |
| +++ b/internal/mediahandler/testdata/probe/dolby-vision-8-4.json |
| @@ -1,41 +1,47 @@ |
| { |
| + "programs": [], |
| + "stream_groups": [], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "hevc", |
| - "profile": "Main 10", |
| "codec_type": "video", |
| "width": 3840, |
| "height": 2160, |
| - "pix_fmt": "yuv420p10le", |
| - "color_space": "bt2020nc", |
| - "color_transfer": "arib-std-b67", |
| - "color_primaries": "bt2020", |
| "r_frame_rate": "60/1", |
| "avg_frame_rate": "60/1", |
| + "color_transfer": "arib-std-b67", |
| "duration": "8.000000", |
| - "disposition": {"default": 1, "attached_pic": 0}, |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": {}, |
| "side_data_list": [ |
| - {"side_data_type": "DOVI configuration record", "dv_version_major": 1, "dv_version_minor": 0, "dv_profile": 8, "dv_level": 9, "rpu_present_flag": 1, "el_present_flag": 0, "bl_present_flag": 1, "dv_bl_signal_compatibility_id": 4, "dv_md_compression": "none"}, |
| - {"side_data_type": "Display Matrix", "displaymatrix": "\n00000000: 0 65536 0\n00000001: -65536 0 0\n00000002: 0 0 1073741824\n", "rotation": -90} |
| + { |
| + "side_data_type": "DOVI configuration record", |
| + "dv_profile": 8 |
| + }, |
| + { |
| + "side_data_type": "Display Matrix", |
| + "rotation": -90 |
| + } |
| ] |
| }, |
| { |
| "index": 1, |
| "codec_name": "aac", |
| "codec_type": "audio", |
| - "sample_rate": "48000", |
| - "channels": 2, |
| "r_frame_rate": "0/0", |
| "avg_frame_rate": "0/0", |
| + "channels": 2, |
| "duration": "7.989000", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": {} |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 2, |
| - "format_name": "mov,mp4,m4a,3gp,3g2,mj2", |
| "duration": "8.000000" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/h264-120fps.json b/internal/mediahandler/testdata/probe/h264-120fps.json| index 6b8536a45..3c90926e6 100644 |
| --- a/internal/mediahandler/testdata/probe/h264-120fps.json |
| +++ b/internal/mediahandler/testdata/probe/h264-120fps.json |
| @@ -1,23 +1,29 @@ |
| { |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "h264", |
| - "profile": "High", |
| "codec_type": "video", |
| - "width": 1920, |
| - "height": 1080, |
| - "pix_fmt": "yuv420p", |
| + "width": 320, |
| + "height": 180, |
| "r_frame_rate": "120/1", |
| "avg_frame_rate": "120/1", |
| - "duration": "10.000000", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "duration": "1.000000", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 1, |
| - "format_name": "mov,mp4,m4a,3gp,3g2,mj2", |
| - "duration": "10.000000" |
| + "duration": "1.000000" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/h264-4k60.json b/internal/mediahandler/testdata/probe/h264-4k60.json| index 8072ec4d0..220cb54d2 100644 |
| --- a/internal/mediahandler/testdata/probe/h264-4k60.json |
| +++ b/internal/mediahandler/testdata/probe/h264-4k60.json |
| @@ -1,34 +1,44 @@ |
| { |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "h264", |
| - "profile": "High", |
| "codec_type": "video", |
| "width": 3840, |
| "height": 2160, |
| - "pix_fmt": "yuv420p", |
| "r_frame_rate": "60/1", |
| "avg_frame_rate": "60/1", |
| - "duration": "30.000000", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "duration": "0.050000", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| }, |
| { |
| "index": 1, |
| "codec_name": "aac", |
| "codec_type": "audio", |
| - "sample_rate": "48000", |
| "channels": 2, |
| "r_frame_rate": "0/0", |
| "avg_frame_rate": "0/0", |
| - "duration": "30.000000", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "duration": "0.050000", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 2, |
| - "format_name": "mov,mp4,m4a,3gp,3g2,mj2", |
| - "duration": "30.000000" |
| + "duration": "0.050000" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/h264-subtitle.json b/internal/mediahandler/testdata/probe/h264-subtitle.json| new file mode 100644 |
| index 000000000..b029f575c |
| --- /dev/null |
| +++ b/internal/mediahandler/testdata/probe/h264-subtitle.json |
| @@ -0,0 +1,58 @@ |
| +{ |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| + "streams": [ |
| + { |
| + "index": 0, |
| + "codec_name": "h264", |
| + "codec_type": "video", |
| + "width": 160, |
| + "height": 90, |
| + "r_frame_rate": "10/1", |
| + "avg_frame_rate": "10/1", |
| + "duration": "2.000000", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| + }, |
| + { |
| + "index": 1, |
| + "codec_name": "aac", |
| + "codec_type": "audio", |
| + "channels": 1, |
| + "r_frame_rate": "0/0", |
| + "avg_frame_rate": "0/0", |
| + "duration": "2.000000", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| + }, |
| + { |
| + "index": 2, |
| + "codec_name": "mov_text", |
| + "codec_type": "subtitle", |
| + "r_frame_rate": "0/0", |
| + "avg_frame_rate": "0/0", |
| + "duration": "1.000000", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| + } |
| + ], |
| + "format": { |
| + "duration": "2.000000" |
| + } |
| +} |
diff --git a/internal/mediahandler/testdata/probe/iphone-hevc-hlg-portrait.json b/internal/mediahandler/testdata/probe/iphone-hevc-hlg-portrait.json| index 82816e975..6c4eb2a8a 100644 |
| --- a/internal/mediahandler/testdata/probe/iphone-hevc-hlg-portrait.json |
| +++ b/internal/mediahandler/testdata/probe/iphone-hevc-hlg-portrait.json |
| @@ -1,59 +1,51 @@ |
| { |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "hevc", |
| - "profile": "Main 10", |
| "codec_type": "video", |
| - "codec_tag_string": "hvc1", |
| "width": 1920, |
| "height": 1080, |
| - "coded_width": 1920, |
| - "coded_height": 1080, |
| - "pix_fmt": "yuv420p10le", |
| - "color_range": "tv", |
| - "color_space": "bt2020nc", |
| "color_transfer": "arib-std-b67", |
| - "color_primaries": "bt2020", |
| "r_frame_rate": "30/1", |
| "avg_frame_rate": "30/1", |
| - "time_base": "1/600", |
| - "duration": "12.345000", |
| - "disposition": {"default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "non_diegetic": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0, "multilayer": 0}, |
| + "duration": "1.000000", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + }, |
| "side_data_list": [ |
| - {"side_data_type": "Display Matrix", "displaymatrix": "\n00000000: 0 65536 0\n00000001: -65536 0 0\n00000002: 0 0 1073741824\n", "rotation": -90} |
| + { |
| + "side_data_type": "Display Matrix", |
| + "rotation": -90 |
| + } |
| ] |
| }, |
| { |
| "index": 1, |
| "codec_name": "aac", |
| - "profile": "LC", |
| "codec_type": "audio", |
| - "sample_fmt": "fltp", |
| - "sample_rate": "44100", |
| "channels": 2, |
| - "channel_layout": "stereo", |
| - "r_frame_rate": "0/0", |
| - "avg_frame_rate": "0/0", |
| - "duration": "12.329796", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| - }, |
| - { |
| - "index": 2, |
| - "codec_type": "data", |
| - "codec_tag_string": "mebx", |
| "r_frame_rate": "0/0", |
| "avg_frame_rate": "0/0", |
| - "duration": "12.345000", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "duration": "1.000000", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 3, |
| - "format_name": "mov,mp4,m4a,3gp,3g2,mj2", |
| - "duration": "12.345000", |
| - "size": "20480000", |
| - "bit_rate": "13271000" |
| + "duration": "1.000000" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/lying-10h.json b/internal/mediahandler/testdata/probe/lying-10h.json| index c8db0553d..e70f0a74c 100644 |
| --- a/internal/mediahandler/testdata/probe/lying-10h.json |
| +++ b/internal/mediahandler/testdata/probe/lying-10h.json |
| @@ -1,23 +1,23 @@ |
| { |
| + "programs": [], |
| + "stream_groups": [], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "h264", |
| - "profile": "High", |
| "codec_type": "video", |
| "width": 1280, |
| "height": 720, |
| - "pix_fmt": "yuv420p", |
| "r_frame_rate": "30/1", |
| "avg_frame_rate": "30/1", |
| "duration": "4.000000", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": {} |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 1, |
| - "format_name": "matroska,webm", |
| "duration": "36000.000000" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/m4a-cover-art.json b/internal/mediahandler/testdata/probe/m4a-cover-art.json| index 0172ea08c..3fca37aa7 100644 |
| --- a/internal/mediahandler/testdata/probe/m4a-cover-art.json |
| +++ b/internal/mediahandler/testdata/probe/m4a-cover-art.json |
| @@ -1,32 +1,41 @@ |
| { |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "aac", |
| - "profile": "LC", |
| "codec_type": "audio", |
| - "sample_rate": "44100", |
| - "channels": 2, |
| + "channels": 1, |
| "r_frame_rate": "0/0", |
| "avg_frame_rate": "0/0", |
| - "duration": "180.000000", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "duration": "3.000000", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| }, |
| { |
| "index": 1, |
| - "codec_name": "png", |
| + "codec_name": "mjpeg", |
| "codec_type": "video", |
| - "width": 1400, |
| - "height": 1400, |
| + "width": 64, |
| + "height": 64, |
| "r_frame_rate": "90000/1", |
| "avg_frame_rate": "0/0", |
| - "disposition": {"default": 0, "attached_pic": 1} |
| + "duration": "3.000000", |
| + "disposition": { |
| + "attached_pic": 1 |
| + } |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 2, |
| - "format_name": "mov,mp4,m4a,3gp,3g2,mj2", |
| - "duration": "180.000000" |
| + "duration": "3.000000" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/mka-cover-art.json b/internal/mediahandler/testdata/probe/mka-cover-art.json| index e7a199d32..67e287301 100644 |
| --- a/internal/mediahandler/testdata/probe/mka-cover-art.json |
| +++ b/internal/mediahandler/testdata/probe/mka-cover-art.json |
| @@ -1,30 +1,43 @@ |
| { |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| "streams": [ |
| { |
| "index": 0, |
| - "codec_name": "mjpeg", |
| - "codec_type": "video", |
| - "width": 500, |
| - "height": 500, |
| - "r_frame_rate": "90000/1", |
| + "codec_name": "flac", |
| + "codec_type": "audio", |
| + "channels": 1, |
| + "r_frame_rate": "0/0", |
| "avg_frame_rate": "0/0", |
| - "disposition": {"default": 0, "attached_pic": 1} |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| }, |
| { |
| "index": 1, |
| - "codec_name": "flac", |
| - "codec_type": "audio", |
| - "sample_rate": "96000", |
| - "channels": 2, |
| - "r_frame_rate": "0/0", |
| + "codec_name": "mjpeg", |
| + "codec_type": "video", |
| + "width": 64, |
| + "height": 64, |
| + "r_frame_rate": "90000/1", |
| "avg_frame_rate": "0/0", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "duration": "2.000000", |
| + "disposition": { |
| + "attached_pic": 1 |
| + }, |
| + "tags": { |
| + |
| + } |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 2, |
| - "format_name": "matroska,webm", |
| - "duration": "240.500000" |
| + "duration": "2.000000" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/mp3-cover-art.json b/internal/mediahandler/testdata/probe/mp3-cover-art.json| index 917c1f959..5598ff8dd 100644 |
| --- a/internal/mediahandler/testdata/probe/mp3-cover-art.json |
| +++ b/internal/mediahandler/testdata/probe/mp3-cover-art.json |
| @@ -1,34 +1,41 @@ |
| { |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "mp3", |
| "codec_type": "audio", |
| - "sample_fmt": "fltp", |
| - "sample_rate": "44100", |
| - "channels": 2, |
| + "channels": 1, |
| "r_frame_rate": "0/0", |
| "avg_frame_rate": "0/0", |
| - "duration": "215.484082", |
| - "disposition": {"default": 0, "attached_pic": 0} |
| + "duration": "3.030204", |
| + "disposition": { |
| + "attached_pic": 0 |
| + } |
| }, |
| { |
| "index": 1, |
| "codec_name": "mjpeg", |
| - "profile": "Baseline", |
| "codec_type": "video", |
| - "width": 600, |
| - "height": 600, |
| + "width": 64, |
| + "height": 64, |
| "r_frame_rate": "90000/1", |
| "avg_frame_rate": "0/0", |
| - "duration": "215.484082", |
| - "disposition": {"default": 0, "attached_pic": 1} |
| + "duration": "3.030200", |
| + "disposition": { |
| + "attached_pic": 1 |
| + }, |
| + "tags": { |
| + |
| + } |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 2, |
| - "format_name": "mp3", |
| - "duration": "215.484082" |
| + "duration": "3.030204" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/provenance.txt b/internal/mediahandler/testdata/probe/provenance.txt| new file mode 100644 |
| index 000000000..84ffe5dde |
| --- /dev/null |
| +++ b/internal/mediahandler/testdata/probe/provenance.txt |
| @@ -0,0 +1,33 @@ |
| +Where each fixture comes from (plan 3 Task 3, fix round 1). |
| + |
| +Made by Debian 13's ffmpeg 7.1.5 from lavfi test patterns and answered |
| +by its ffprobe, with probe's own arguments (-show_entries probeEntries, |
| +so no tags); the recipes are in realffmpeg_test.go, and |
| +CARLOS_MEDIA_REGEN_FIXTURES=1 go test -run TestRegenerateProbeFixtures |
| +rewrites them: |
| + |
| +iphone-hevc-hlg-portrait.json HEVC 10-bit HLG, display matrix -90, AAC |
| +vfr-screen-recording.json H.264, r_frame_rate 120/1, average 30.5 |
| +chrome-webm-opus.json Opus WebM written to a pipe: no duration |
| +chrome-webm-opus.packets.csv its packet pass (the last packet carries |
| + side data: a third, empty field) |
| +av-no-duration.json VP8 1 s + Opus 3 s Matroska to a pipe |
| +av-no-duration.packets.csv its packet pass over the audio |
| +mp3-cover-art.json MP3 with a JPEG attached picture |
| +m4a-cover-art.json AAC M4A with a JPEG attached picture |
| +mka-cover-art.json FLAC Matroska with a JPEG attachment |
| +h264-subtitle.json H.264 + AAC + mov_text subtitles |
| +h264-4k60.json 3840x2160 at 60 fps, AAC |
| +h264-120fps.json 320x180 at 120 fps |
| +wav-mono.json PCM s16le mono |
| +aac-6ch.json AAC 5.1 |
| + |
| +The first four stand in for Paul's files until plan 1's spike saves |
| +those (their tags removed). |
| + |
| +Hand-written, in the same shape, because ffmpeg cannot make them: |
| + |
| +dolby-vision-8-4.json Dolby Vision 8.4 configuration record |
| +dolby-vision-5.json Dolby Vision 5 configuration record |
| +bomb-30000.json a 30000x30000 header |
| +lying-10h.json a 10 h header over a 4 s stream |
diff --git a/internal/mediahandler/testdata/probe/stand-ins.txt b/internal/mediahandler/testdata/probe/stand-ins.txt| deleted file mode 100644 |
| index 541c7ea4a..000000000 |
| --- a/internal/mediahandler/testdata/probe/stand-ins.txt |
| +++ /dev/null |
| @@ -1,13 +0,0 @@ |
| -Stand-ins, hand-written in ffprobe 7.1's -of json shape (plan 3 Task 3; |
| -preflight section 4). Plan 1's spike replaces the first four with the |
| -answers it saves from Paul's files, every tags object removed: |
| - |
| -iphone-hevc-hlg-portrait.json an iPhone HEVC HLG portrait |
| -dolby-vision-8-4.json a Dolby Vision 8.4 |
| -vfr-screen-recording.json a VFR screen recording |
| -chrome-webm-opus.json a Chrome WebM Opus without duration |
| -chrome-webm-opus.packets.csv its packet pass |
| - |
| -The rest are hand-written by design: dolby-vision-5, mp3-cover-art, |
| -m4a-cover-art, mka-cover-art (preflight F17), h264-4k60, h264-120fps, |
| -bomb-30000, lying-10h, wav-mono, aac-6ch. |
diff --git a/internal/mediahandler/testdata/probe/vfr-screen-recording.json b/internal/mediahandler/testdata/probe/vfr-screen-recording.json| index 23823d8ca..75e990c21 100644 |
| --- a/internal/mediahandler/testdata/probe/vfr-screen-recording.json |
| +++ b/internal/mediahandler/testdata/probe/vfr-screen-recording.json |
| @@ -1,24 +1,29 @@ |
| { |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "h264", |
| - "profile": "High", |
| "codec_type": "video", |
| - "width": 2880, |
| - "height": 1800, |
| - "pix_fmt": "yuv420p", |
| - "color_transfer": "bt709", |
| + "width": 640, |
| + "height": 400, |
| "r_frame_rate": "120/1", |
| - "avg_frame_rate": "30000/1001", |
| - "duration": "95.200000", |
| - "disposition": {"default": 1, "attached_pic": 0} |
| + "avg_frame_rate": "1800/59", |
| + "duration": "1.966667", |
| + "disposition": { |
| + "attached_pic": 0 |
| + }, |
| + "tags": { |
| + |
| + } |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 1, |
| - "format_name": "mov,mp4,m4a,3gp,3g2,mj2", |
| - "duration": "95.200000" |
| + "duration": "1.966667" |
| } |
| } |
diff --git a/internal/mediahandler/testdata/probe/wav-mono.json b/internal/mediahandler/testdata/probe/wav-mono.json| index 74dad149b..1fa39ca57 100644 |
| --- a/internal/mediahandler/testdata/probe/wav-mono.json |
| +++ b/internal/mediahandler/testdata/probe/wav-mono.json |
| @@ -1,23 +1,25 @@ |
| { |
| + "programs": [ |
| + |
| + ], |
| + "stream_groups": [ |
| + |
| + ], |
| "streams": [ |
| { |
| "index": 0, |
| "codec_name": "pcm_s16le", |
| "codec_type": "audio", |
| - "sample_fmt": "s16", |
| - "sample_rate": "44100", |
| "channels": 1, |
| - "channel_layout": "mono", |
| "r_frame_rate": "0/0", |
| "avg_frame_rate": "0/0", |
| - "duration": "62.500000", |
| - "disposition": {"default": 0, "attached_pic": 0} |
| + "duration": "2.500000", |
| + "disposition": { |
| + "attached_pic": 0 |
| + } |
| } |
| ], |
| "format": { |
| - "filename": "/scratch/in/source", |
| - "nb_streams": 1, |
| - "format_name": "wav", |
| - "duration": "62.500000" |
| + "duration": "2.500000" |
| } |
| } |