Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
2nd August 2017, 19:25 | #1 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
Detect Invalid Video File
I have written code that encodes videos in several segments and then merges at the end. It works fine *AS LONG AS* any segment is terminated cleanly. If you kill any of the FFMPEG processes, however, the merge will result in undefined behaviors.
How can I detect whether a video file is valid to prevent such undefined behavior? Is there any way to recover parts of an invalid file to make it valid, perhaps by discarding the end? Thanks |
2nd August 2017, 19:37 | #2 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Recover Parts: Just do a remux in ffmpeg and it should chop off crap at the end.
Remux to MKV, Code:
setlocal REM Where to Find ffmpeg set FFMPEG="C:\BIN\ffmpeg.exe" REM Where to get input file, No terminating Backslash, "." = current directory set INDIR="." REM Where to place output file, No terminating Backslash. set OUTDIR=".\OUTPUT" FOR %%A IN (*.wmv *.mpg *.avi *.flv *.mov *.mp4 *.m4v *.RAM *.RM) DO ( %FFMPEG% -i "%INDIR%\%%A" -vcodec copy -acodec copy "%OUTDIR%\%%~nxA.MKV" ) Pause EDIT: Maybe RaffRiff can comment on ffProbe use for error detection (Usually comes with full ffmpeg package).
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 2nd August 2017 at 19:40. |
5th August 2017, 03:47 | #4 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
In terms of terminating FFMPEG cleanly, I just found something. I run AVS2YUV and pipe it to FFMPEG; and now can run 4 instances in parallel. Killing FFMPEG gives an invalid file. Soft killing all 4 instances takes considerable time. If I hard kill the 4 instances of AVS2YUV, however, that stops immediately and FFMPEG still finishes writing its file
If someone kills a FFMPEG process manually, however, I still have no way of knowing the file is bad. |
Thread Tools | Search this Thread |
Display Modes | |
|
|