diff --git a/.gitignore b/.gitignore index a92007c..9d55ea8 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,7 @@ dist # Design Templates Design/Cover.psd Design/Programmatic.psd -#Design/Sidebar.xd \ No newline at end of file +#Design/Sidebar.xd + +# XCUserData +Converter.xcworkspace/xcuserdata diff --git a/Converter.xcworkspace/xcuserdata/francescovirga.xcuserdatad/.dat.nosync14dd.aQpz7P b/Converter.xcworkspace/xcuserdata/francescovirga.xcuserdatad/.dat.nosync14dd.aQpz7P deleted file mode 100644 index e69de29..0000000 diff --git a/Converter.xcworkspace/xcuserdata/francescovirga.xcuserdatad/UserInterfaceState.xcuserstate b/Converter.xcworkspace/xcuserdata/francescovirga.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index e02a070..0000000 Binary files a/Converter.xcworkspace/xcuserdata/francescovirga.xcuserdatad/UserInterfaceState.xcuserstate and /dev/null differ diff --git a/Converter.xcworkspace/xcuserdata/justinbush.xcuserdatad/UserInterfaceState.xcuserstate b/Converter.xcworkspace/xcuserdata/justinbush.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index 58746e2..0000000 Binary files a/Converter.xcworkspace/xcuserdata/justinbush.xcuserdatad/UserInterfaceState.xcuserstate and /dev/null differ diff --git a/Converter/Conversion.swift b/Converter/Conversion.swift index 1ce9d97..053494c 100644 --- a/Converter/Conversion.swift +++ b/Converter/Conversion.swift @@ -59,8 +59,15 @@ func getVideoConversionCommand(inputFilePath: String, outputFilePath: String) -> return "-c:v libx264 -preset veryfast -crf 26" } - // If input file is HEVC, we re-encode to H264 to ensure QuickTime support + // If input file is HEVC, we re-encode to H264 and 8-bit colour to ensure QuickTime support + // https://superuser.com/questions/1380946/how-do-i-convert-10-bit-h-265-hevc-videos-to-h-264-without-quality-loss if inputVideoCodec == VideoCodec.hevc { + return "-c:v libx264 -preset veryfast -crf 20 -vf format=yuv420p" + } + + let inputVideoCodecTag = getVideoCodecTag(inputFilePath: inputFilePath) + // MOV does not support xvid, so we need to re-encode + if inputVideoCodecTag == "xvid" && outputFileType == VideoFormat.mov.rawValue { return "-c:v libx264 -preset veryfast -crf 26" } @@ -225,6 +232,14 @@ func getAudioCodec(inputFilePath: String) -> AudioCodec { return convertToAudioCodec(inputCodec: codec) } +func getVideoCodecTag(inputFilePath: String) -> String { + let session = FFprobeKit.execute("-loglevel error -select_streams v:0 -show_entries stream=codec_tag_string -of default=noprint_wrappers=1:nokey=1 \"\(inputFilePath)\"") + let logs = session?.getAllLogsAsString() + + let codecTagString = logs!.trimmingCharacters(in: .whitespacesAndNewlines) + return codecTagString +} + func getChannelLayout(inputFilePath: String) -> ChannelLayout { let session = FFprobeKit.execute("-loglevel error -select_streams a:0 -show_entries stream=channel_layout -of default=noprint_wrappers=1:nokey=1 \"\(inputFilePath)\"") let logs = session?.getAllLogsAsString()