From 56cd37dde85acea3de2acd7c9d1ad0a16250e843 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Wed, 28 Aug 2024 22:14:34 +0200 Subject: [PATCH] enable gopro tmcd track by default closes #2134 --- src/renderer/src/util/streams.ts | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/renderer/src/util/streams.ts b/src/renderer/src/util/streams.ts index 2032ac56..98477baf 100644 --- a/src/renderer/src/util/streams.ts +++ b/src/renderer/src/util/streams.ts @@ -2,17 +2,6 @@ import invariant from 'tiny-invariant'; import { FFprobeStream, FFprobeStreamDisposition } from '../../../../ffprobe'; import { AllFilesMeta, ChromiumHTMLAudioElement, ChromiumHTMLVideoElement, CopyfileStreams, LiteFFprobeStream } from '../types'; -// https://www.ffmpeg.org/doxygen/3.2/libavutil_2utils_8c_source.html#l00079 -const defaultProcessedCodecTypes = new Set([ - 'video', - 'audio', - 'subtitle', - 'attachment', -]); - -const unprocessableCodecs = new Set([ - 'dvb_teletext', // ffmpeg doesn't seem to support this https://github.com/mifi/lossless-cut/issues/1343 -]); // taken from `ffmpeg -codecs` export const pcmAudioCodecs = [ @@ -235,9 +224,26 @@ export function getMapStreamsArgs({ startIndex = 0, outFormat, allFilesMeta, cop } export function shouldCopyStreamByDefault(stream: FFprobeStream) { - if (!defaultProcessedCodecTypes.has(stream.codec_type)) return false; - if (unprocessableCodecs.has(stream.codec_name)) return false; - return true; + // https://www.ffmpeg.org/doxygen/3.2/libavutil_2utils_8c_source.html#l00079 + switch (stream.codec_type) { + case 'audio': + case 'attachment': + case 'video': { + return true; + } + case 'subtitle': { + return stream.codec_name !== 'dvb_teletext'; // ffmpeg doesn't seem to support this https://github.com/mifi/lossless-cut/issues/1343 + } + case 'data': { + // can handle gopro gpmd https://github.com/mifi/lossless-cut/issues/2134 + // no other data tracks are known to be supported (might be added later) + return stream.codec_name === 'bin_data' && stream.codec_tag_string === 'gpmd'; + } + + default: { + return false; + } + } } export const attachedPicDisposition = 'attached_pic';