@@ -23,16 +23,17 @@ const (
2323func MuxTStoMP4 (tsInputFile , mp4OutputFile string ) ([]string , error ) {
2424 var transmuxOutputFiles []string
2525 // transmux the .ts file into a standalone MP4 file
26+ ffmpegErr := bytes.Buffer {}
2627 err := ffmpeg .Input (tsInputFile ).
2728 Output (mp4OutputFile , ffmpeg.KwArgs {
2829 "analyzeduration" : "15M" , // Analyze up to 15s of video to figure out the format. We saw failures to detect the video codec without this
2930 "movflags" : "faststart" , // Need this for progressive playback and probing
3031 "c" : "copy" , // Don't accidentally transcode
3132 "bsf:a" : "aac_adtstoasc" , // Remove ADTS header (required for ts -> mp4 container conversion)
3233 }).
33- OverWriteOutput ().ErrorToStdOut ( ).Run ()
34+ OverWriteOutput ().WithErrorOutput ( & ffmpegErr ).Run ()
3435 if err != nil {
35- return nil , fmt .Errorf ("failed to transmux concatenated mpeg-ts file (%s) into a mp4 file: %w" , tsInputFile , err )
36+ return nil , fmt .Errorf ("failed to transmux concatenated mpeg-ts file (%s) into a mp4 file [%s] : %w" , tsInputFile , ffmpegErr . String () , err )
3637 }
3738 // Verify the mp4 output file was created
3839 _ , err = os .Stat (mp4OutputFile )
@@ -211,15 +212,16 @@ func concatStreams(segmentList, outputTsFileName string) error {
211212 }
212213 defer tsFile .Close ()
213214 // Transmux the individual .ts files into a combined single ts file using stream based concatenation
215+ ffmpegErr := bytes.Buffer {}
214216 err = ffmpeg .Input (segmentList , ffmpeg.KwArgs {
215217 "f" : "concat" , // Use stream based concatenation (instead of file based concatenation)
216218 "safe" : "0" }). // Must be 0 since relative paths to segments are used in segmentListTxtFileName
217219 Output (outputTsFileName , ffmpeg.KwArgs {
218220 "c" : "copy" , // Don't accidentally transcode
219221 }).
220- OverWriteOutput ().ErrorToStdOut ( ).Run ()
222+ OverWriteOutput ().WithErrorOutput ( & ffmpegErr ).Run ()
221223 if err != nil {
222- return fmt .Errorf ("failed to transmux multiple ts files from %s into a ts file: %w" , segmentList , err )
224+ return fmt .Errorf ("failed to transmux multiple ts files from %s into a ts file [%s] : %w" , segmentList , ffmpegErr . String () , err )
223225 }
224226 // Verify the ts output file was created
225227 _ , err = os .Stat (outputTsFileName )
@@ -237,13 +239,14 @@ func concatFiles(segmentList, outputTsFileName string) error {
237239 }
238240 defer tsFile .Close ()
239241 // Transmux the individual .ts files into a combined single ts file using file based concatenation
242+ ffmpegErr := bytes.Buffer {}
240243 err = ffmpeg .Input (segmentList ).
241244 Output (outputTsFileName , ffmpeg.KwArgs {
242245 "c" : "copy" , // Don't accidentally transcode
243246 }).
244- OverWriteOutput ().ErrorToStdOut ( ).Run ()
247+ OverWriteOutput ().WithErrorOutput ( & ffmpegErr ).Run ()
245248 if err != nil {
246- return fmt .Errorf ("failed to transmux multiple ts files from %s into a ts file: %w" , segmentList , err )
249+ return fmt .Errorf ("failed to transmux multiple ts files from %s into a ts file [%s] : %w" , segmentList , ffmpegErr . String () , err )
247250 }
248251 // Verify the ts output file was created
249252 _ , err = os .Stat (outputTsFileName )
0 commit comments