<p>I have a number of videos that contain sound sequences that repeat with a corresponding video freeze. I have an example clip that contains a sound sequence from 51.194s -- 60.133s that repeats again from  60.157s--69.096s with a corresponding video freeze that consists of a single frame at 61.144s with next frame coming nearly 9 seconds later at 70.149s.</p>
<p>I've managed to cobble together a perl script that will find and repair the erroes in this particular sample. The repair was to simply delete the second sound sequence (51.194s -- 60.133s) and reduce the following audio time stamps by ~8.9s and to reduce the video timestamps after 61.144s by the same 8.9s.</p>
<p>As I said my script is simply cobbled toghether and before putting more work into it, I would like to explore options with ffmpeg.</p>
<p>I've had luck using freezedetect to find the frozen video:</p>
<pre><code>ffmpeg -i input.flv -vf &quot;freezedetect=n=0:d=2&quot;  -f null -
[freezedetect @ 0x5632dc441f00] lavfi.freezedetect.freeze_start: 61.14421.5x    
[freezedetect @ 0x5632dc441f00] lavfi.freezedetect.freeze_duration: 9.005
[freezedetect @ 0x5632dc441f00] lavfi.freezedetect.freeze_end: 70.149
[freezedetect @ 0x5632dc441f00] lavfi.freezedetect.freeze_start: 116.1112.2x
</code></pre>
<p>And I've attempted to use trim/atrim to repair the file -- with no luck:</p>
<pre><code>ffmpeg -i input.flv -filter_complex
'[0:v] trim=end=61.115,trim=start=70.107, setpts=PTS-STARTPTS [v0];
 [0:a] atrim=end=60.158,atrim=start=69.121,asetpts=PTS-STARTPTS [a0]'
 -map [v0] -map [a0] output.flv
</code></pre>
<p>This produced a short, unplayable file. But even if this had worked, I'd need some way to detect the duplicated audio first.</p>
<p>So is there a filter that will detect and repair the problems I've described above? Something like this:</p>
<pre><code>ffmpeg -i broken.mp4 -vf {dup remove filter} fixed.mp4
</code></pre>

CC BY-SA 4.0
2020-12-10T00:30:50.197Z
is there any reasons the end is smaller than the start in the trim filter?
xer-rex
CC BY-SA 4.0
2020-12-10T22:40:57.660Z
I can't seem to edit the question but my understanding is this acts as 2 trims the first will include segments in 0--61.115s and the second will include segments between 70.107 and the end of the video.
nilram
<ffmpeg>
Finding and repairing duplicate sound with ffmpeg
nilram
# Finding and repairing duplicate sound with ffmpeg

(Asked by: username_0 on 2020-12-09)

I have a number of videos that contain sound sequences that repeat with a corresponding video freeze. I have an example clip that contains a sound sequence from 51.194s -- 60.133s that repeats again from  60.157s--69.096s with a corresponding video freeze that consists of a single frame at 61.144s with next frame coming nearly 9 seconds later at 70.149s.
I've managed to cobble together a perl script that will find and repair the erroes in this particular sample. The repair was to simply delete the second sound sequence (51.194s -- 60.133s) and reduce the following audio time stamps by ~8.9s and to reduce the video timestamps after 61.144s by the same 8.9s.
As I said my script is simply cobbled toghether and before putting more work into it, I would like to explore options with ffmpeg.
I've had luck using freezedetect to find the frozen video:
ffmpeg -i input.flv -vf "freezedetect=n=0:d=2"  -f null -
[freezedetect @ 0x5632dc441f00] lavfi.freezedetect.freeze_start: 61.14421.5x    
[freezedetect @ 0x5632dc441f00] lavfi.freezedetect.freeze_duration: 9.005
[freezedetect @ 0x5632dc441f00] lavfi.freezedetect.freeze_end: 70.149
[freezedetect @ 0x5632dc441f00] lavfi.freezedetect.freeze_start: 116.1112.2x

And I've attempted to use trim/atrim to repair the file -- with no luck:
ffmpeg -i input.flv -filter_complex
'[0:v] trim=end=61.115,trim=start=70.107, setpts=PTS-STARTPTS [v0];
 [0:a] atrim=end=60.158,atrim=start=69.121,asetpts=PTS-STARTPTS [a0]'
 -map [v0] -map [a0] output.flv

This produced a short, unplayable file. But even if this had worked, I'd need some way to detect the duplicated audio first.
So is there a filter that will detect and repair the problems I've described above? Something like this:
ffmpeg -i broken.mp4 -vf {dup remove filter} fixed.mp4

**Tags:** ffmpeg

> **Comments:**
> **username_1**: is there any reasons the end is smaller than the start in the trim filter?  
> **username_0**: I can't seem to edit the question but my understanding is this acts as 2 trims the first will include segments in 0--61.115s and the second will include segments between 70.107 and the end of the video.  

---

## 0 answers

