Discussion:
[FFmpeg-user] Force concat to ignore corrupt files?
Phunkadilic
2014-04-14 21:49:24 UTC
Permalink
I'm currently using this command to concat individual video files every
night:

"ffmpeg.exe -f concat -i C:\path\video-files.txt -c copy
C:\Desitination\path\concat-file.mp4"

I've noticed that if there's a single corrupt .mp4 file, the command will
stop and concat only the files that were good before hitting the corrupt
file. Is there a way/command to have ffmpeg to either skip any corrupt
files or to force through and ignore errors?

This script runs automatically nightly and I'd rather not have to babysit
these files. If there's one or two corrupt files, I'd rather them just be
skipped and not worry about having to go through and remove the corrupt
files and re-do the process manually.

Thanks in advance!



--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Force-concat-to-ignore-corrupt-files-tp4664775.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.
Carl Eugen Hoyos
2014-04-16 11:07:17 UTC
Permalink
Post by Phunkadilic
"ffmpeg.exe -f concat -i C:\path\video-files.txt -c copy
C:\Desitination\path\concat-file.mp4"
I've noticed that if there's a single corrupt .mp4 file,
the command will stop and concat only the files that
were good before hitting the corrupt file.
I suspect this cannot be fixed (depending on what you mean)
but please describe a testcase.
(minimal video-files.txt, two ffmpeg -i outputs and the
output of the failing concat command).

Carl Eugen
Nicolas George
2014-04-16 14:38:24 UTC
Permalink
Post by Phunkadilic
I'm currently using this command to concat individual video files every
"ffmpeg.exe -f concat -i C:\path\video-files.txt -c copy
C:\Desitination\path\concat-file.mp4"
I've noticed that if there's a single corrupt .mp4 file, the command will
stop and concat only the files that were good before hitting the corrupt
file. Is there a way/command to have ffmpeg to either skip any corrupt
files or to force through and ignore errors?
This script runs automatically nightly and I'd rather not have to babysit
these files. If there's one or two corrupt files, I'd rather them just be
skipped and not worry about having to go through and remove the corrupt
files and re-do the process manually.
I may be wrong, but it seems to me like a very specific use case.

I suggest you test if the file is corrupt while constructing your concat
script. Something like that would probably do the trick (with extra shell
escaping of course):

for f in $files; do
if ffprobe -loglevel warning $f; then
printf 'file %s\n' $f >> $concat
else
corrupted=$((corrupted+1))
fi
done

That way, you can do smart decisions depending on the amount of corrupted
files, for example. Depending on the degree of corruption you want to guard
against, you may want to read the file completely (-show_packets), or maybe
even decode it (-show_frames). Note that since the concat demuxer works at
demuxer level, it could not guard against problems at the decoding level
anyway.

Regards,
--
Nicolas George
Phunkadilic
2014-04-16 15:25:15 UTC
Permalink
Thanks for these great tips. Basically it's like this. I'm using the concat command for daily merging of video capture files (.mp4). Every now and then I'll get one or two video files that will have some time of error or will be incomplete. The concat command see's these files and simply stops the concat process instead of skipping them and continuing on to the next good file in the list. This is what I would to fix. I want the concat function to continue on instead of getting stuck and exiting the first time it hits a bad file.

I'll have to try the ffprobe command to see if that does the trick.

-Dilan
_________________________________
"NO OBSTACLES, ONLY CHALLENGES!" -Groove
Post by Nicolas George
Post by Phunkadilic
I'm currently using this command to concat individual video files every
"ffmpeg.exe -f concat -i C:\path\video-files.txt -c copy
C:\Desitination\path\concat-file.mp4"
I've noticed that if there's a single corrupt .mp4 file, the command will
stop and concat only the files that were good before hitting the corrupt
file. Is there a way/command to have ffmpeg to either skip any corrupt
files or to force through and ignore errors?
This script runs automatically nightly and I'd rather not have to babysit
these files. If there's one or two corrupt files, I'd rather them just be
skipped and not worry about having to go through and remove the corrupt
files and re-do the process manually.
I may be wrong, but it seems to me like a very specific use case.
I suggest you test if the file is corrupt while constructing your concat
script. Something like that would probably do the trick (with extra shell
for f in $files; do
if ffprobe -loglevel warning $f; then
printf 'file %s\n' $f >> $concat
else
corrupted=$((corrupted+1))
fi
done
That way, you can do smart decisions depending on the amount of corrupted
files, for example. Depending on the degree of corruption you want to guard
against, you may want to read the file completely (-show_packets), or maybe
even decode it (-show_frames). Note that since the concat demuxer works at
demuxer level, it could not guard against problems at the decoding level
anyway.
Regards,
--
Nicolas George
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
signature.asc (836 bytes) Download Attachment
http://ffmpeg-users.933282.n4.nabble.com/Force-concat-to-ignore-corrupt-files-tp4664775p4664793.html
To unsubscribe from Force concat to ignore corrupt files?, click here.
NAML
--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Force-concat-to-ignore-corrupt-files-tp4664775p4664796.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.

Loading...