brettsheleski / comchap Goto Github PK
View Code? Open in Web Editor NEWCommercial detection script to add chapters into video file
License: MIT License
Commercial detection script to add chapters into video file
License: MIT License
If all the chapters don't have a title statement it mangles the chapters in the resulting file.
Example edl file:
0.00 8.88 0
83.78 243.74 0
781.15 1062.13 0
1514.78 1653.89 0
1843.04 1859.86 0
Original meta file from script (Note only commercials are labeled):
;FFMETADATA1
[CHAPTER]
TIMEBASE=1/1
START=0
END=0.00
[CHAPTER]
TIMEBASE=1/1
START=0.00
END=8.88
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=8.88
END=83.78
[CHAPTER]
TIMEBASE=1/1
START=83.78
END=243.74
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=243.74
END=781.15
[CHAPTER]
TIMEBASE=1/1
START=781.15
END=1062.13
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=1062.13
END=1514.78
[CHAPTER]
TIMEBASE=1/1
START=1514.78
END=1653.89
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=1653.89
END=1843.04
[CHAPTER]
TIMEBASE=1/1
START=1843.04
END=1859.86
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=1859.86
Resultant mangled chapters (from ffprobe):
Chapter #0:0: start 0.000000, end 83.000000
Metadata:
title : Commercial
Chapter #0:1: start 83.000000, end 781.000000
Metadata:
title : Commercial
Chapter #0:2: start 781.000000, end 1514.000000
Metadata:
title : Commercial
Chapter #0:3: start 1514.000000, end 1843.000000
Metadata:
title : Commercial
Chapter #0:4: start 1843.000000, end 1859.000000
Metadata:
title : Commercial
Chapter #0:5: start 781.000000, end 1062.000000
Metadata:
title : Commercial
Chapter #0:6: start 1062.000000, end 1514.000000
Metadata:
title :
Chapter #0:7: start 1514.000000, end 1653.000000
Metadata:
title : Commercial
Chapter #0:8: start 1653.000000, end 1843.000000
Metadata:
title :
Chapter #0:9: start 1843.000000, end 1859.000000
Metadata:
title : Commercial
Chapter #0:10: start 1859.000000, end 1860.125000
Metadata:
title :
Corrected metafile naming all chapters:
;FFMETADATA1
[CHAPTER]
TIMEBASE=1/1
START=0.00
END=8.88
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=8.88
END=83.78
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=83.78
END=243.74
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=243.74
END=781.15
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=781.15
END=1062.13
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=1062.13
END=1514.78
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=1514.78
END=1653.89
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=1653.89
END=1843.04
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=1843.04
END=1859.86
title=Commercial
[CHAPTER]
TIMEBASE=1/1
START=1859.86
title=Commercial
Resultant Correct mp4 (from ffprobe):
Chapter #0:0: start 0.000000, end 8.000000
Metadata:
title : Commercial
Chapter #0:1: start 8.000000, end 83.000000
Metadata:
title : Commercial
Chapter #0:2: start 83.000000, end 243.000000
Metadata:
title : Commercial
Chapter #0:3: start 243.000000, end 781.000000
Metadata:
title : Commercial
Chapter #0:4: start 781.000000, end 1062.000000
Metadata:
title : Commercial
Chapter #0:5: start 1062.000000, end 1514.000000
Metadata:
title : Commercial
Chapter #0:6: start 1514.000000, end 1653.000000
Metadata:
title : Commercial
Chapter #0:7: start 1653.000000, end 1843.000000
Metadata:
title : Commercial
Chapter #0:8: start 1843.000000, end 1859.000000
Metadata:
title : Commercial
Chapter #0:9: start 1859.000000, end 1860.125000
Metadata:
title :
The titles I inserted were all the same, but I actually think it might be better to name them something like:
The Roku lets me browse through the chapters and having them not named the same thing is a little more visually appealing.
Do you think it would be too hard to avoid chapters with 1 second or less?
I keep getting a first chapter with less than 1 second with a tiny piece of commercial before the start of the show.
Lines 135, 136 should have a space after -v -- without it on MacOS, awk version 20070501, I get this error: awk: invalid -v option
This is how it should be:
end=awk -v p="${line[0]}" 'BEGIN{printf "%.0f" ,p*1000}'
startnext=awk -v p="${line[1]}" 'BEGIN{printf "%.0f" ,p*1000}'
Hi,
Just a thought, as it saves needed disk space - but after a part-xx.ts file is added ... remove it? If not about 3x the disk space is needed overall (the original file, the part files, and then the cut file).
Thoughts?
Thanks!
Some of my recordings fails because the generated ffmeta file has the first chapter as:
[CHAPTER]
TIMEBASE=1/1
START=0
END=.97
This causes comskip to fail:
[ffmetadata @ 0x55744b6a0480] Expected chapter end timestamp, found END=.97.
[ffmetadata @ 0x55744b6a0480] Expected chapter start timestamp, found START=.97.
[ffmetadata @ 0x55744b6a0480] Expected chapter end timestamp, found START=.97.
Input #0, ffmetadata, from '/plex/The Big Bang Theory (2007) - S10E09 - The Geology Elevation.ffmeta':
Duration: 00:21:03.00, start: 0.000000, bitrate: 0 kb/s
Chapter #0:0: start 0.000000, end 115.000000
Chapter #0:1: start 0.000000, end 115.000000
Metadata:
END : 115.05
Chapter #0:2: start 115.000000, end 600.000000
Chapter #0:3: start 600.000000, end 1237.000000
Chapter #0:4: start 1237.000000, end 1263.000000
concat:/plex/The Big Bang Theory (2007) - S10E09 - The Geology Elevation.part-1.ts|/plex/The Big Bang Theory (2007) - S10E09 - The Geology Elevation.part-2.ts|/plex/The Big Bang Theory (2007) - S10E09 - The Geology Elevation.part-3.ts|/plex/The Big Bang Theory (2007) - S10E09 - The Geology Elevation.part-4.ts|/plex/The Big Bang Theory (2007) - S10E09 - The Geology Elevation.part-5.ts: No such file or directory
rm: cannot remove '/plex/The Big Bang Theory (2007) - S10E09 - The Geology Elevation.part-1.ts': No such file or directory
Have been pulling my hair out a bit with this, but it turns out ... if the EDL starts with identically 0 (i.e. 0.00). then the first cut is missed when calculating totalcutduration => and the metafile (and video length that is set) is incorrect as a result.
If the first entry in the EDL starts with zero, the duration of this first cut needs to be added to totalcutduration.
Thanks!
New install of Ubuntu, trying this out for the first time, and the script was eating my input file name by trying to process it as a 'key" value and "shift"ing it out. At least it was doing this if I only ran it with a filename, which is what I was trying.
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
.
.
.
esac
shift # past argument or value
done
I wrapped that section in:
if [[ $1 == "--*" ]]
then
.
.
.
fi
So it would only try that section if a parameter had a -- at the front, and it lets it run. I haven't tried various combinations of with or without parameters/etc... Curious why bash is behaving differently here than it would for you. :(
~/.cmskip.ini should be checked to see if it contains "output_edl=1". if it does not, then add it to the file.
Currently it is adding an "output_edl=1" to the file every time (even if it is already in the file).
Add a command line argument that would remove commercials from the file instead of just marking them as chapters.
Hello
Is there any plans to make a windows version? I would like to use this with WMC.
I get error like this when I run comcut. The error comes right after comskip is finished and found com's
/usr/local/bin/comcut --comskip=/usr/local/bin/comskip --comskip-ini=/usr/local/etc/comskip.ini --keep-edl --ffmpeg=/usr/bin/ffmpeg /MEDIA/FILM/The\ Maze\ Runner/The\ Maze\ Runner.mkv
[mpegts @ 0x152c680] H.264 bitstream malformed, no startcode found, use the video bitstream filter 'h264_mp4toannexb' to fix it ('-bsf:v h264_mp4toannexb' option with ffmpeg)
av_interleaved_write_frame(): Invalid data found when processing input
Any Idea how to fix that ?
Hello, so in a nut shell, I use Channels-DVR to record shows. Channels produces the file (they are .mpgs') and then dumps it in its DVR folder. With it, it also dumps a .edl folder and the program reads it to skip commercials. Plex does not read .edl's... so what I'd like to have done is use comcut to find these .mpg's that are in the DVR directory (and sub directories for shows), run the comcut process with the .edl (keeping the .edl when done) and then moving the result to another directory for plex to see. I can get this to work via the command line but I can't get it to retain the original file name. I'm using comcut /home/user/dvr/*.mpg *.mpg, which just renames it to a *.mpg (sorry my Linux skills are mediocre). Is there a way to use comcut to do this, or know of a script that would automatically do this?
Currently Comcut and Comchap are largely the same and only really differ in operation after Comskip and generating the ffmeta file is done.
This leads to duplicate code. Duplicate code is bad code. This leads to functionality being added to one script and not to the other, or at least not consistently.
Refactor Comcut and Comchap so that the common tasks such as setting up and running Comskip, generating the ffmeta file, file cleanup, etc. is implemented once and only once.
Currently unsure what the best approach is to handle this.
Hi,
It seems like if processing a shorter file, with no commercials => then things break. Or is it just me?
Thanks!
How to recreate
Import an .edl file where the first element begins with a 0. The resulting output file will have either corrupted audio or no audio at all.
Example .edl file
0 86.39 3
574.49 845.76 3
1085.22 1380.4 3
1619.95 1872.42 3
2360.87 2637.57 3
2966 3087.17 3
3351.55 3639.85 3
Manual Fix
Modify the .edl file prior to using comcut by replacing the 0 with 0.0 or 00.00. Comcut will process the .edl file correctly and the resulting video file will function as expected.
00.00 86.39 3
574.49 845.76 3
...
Notes
The video files I am converting are DVR recordings of Over the Air broadcasts using Channels DVR. By default, I add some padding before and after each recording to accommodate for time deviation. Therefore, all resulting recordings will need content removed from the beginning and end of each file.
I'm getting the following on Fedora 25:
$ comcut All\ Our\ Yesterdays.mpg All\ Our\ Yesterdays\ comcut.mpg
Comskip 0.81.089, made using ffmpeg
Donator build
The commandline used was:
comskip --ini=/home/orion/.comskip.ini "All Our Yesterdays.mpg"
Setting ini file to /home/orion/.comskip.ini as per commandline
Using /home/orion/.comskip.ini for initiation values.
1:02:46 - 115335 frames in 1873.16 sec(61.57 fps), 1.00 sec(133.00 fps), 89%
115430 frames decoded in 1873.80 seconds (61.60 fps)
Commercials were found.
ffmpeg version 3.1.6 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160916 (Red Hat 6.2.1-2)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --extra-ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --extra-cflags=-I/usr/include/nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-libmfx --enable-runtime-cpudetect
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mpeg, from 'All Our Yesterdays.mpg':
Duration: 01:10:01.17, start: 0.982767, bitrate: 2126 kb/s
Stream #0:0[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[mpegts @ 0x804eb4c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mpegts, to 'All Our Yesterdays.part-1.ts':
Metadata:
encoder : Lavf57.41.100
Stream #0:0: Video: mpeg2video, yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Stream #0:1: Audio: mp2, 48000 Hz, stereo, 192 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (copy)
frame= 0 fps=0.0 q=-1.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
ffmpeg version 3.1.6 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160916 (Red Hat 6.2.1-2)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --extra-ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --extra-cflags=-I/usr/include/nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-libmfx --enable-runtime-cpudetect
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mpeg, from 'All Our Yesterdays.mpg':
Duration: 01:10:01.17, start: 0.982767, bitrate: 2126 kb/s
Stream #0:0[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[mpegts @ 0x8087d4c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mpegts, to 'All Our Yesterdays.part-2.ts':
Metadata:
encoder : Lavf57.41.100
Stream #0:0: Video: mpeg2video, yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Stream #0:1: Audio: mp2, 48000 Hz, stereo, 192 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (copy)
[mpegts @ 0x8087d4c0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mpegts @ 0x8087d4c0] first pts value must be set
av_interleaved_write_frame(): Invalid data found when processing input
frame= 1 fps=0.0 q=-1.0 Lsize= 14kB time=00:00:00.53 bitrate= 212.8kbits/s speed=6.05x
video:9kB audio:12kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
ffmpeg version 3.1.6 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160916 (Red Hat 6.2.1-2)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --extra-ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --extra-cflags=-I/usr/include/nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-libmfx --enable-runtime-cpudetect
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mpeg, from 'All Our Yesterdays.mpg':
Duration: 01:10:01.17, start: 0.982767, bitrate: 2126 kb/s
Stream #0:0[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[mpegts @ 0x8014f4c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mpegts, to 'All Our Yesterdays.part-3.ts':
Metadata:
encoder : Lavf57.41.100
Stream #0:0: Video: mpeg2video, yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Stream #0:1: Audio: mp2, 48000 Hz, stereo, 192 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (copy)
[mpegts @ 0x8014f4c0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mpegts @ 0x8014f4c0] first pts value must be set
av_interleaved_write_frame(): Invalid data found when processing input
frame= 1 fps=0.2 q=-1.0 Lsize= 13kB time=00:00:00.49 bitrate= 207.9kbits/s speed=0.124x
video:7kB audio:11kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
ffmpeg version 3.1.6 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160916 (Red Hat 6.2.1-2)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --extra-ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --extra-cflags=-I/usr/include/nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-libmfx --enable-runtime-cpudetect
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mpeg, from 'All Our Yesterdays.mpg':
Duration: 01:10:01.17, start: 0.982767, bitrate: 2126 kb/s
Stream #0:0[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[mpegts @ 0x81bd94c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mpegts, to 'All Our Yesterdays.part-4.ts':
Metadata:
encoder : Lavf57.41.100
Stream #0:0: Video: mpeg2video, yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Stream #0:1: Audio: mp2, 48000 Hz, stereo, 192 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (copy)
[mpegts @ 0x81bd94c0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mpegts @ 0x81bd94c0] first pts value must be set
av_interleaved_write_frame(): Invalid data found when processing input
frame= 1 fps=0.1 q=-1.0 Lsize= 12kB time=00:00:00.43 bitrate= 215.7kbits/s speed=0.0525x
video:7kB audio:10kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
ffmpeg version 3.1.6 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160916 (Red Hat 6.2.1-2)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --extra-ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --extra-cflags=-I/usr/include/nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-libmfx --enable-runtime-cpudetect
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mpeg, from 'All Our Yesterdays.mpg':
Duration: 01:10:01.17, start: 0.982767, bitrate: 2126 kb/s
Stream #0:0[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[mpegts @ 0x806bc4c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mpegts, to 'All Our Yesterdays.part-5.ts':
Metadata:
encoder : Lavf57.41.100
Stream #0:0: Video: mpeg2video, yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Stream #0:1: Audio: mp2, 48000 Hz, stereo, 192 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (copy)
[mpegts @ 0x806bc4c0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mpegts @ 0x806bc4c0] first pts value must be set
av_interleaved_write_frame(): Invalid data found when processing input
frame= 1 fps=0.1 q=-1.0 Lsize= 8kB time=00:00:00.29 bitrate= 212.5kbits/s speed=0.0198x
video:5kB audio:7kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
ffmpeg version 3.1.6 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160916 (Red Hat 6.2.1-2)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --extra-ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --extra-cflags=-I/usr/include/nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-libmfx --enable-runtime-cpudetect
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mpeg, from 'All Our Yesterdays.mpg':
Duration: 01:10:01.17, start: 0.982767, bitrate: 2126 kb/s
Stream #0:0[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[mpegts @ 0x819da4c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mpegts, to 'All Our Yesterdays.part-6.ts':
Metadata:
encoder : Lavf57.41.100
Stream #0:0: Video: mpeg2video, yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Stream #0:1: Audio: mp2, 48000 Hz, stereo, 192 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (copy)
[mpegts @ 0x819da4c0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mpegts @ 0x819da4c0] first pts value must be set
av_interleaved_write_frame(): Invalid data found when processing input
frame= 1 fps=0.1 q=-1.0 Lsize= 10kB time=00:00:00.40 bitrate= 212.6kbits/s speed=0.0214x
video:19kB audio:9kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
ffmpeg version 3.1.6 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160916 (Red Hat 6.2.1-2)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --extra-ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --extra-cflags=-I/usr/include/nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-libmfx --enable-runtime-cpudetect
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mpeg, from 'All Our Yesterdays.mpg':
Duration: 01:10:01.17, start: 0.982767, bitrate: 2126 kb/s
Stream #0:0[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 192 kb/s
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
[mpegts @ 0x8107a4c0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mpegts, to 'All Our Yesterdays.part-7.ts':
Metadata:
encoder : Lavf57.41.100
Stream #0:0: Video: mpeg2video, yuv420p(tv, fcc/bt470bg/bt470bg), 480x480 [SAR 4:3 DAR 4:3], q=2-31, 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Stream #0:1: Audio: mp2, 48000 Hz, stereo, 192 kb/s
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (copy)
[mpegts @ 0x8107a4c0] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mpegts @ 0x8107a4c0] first pts value must be set
av_interleaved_write_frame(): Invalid data found when processing input
frame= 1 fps=0.0 q=-1.0 Lsize= 5kB time=00:00:00.18 bitrate= 206.6kbits/s speed=0.00699x
video:11kB audio:4kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Conversion failed!
ffmpeg version 3.1.6 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160916 (Red Hat 6.2.1-2)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --optflags='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --extra-ldflags='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcdio --enable-indev=jack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libmp3lame --enable-nvenc --extra-cflags=-I/usr/include/nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-libmfx --enable-runtime-cpudetect
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, ffmetadata, from 'All Our Yesterdays.ffmeta':
Duration: 00:49:03.79, start: 0.000000, bitrate: N/A
Chapter #0:0: start 0.000000, end 0.000000
Chapter #0:1: start 0.000000, end 223.490000
Chapter #0:2: start 223.490000, end 601.460000
Chapter #0:3: start 601.460000, end 1246.960000
Chapter #0:4: start 1246.960000, end 2177.370000
Chapter #0:5: start 2177.370000, end 2688.840000
Chapter #0:6: start 2688.840000, end 2943.790000
[mpegts @ 0x802eb500] start time for stream 0 is not set in estimate_timings_from_pts
[mpegts @ 0x802eb500] Could not find codec parameters for stream 0 (Video: mpeg2video ([2][0][0][0] / 0x0002), none(tv)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #1, mpegts, from 'concat:All Our Yesterdays.part-1.ts|All Our Yesterdays.part-2.ts|All Our Yesterdays.part-3.ts|All Our Yesterdays.part-4.ts|All Our Yesterdays.part-5.ts|All Our Yesterdays.part-6.ts|All Our Yesterdays.part-7.ts':
Duration: 00:00:00.50, start: 1.409233, bitrate: 993 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #1:0[0x100]: Video: mpeg2video ([2][0][0][0] / 0x0002), none(tv), 90k tbr, 90k tbn, 90k tbc
Stream #1:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 192 kb/s
[mpeg @ 0x802f1e40] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Output #0, mpeg, to 'All Our Yesterdays comcut.mpg':
Metadata:
encoder : Lavf57.41.100
Chapter #0:0: start 0.000000, end 0.000000
Chapter #0:1: start 0.000000, end 223.490000
Chapter #0:2: start 223.490000, end 601.460000
Chapter #0:3: start 601.460000, end 1246.960000
Chapter #0:4: start 1246.960000, end 2177.370000
Chapter #0:5: start 2177.370000, end 2688.840000
Chapter #0:6: start 2688.840000, end 2943.790000
Stream #0:0: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, 192 kb/s
Stream mapping:
Stream #1:1 -> #0:0 (copy)
size= 54kB time=00:00:02.28 bitrate= 194.0kbits/s speed= 228x
video:0kB audio:54kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.487025%
I was experiencing a 5-10% failure rate on MKV files while cutting commercials, resulting in movies with no video. After a lot of debugging and reading, I came across this additional argument string for FFMPEG that has totally solved the problem:
-analyzeduration 100M -probesize 100M
My current modified script is attached.
First of all I want to say thank you for this awesome script. Second of all, I want to make clear that this is not meant as criticism of any kind, I'm just curious.
I'm currently working on a highly personalized fork of this project, most notably 'comcut'. So I noticed that intermediate files (infile.part-1.ts
, etc) have an .TS
extension and I would like to know if they were chosen for a specific reason.
The reason I'm asking is because I'm thinking about switching them (for my fork) to Matroska so that they can support subrip subtitles and I'm worried that this will cause trouble.
The MKV format allows for richer chapter specifications that could allow a player to automatically skip over the chapters labeled as commercials. This would give the best of both worlds of cutting and marking commercials -- no user intervention necessary to skip commercials, but if they are incorrectly identified, a user can go back and view them.
https://mkvtoolnix.download/doc/mkvmerge.html#mkvmerge.chapters
I wrote up a version of comchap that creates an XML chapter file and merges it in with mkvmerge.
As yet, unfortunately, Plex doesn't respect the ChapterFlagEnabled and ChapterFlagHidden settings. Ideally, it would skip over the sections identified as commercials, and not show the commercial chapters in the list of chapters.
Other players may support these features however. Let me know if you're interested in integrating my code.
i updated comcut to include handbrakecli post-processing, any objections if i submitted these updates to your project? the reason is mainly for decombing and compressing. this would be disabled by default and require a command line argument to enable.
FYI, the last portion of the file is not included ... from the end of the last line in the EDL file, to the end of the video.
Thanks!
The last two nights when comchap was launched through my cron jobs I was surprised to find no chapters in the resulting files. I logged in and tested it again and again and analyzed my code again and again and couldn't find the issue.
Finally it occurred to me that since it was launching through cron the paths weren't setup properly and comchap wasn't flagging it as an error as it ran. I made some changes to comchap to address all the corner cases I found when I went into the script.
Either issues should not allow the script to proceed. The rest of the script is wholly dependent upon the edl file being present and of non-zero length. Because the cleanup for the lock file is at the end of the script I had to replicate the lock file cleanup and exit with error status in the middle of the script.
The way I did this isn't what I'd consider optimal. In Perl (my comfort zone) I would create a error subroutine which I would call in the event of an error. The error subroutine would print the error and it would also perform the file cleanup / removal of lock file, etc. That way the exit and cleanup doesn't need to be replicated multiple times. I'm out of my depth in Bash to do something similar.
if [ ! -f "$edlfile" ]; then
$comskipPath --ini="$comskipini" "$infile"
if [ ! -f "$edlfile" ] || [ ! -s "$edlfile" ]; then
echo Error running comskip. 1>&3 2>&4
if [ ! -z "$lockfile" ]; then
rm "$lockfile"
fi
exit -1
fi
fi
if [ "$infile" -ef "$outfile" ] ; then
tempfile=`mktemp --suffix=."$outextension" "$outdir"/XXXXXXXX`
echo Writing file to temporary file: "$tempfile"
if $ffmpegPath -loglevel error -hide_banner -nostdin -i "$infile" -i "$metafile" -map_metadata 1 -codec copy -y "$tempfile" 1>&3 2>&4; then
mv -f "$tempfile" "$outfile"
echo Saved to: "$outfile"
else
echo Error running ffmpeg. 1>&3 2>&4
exitcode=-1
fi
exit $exitcode
if [ ! -f "$outfile" ]; then
echo Error, "$outfile" does not exist. 1>&3 2>&4
exitcode=-1
fi
Removed encoding when no commercials are present. If no commercials are present it should be counted as an error because the main point of running is to detect commercials. Previously it was simply running ffmpeg and copying the streams and acting like it actually successfully ran.
Minor code cleanup, removed a redundant outfile assignment. There's no need to do the initial 'outfile' assignment because the conditional that follows assigns it in either case, making the original redundant.
infile=$1
if [[ -z "$2" ]]; then
outfile="$infile"
else
outfile="$2"
fi
I've been working on a docker service that combines plex and comskip (and a few other things) to produce a simple to use plex implementation complete with automatic commercial marking/cutting and transcoding.
I've published my build files on github here.
I've been using (unmodified) your comchap and comcut scripts.
What I provide at this point is a dockerfile and a set of scripts that will build a container that includes comcut and comchap copied directly from your github repo. What I'd really like to do is set up an automated build on the dockerhub for a complete container that includes a pre-built comskip.
Before I do that I wanted to make sure it was okay with you. I'm not really sure what license you provide the source code, but I figure its best to make sure its okay with you before I proceed.
The only essential feature missing (which I'll need to add if you aren't game to add it) is some type of quiet switch. I run this post-processing in a cron job at night so if it runs successfully I'll need it to be completely silent. Only if it runs into problems should it print out anything which by default gets e-mailed to me to resolve.
Let me know, I can help add this if you don't want to spend the time. This is more of an issue that I care about so I'm willing to put the time into creating it.
The audio cuts out just before a commercial, looking for possible solutions I read on the MCEBuddy FAQ, a possible cause for this, is corruption at the start of the video and recommends skipping the first 3-30 seconds of the video.
Would it be possible to add a variable so I could skip the first X seconds ?
Aside from the audio desync I get noticeable glitching and stuttering at the start of the video anyway and I'd like to skip that.
Comskip generated the following /recordings/movie.edl:
0.00 739.92 0
3502.08 3698.60 0
5162.68 5350.08 0
I feeded it into Comchap with command:
/home/comchap/comchap --ffmpeg=/usr/bin/ffmpeg --comskip=/usr/bin/comskip --keep-edl --keep-meta /recordings/movie.mkv
This generates the /recordings/movie.ffmeta
;FFMETADATA1
[CHAPTER]
TIMEBASE=1/1000
START=0
END=3502080
title=Chapter 1
[CHAPTER]
TIMEBASE=1/1000
START=3502080
END=3698600
title=Commercial 1
[CHAPTER]
TIMEBASE=1/1000
START=3698600
END=0
title=Chapter 2
[CHAPTER]
TIMEBASE=1/1000
START=0
END=0
title=Commercial 2
[CHAPTER]
TIMEBASE=1/1000
START=0
END=6179950
title=Chapter 3
... and then Comchap crashes with message:
[ffmetadata @ 0x74a36030] Chapter end time 0 before start 3698600
/recordings/movie.ffmeta: Out of memory
Error running ffmpeg: /recordings/movie.mkv
RAM may not the issue, there is a lot of free memory..
Maybe this part of the .ffmeta is corrupt?
...
[CHAPTER]
TIMEBASE=1/1000
START=3698600
END=0
title=Chapter 2
...
System information
Raspberry Pi 3 (armhf)
awk: BusyBox v1.26.2 (2017-06-11 06:38:58 GMT) multi-call binary.
Comskip 0.81.098, made using ffmpeg
Comchap master (d52aa36)
I try to cut com's from an .ts file, but the output is much bigger than inputfile
Why is that, and anyway to change that ?
This has been working for me for well over a year now, but suddenly chapters are not being added by ffmpeg. The edl file is created just fine. The meta file is created for ffmpeg. Ffmpeg runs without any error, but the chapters are just not present. I'm at a loss because I haven't changed anything on my system, so I have no idea what update might have broken it.
Decided to make a powershell version of comcut for fun (and for me):
param(
[string]$infile,
[string]$outfile,
[switch]$keepEdl,
[switch]$keepMeta,
[string]$ffmpegPath = ".\ffmpeg.exe",
[string]$comskipPath = ".\comskip.exe",
[string]$comskipini = "$env:USERPROFILE.comskip.ini",
[string]$lockfile,
[string]$workdir
)
$ldPath = $env:LD_LIBRARY_PATH
$env:LD_LIBRARY_PATH = ""
$exitcode = 0
if (-not $infile) {
$exename = Split-Path -Leaf $MyInvocation.MyCommand.Path
Write-Host "Remove commercial from video file using EDL file"
Write-Host " (If no EDL file is found, comskip will be used to generate one)"
Write-Host ""
Write-Host "Usage: $exename infile [outfile]"
exit 1
}
[bool]$deleteedl = $keepEdl
[bool]$deletemeta = $keepMeta
$deletelog = $true
$deletelogo = $true
$deletetxt = $true
$tempfiles = @()
$totalcutduration = 0
if (-not $outfile) {
$outfile = $infile
}
$outdir = Split-Path $outfile -Parent
$outextension = $outfile -split "." | Select-Object -Last 1
$comskipoutput = ""
if ($workdir) {
if (!($workdir.EndsWith(""))) {
$comskipoutput = "--output=$workdir"
$workdir += ""
}
$infileb = Split-Path $infile -Leaf
}
else {
}
if (-not (Test-Path $comskipIni)) {
"output_edl=1" | Out-File -Encoding utf8 $comskipIni
}
elseif ((Get-Content $comskipIni) -notcontains "output_edl=1") {
"output_edl=1" | Add-Content -Encoding utf8 $comskipIni
}
if (-not (Test-Path $edlfile)) {
& "$comskipPath" $comskipoutput --ini="$comskipIni" "$infile"
}
$start = 0
$i = 0
$hascommercials = $false
$concat = ""
$lines = Get-Content $edlfile
foreach ($line in $lines) {
$fields = $line -split "`t"
$end = [float]$fields[0]
$startnext = [float]$fields[1]
if ([double]$end * 1000 -gt [double]$start * 1000) {
$i++
$hascommercials = $true
Add-Content -Path $metafile ";FFMETADATA1"
Add-Content -Path $metafile "[CHAPTER]"
Add-Content -Path $metafile "TIMEBASE=1/1000"
Add-Content -Path
Add-Content -Path
Add-Content -Path $metafile "title=Chapter $i"
if ($workdir) {
$chapterfile = Split-Path $chapterfile -Leaf
$chapterfile = "$workdir$chapterfile"
}
$tempfiles += $chapterfile
$concat += "|$chapterfile"
$duration = [double]$end - [double]$start
& $ffmpegPath -hide_banner -loglevel error -nostdin -i $infile -ss $start -t $duration -c copy -y $chapterfile
$totalcutduration += $startnext - $end
}
$start = $startnext
}
if ($hascommercials) {
$endstring = & $ffmpegPath -hide_banner -nostdin -i $infile 2>&1 | Select-String -Pattern "Duration" | ForEach-Object { $_ -replace '\D+(\d+:\d+:\d+.\d+),.*', '$1' }
$end=([TimeSpan]::Parse($endstring)).TotalSeconds
if ([double]$end * 1000 -gt [double]$start * 1000) {
$i++
Add-Content -Path $metafile "[CHAPTER]"
Add-Content -Path $metafile "TIMEBASE=1/1000"
Add-Content -Path
Add-Content -Path
Add-Content -Path $metafile "title=Chapter $i"
if ($workdir) {
$chapterfile = Split-Path $chapterfile -Leaf
$chapterfile = "$workdir$chapterfile"
}
$tempfiles += $chapterfile
$concat += "|$chapterfile"
$duration = [double]$end - [double]$start
& $ffmpegPath -hide_banner -loglevel error -nostdin -i $infile -ss $start -t $duration -c copy -y $chapterfile
}
& $ffmpegPath -hide_banner -loglevel error -nostdin -i
}
foreach ($tempfile in $tempfiles) {
Remove-Item -Path $tempfile
}
if ($deleteedl) {
Remove-Item -Path $edlfile
}
if ($deletemeta) {
Remove-Item -Path $metafile
}
if ($deletelog) {
Remove-Item -Path $logfile
}
if ($deletelogo) {
Remove-Item -Path $logofile
}
if ($deletetxt) {
Remove-Item -Path $txtfile
}
if ($ldPath) {
$env:LD_LIBRARY_PATH = $ldPath
}
if ($lockfile) {
Remove-Item -Path $lockfile
}
Hi,
Just a thought, but any feeling for the timing "error" that should exist when cutting a file? Asking because I trimmed a file, and found that the deltas in the EDL file, vs. the file size change was off by a few seconds. Not a big deal of course, but just a bit surprised that it exists at all really.
Thoughts?
Thanks!
I've been downloading some videos from Tubi and attempted to use comcut on Ubuntu to strip out the commercials. It seems to work fine, except that the last part of video from the last commercial to the end of the file is missing from the new file. I was trying to figure out what the issue is, but not exactly sure at this point. I'll post the log file I captured to this issue later.
Hi,
Not sure what has changed recently with comskip, but I sometimes seem to see a blank line at the end. Shouldn't be a big deal, but comcut breaks due to it => it tries to generate one more part file, with ss = blank, and duration equal to the last time seen in the file.
To test this, just add a blank line at the end of the EDL file.
Thanks!
Comcut was losing audio on all MKV files recorded with Vorbis audio streams. I found that by converting to AAC audio, the problem is solved, and the audio channel isn't dropped.
My use is capturing video with audio from the desktop, which contain commercials. Comcut removes the commercials. The default audio format from a pulseaudio (Ubuntu) capture is Vorbis. Here's the command for that: ffmpeg -loglevel error -video_size "$V" -f x11grab -i :0.0 -f pulse -i default -ac 2 -preset veryfast "$F"
Updated code attached.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.