[FFmpeg-user] Cut stream to file, transcode, merge trancoded file without gaps

frafart at free.fr frafart at free.fr
Wed Dec 11 14:44:10 CET 2013


Hi,

I attempt to achieve this with an UDP Mpeg/Ts input stream :

1- Generate 5 minutes length .ts files from this stream, for shirt time storage purpose.
I've tested multicat, ffmpeg segment and some homemade tools, none of them make TS files starting with a KeyFrame (IFrame). This is normal.

Joining two produced .ts files to a new one with the ffmpeg concat muxer or a cat command works great, no gap, no scratch, no artefact.

2- Generate 5 minutes length .mp4 (h264/aacplus) files from this generated 5min .ts.

I use this ffmpeg command :

ffmpeg -i <INPUT_5MIN_TS> -y -movflags +faststart -c:v libx264 -vf yadif=0:1:0,scale=-1:288 -vprofile baseline -preset fast -crf 18 -maxrate 450k -bufsize 450k -pix_fmt yuv420p -c:a libaacplus -ab 64k -ac 2 <OUTPUT_5MIN_MP4>

(I try with and without -copyinkf)

All generated files (.ts, .mp4) must join smoothly (without any gaps or cracks) with subsequent one to produce a new file (eg: 05to10.mp4 | 10to15.mp4 | 15to20.mp4 => 05to20.mp4 ).

I've tried the technic described in this post https://trac.ffmpeg.org/wiki/How%20to%20concatenate%20(join,%20merge)%20media%20files to join .mp4 files

ffmpeg -i 05to10.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i 10to15.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc 05to15.mp4

Sadly, the output "05to15.mp4" contains video artefacts around the cutting point (~4 min 59 sec).

Is there another method to cut the ts stream or tricks to prevent this artifacts ?

Anybody can help me to solve this problem ?

I use this version : 

ffmpeg version 1.0.8 Copyright (c) 2000-2013 the FFmpeg developers
  built on Sep 12 2013 11:57:09 with gcc 4.7 (Debian 4.7.2-5)
  configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --enable-libvo-aacenc --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libaacplus --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libfdk-aac --enable-libdc1394 --disable-altivec --dis  libavutil      51. 73.101 / 51. 73.101
  libavcodec     54. 59.100 / 54. 59.100
  libavformat    54. 29.104 / 54. 29.104
  libavdevice    54.  2.101 / 54.  2.101
  libavfilter     3. 17.100 /  3. 17.100
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 15.100 /  0. 15.100
  libpostproc    52.  0.100 / 52.  0.100


Thanks


More information about the ffmpeg-user mailing list