<div dir="ltr">Hello<div><br></div><div style>I have been experimenting with encoding a single file and removing parts of the stream. I need this function when encoding material with breaks for commercials to remove bars and other funky stuff and sync with the subtitles.</div>
<div style><br></div><div style>I have done some tests with piping (windows), and I can get this to work pretty well for two arbitrary segments as an example:</div><div style><br></div><div style><div>(ffmpeg -i inputfile.mp4 -ss 00:10:00 -t 60 -bsf h264_mp4toannexb -vcodec copy -acodec copy -f mpegts -</div>
<div>ffmpeg -i inputfile.mp4 -ss 00:20:00 -t 60 -bsf h264_mp4toannexb -vcodec copy -acodec copy -f mpegts - )| ffmpeg -y -f mpegts -i - -c:v libx264 -preset veryfast -x264opts keyint=75:min-keyint=75:no-scenecut -b:v 704k -minrate 704k -maxrate 704k -bufsize 1500k -profile:v baseline -aspect 16:9 -c:a libvo_aacenc -b:a 96k -ac 2 test.mp4</div>
<div><br></div><div style>(this will create a two minute file from two different sections of the input file)</div><div><br></div><div style>The problem is the codec copying in the first parts. Since the timecodes might begin in the middle of a GOP, the final ffmpeg will not know what to do until the first I-frame shows up, so it just shows a freeze frame until that happens.</div>
<div style><br></div><div style>There is a requirement of a fixed gop size of 3 secs for the final output file, so I need to do the encoding again for the final step, no cat can be used on segments.</div><div style><br></div>
<div style>Is there a good intermediate codec to decode to in the first step? (Preferrably uncompressed to gain performance) I have found yuv4mpegvideo but that only does video. I need the audio as well. Anyone got any smart ideas?</div>
<div style><br></div><div style>/Carl<br></div></div></div>