-
Notifications
You must be signed in to change notification settings - Fork 19
How to Find and Fix Corruptions in FFMPEG
You can check a stream for errors with the following command:
ffmpeg -v error -i corrupted_input.ts -f null - &> corruptions.log
This command will check the corrupted_input.ts stream and save all the errors in the corruptions.log in the same directory.
You can fix the stream corruptions using the following command:
ffmpeg -i corrupted_input.ts -map 0 -ignore_unknown/-copy_unknown -c copy fixed.ts
This will take the corrupted input stream and fix the corruption in the output fixed.ts.
By default ffmpeg is grabbing only the first video and audio stream, so in case you want to transfer all streams you have to use the -map 0
option. The -ignore_unkown
option should ignore the unrecognized streams and drop them from the output, while -copy_unknown
will copy them. Unfortunately these two options were not working properly on my ffmpeg v.3.3.3.
ffmpeg -y -i input.ts -copyts -map 0 -c copy -ignore_unknown fixed_output.ts
This command is copying the whole TS to the fixed_output.ts file. Please note that if there is a scrambled channel and/or stream in the MPTS you will need to use the -copyts
flag, otherwise ffmpeg won't copy the TS completely. For more information you can check the scrambled channels section in the WIKI dedicated to dealing with scrambled channels
You can also use the following command to copy only certain programs to the output:
ffmpeg -y -i input.ts -map 0:p:1 -map:p:2 -map:p:3 -c copy -ignore_unknown fixed_output.ts
where:
-map 0:p:1
, -map 0:p:2
, etc are defining which programs to be forwarded to the output only.
You can see the programs in the MPTS using the following command:
ffmpeg -i input.ts
When the channels are forwarded ffmpeg won't preserve their names and service providers so you can use -metadata service_name="Service Name"
and -metadata service_provider="ServiceProviderName"