Compare commits
60 Commits
77b7638573
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb019413cc | ||
|
|
40ca3e136b | ||
|
|
367cb440d8 | ||
|
|
c565699875 | ||
|
|
75f227786f | ||
|
|
960de11b1b | ||
|
|
e192c66157 | ||
|
|
23f1db5ffa | ||
|
|
362844f8a1 | ||
|
|
6ad2c3b50a | ||
|
|
ddec8633e3 | ||
|
|
c3943ff70e | ||
|
|
926ee16433 | ||
|
|
489435a87f | ||
|
|
efceec0e48 | ||
|
|
10234d67da | ||
|
|
7e5a500279 | ||
|
|
8aca12c422 | ||
|
|
b94f865831 | ||
|
|
48cc4f8a27 | ||
|
|
889b8dd6dc | ||
|
|
ffce9aecdf | ||
|
|
4dbf9d9c03 | ||
|
|
03922a76d2 | ||
|
|
f23423ca8d | ||
|
|
3681ff33f3 | ||
|
|
59b55bac6c | ||
|
|
2bf9b467bb | ||
|
|
6959e83327 | ||
|
|
2f425aa9cf | ||
|
|
556d88d73a | ||
|
|
af52c80a8e | ||
|
|
04d23ca1b2 | ||
|
|
88d9d15496 | ||
|
|
b1c58fc53a | ||
|
|
4070f34a60 | ||
|
|
cb600b920d | ||
|
|
bb5333ffca | ||
|
|
1ed4bbf6df | ||
|
|
9a8f97a278 | ||
|
|
650724c966 | ||
|
|
40592dcec2 | ||
|
|
da13f3e9c8 | ||
|
|
b4e304d9ab | ||
|
|
44d47a564c | ||
|
|
b8394069fb | ||
|
|
124772aaeb | ||
|
|
076e3c990b | ||
|
|
d549311e20 | ||
|
|
4a1bf64bda | ||
|
|
58ec094cfc | ||
|
|
0f46dc9fda | ||
|
|
cf4850c8dc | ||
|
|
ed0494b540 | ||
|
|
22592214bb | ||
|
|
0678716c1c | ||
|
|
685365388e | ||
|
|
4bd294e26b | ||
|
|
840aa5c41f | ||
|
|
9f9e17e6ca |
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
*.pcm
|
||||||
|
*.ppm
|
||||||
|
*.ts
|
||||||
|
*.mkv
|
||||||
|
part*
|
||||||
|
venv/
|
||||||
2
Makefile
Normal file
2
Makefile
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
clean:
|
||||||
|
rm -f *.ppm *.pcm part* *.srt *-ts.txt *-full.h264 *-novideo.mkv fre.*
|
||||||
52
README.md
52
README.md
@@ -1,3 +1,51 @@
|
|||||||
# removeads
|
# Goal of the script
|
||||||
|
|
||||||
Remove ads from TV recordings with optimal cuts.
|
Remove ads from TV recordings with optimal cuts with single video frame precision.
|
||||||
|
|
||||||
|
When I record a movie on TV, I sometimes wish to archive the movie on my NAS.
|
||||||
|
In that case, I want to remove (at least) the beginning and the end of the recording
|
||||||
|
if the movie was broadcast on a advertisment free channel, or even worse I may
|
||||||
|
have to split it in numerous parts so as to remove the advertisments.
|
||||||
|
And I do not want to reencode the entire movie since it's a really slow process (on my NAS)
|
||||||
|
and the movie is already broadcast using H264 (DVB-T).
|
||||||
|
|
||||||
|
Doing this by hand is really painful, because most tools like ffmpeg, or mkvmerge are only
|
||||||
|
able to cut a movie (without reencoding) at a boundary within the video stream that corresponds
|
||||||
|
to a reference frame (so called I-frames). These frames are only present roughly every 10-20 frames
|
||||||
|
which corresponds to quite long duration (in the order of a second).
|
||||||
|
|
||||||
|
I really want to cut the movie with a better precision. So I have written a Python script
|
||||||
|
that leverages _ffmpeg_, _ffprobe_ and _mkvmerge_, _subvodocr_ to do the job with the required precision.
|
||||||
|
|
||||||
|
# Parameters
|
||||||
|
|
||||||
|
# How does it work ?
|
||||||
|
|
||||||
|
The processing follows a quite long pipeline:
|
||||||
|
|
||||||
|
1. The original .ts file is first transformed into an .mp4 file using _ffmpeg_ to correct timestamps:
|
||||||
|
|
||||||
|
2. The .mp4 is then transformed into a Matroska container (which is the default container) still using _ffmpeg_:
|
||||||
|
|
||||||
|
3. Then the movie is then cut using the indications passed as parameters. It is possible to give as many parts as needed.
|
||||||
|
|
||||||
|
Each part is treated with the same algorithm.
|
||||||
|
Trouver l'estampille de la trame 'I' la plus proche (mais postérieure) au début de la portion.
|
||||||
|
Trouver l'estampille de la trame 'I' la plus proche (mais antérieure) à la fin de la portion.
|
||||||
|
On a alors
|
||||||
|
debut ----- trame --------- trame --------- fin.
|
||||||
|
'B/P' 'B/P'* 'I' 'I' 'B/P'* 'B/P'
|
||||||
|
Si la trame de début est déjà 'I', il n'y a rien à faire (idem pour la fin).
|
||||||
|
Sinon on extrait les trames 'B' ou 'P' depuis le début jusqu'à la trame 'I' non incluse
|
||||||
|
|
||||||
|
4. Then each part that have been previously obtained are merged using _mkvmerge_:
|
||||||
|
|
||||||
|
5. The subtitles (image based) are then extracted using _mkvextract_:
|
||||||
|
|
||||||
|
6. These images are then processed using _vobsubocr_ to create SRT files:
|
||||||
|
|
||||||
|
7. The SRT files are then remuxed inside the Matroska container using _mkvmerge_:
|
||||||
|
|
||||||
|
# How to determine where to cuts
|
||||||
|
|
||||||
|
Use `mpv --osd-fractions --osd-level=3 ./movie.ts`
|
||||||
|
|||||||
3811
removeads.py
3811
removeads.py
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,6 @@
|
|||||||
xmltodict
|
xmltodict
|
||||||
requests
|
requests
|
||||||
pygame
|
|
||||||
coloredlogs
|
coloredlogs
|
||||||
|
tqdm
|
||||||
|
iso639-lang
|
||||||
|
hexdump
|
||||||
|
|||||||
Reference in New Issue
Block a user