I often record tv shows on my computer. Due to their size, I cut the commercials and convert them to a lower bitrate to save space. Here is the method I have been using:

1. Convert from .wtv to .ts using a java program (just "recontainering"). 1080i 29.97fps MPEG2 Video + ac3 audio

2. Use DGIndexNV to find the pieces I want to KEEP, and output a project file (.dgi) for each one, named 1.dgi, 2.dgi, etc. This is instead of using DGIndexNV's builit-in "output trimmed ts" function

3. Use a piece of software that I wrote to cut the original full recording into the pieces listed above, using the .dgi file's RANGE listing, and adding a little bit of extra audio to the end because due to audio delays in the recording, DGIndexNV cuts it short when outputing a trimmed TS.

4. Now I have several pieces of video labeled 1.ts, 2.ts, etc

5. I run the following cmd line on each piece:
Code:
"ffmpeg.exe" -v verbose -y -i "FOLDER\1.ts" -c:v mpeg2video -q:vscale 0 -flags +ilme+ildct -top 1 -mbd 2 -c:a ac3 -ab 384k -ac 6 -async 1 "FOLDER\1_FIX.ts" > "FOLDER\1_FIXLOG.txt" 2>&1
Why do I do this? Because sometimes there are errors in the stream as it comes from the cable box, and with this ffmpeg automatically adds/drops frames of both video and audio to make sure the video matches the timestamps.

6. Next I use my own software to determine how much video and audio needs to be cut or added to make sure that the video and audio streams are exactly the same length. If I didn't do this, and the video was 600ms shorter than the audio (for example), when I appended all the pieces together in the end, the audio would stop lining up with the video after the first piece and get increasingly worse with each piece added.

7. Trim or add to the ac3 audio using command-line delaycut to match video length

8. My software outputs an avisynth script for each piece that removes a few frames from the beginning, and adds enough blank frames at the end to match the audio length. It also uses the high-quality deinterlacer QTGMC so I get 1080p video, resizes and crops if necessary.

9. Now I have the "fixed" pieces of video, and the avisynth scripts for each.

10. Now I run avs4x264mod.exe with the avisynth scripts as inputs and it outputs the final .264 files.

11. Append the pieces to each other using MKVMerge to output the final single MKV file (1080p, 29.97 fps AVC + AC3)



Anyway, that's the current process, which doesn't take as long as you might think especially since my software does all the calculations and outputs all the necessary command-line batch files. I just have to run them.

However, I'd like to streamline this a bit more. After I've determined the cuts and additions to the video and audio that I need and I've applied that to the audio, I'd like to use a single ffmpeg command-line statement that does cuts and adds to the video, uses QTGMC to deinterlace, and runs it all through x264 to output the final video. I'd like to do this so I eliminate step 5 completely, which I imagine causes some quality loss, especially since my cable provider recently changed some channels' streams to AVC + AC3 instead of the old MPEG2 + AC3. Is there a good way to do this?