[FFmpeg-user] the trim filter

Mark Filipak markfilipak.imdb at gmail.com
Fri Jul 5 01:50:16 EEST 2024


On 04/07/2024 17.12, Paul B Mahol wrote:
> Its in documentation: asetpts=N/SR/TB, assuming everything starts from 0,
> so add it after each atrim.

For both video & audio,
   time_base=1/90000
   start_pts=1048560

So, there are 'silent' audio samples starting with the first video frame. I'm dropping 20.062 
seconds of video (i.e., 481 frames). I really don't know how I could rewrite audio PTSes to make 
that 20.062 seconds of audio to go away. I really think that's impossible. They have to be dropped, 
just as I am dropping the 481 video frames.

Here's my trim commands for the first segment:

trim=start_frame=481:end_frame=134047,atrim=start_sample=962962:end_sample=268360093

Here's the interesting terminal output (slightly beautified):

[Parsed_trim_1 @ 0000000000620040]
  Media type mismatch between the 'Parsed_trim_1' filter output pad 0 (video) and the 
'Parsed_atrim_2' filter input pad 0 (audio)

[AVFilterGraph @ 000000000061c7c0] Error linking filters

Failed to set value
  'split=2[i5][i6],
  [i5]trim=start_frame=481:end_frame=134047, atrim=start_sample=962962:end_sample=268360092[o5],
  [i6]trim=start_frame=138745:end_frame=246719[o6],
  [o5][o6]concat=n=2'
for option 'filter_complex': Invalid argument
Error parsing global options: Invalid argument


Following is the entire terminal output:
ffmpeg -i g:\00305+00306+00307+00308.m2ts -bsf:a noise=drop='lt(pts\,1805580)' -filter_complex 
"split=2[i5][i6],[i5]trim=start_frame=481:end_frame=134047,atrim=start_sample=962962:end_sample=268360092[o5],[i6]trim=start_frame=138745:end_frame=246719[o6],[o5][o6]concat=n=2," 
  -c:v libx265 -x265-params crf=16 -c:a dts -strict -2 -sn
  -start_at_zero e:\00305+00306+00307+00308.mp4
ffmpeg version 2024-05-20-git-127ded5078-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg 
developers
   built with gcc 13.2.0 (Rev5, Built by MSYS2 project)
   configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads 
--disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 
--enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist 
--enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray 
--enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d 
--enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e 
--enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 
--enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg 
--enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype 
--enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf 
--enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va 
--enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi 
--enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio 
--enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb 
--enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc 
--enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus 
--enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite 
--enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
   libavutil      59. 19.100 / 59. 19.100
   libavcodec     61.  5.104 / 61.  5.104
   libavformat    61.  3.103 / 61.  3.103
   libavdevice    61.  2.100 / 61.  2.100
   libavfilter    10.  2.102 / 10.  2.102
   libswscale      8.  2.100 /  8.  2.100
   libswresample   5.  2.100 /  5.  2.100
   libpostproc    58.  2.100 / 58.  2.100
[Parsed_trim_1 @ 0000000000620040] Media type mismatch between the 'Parsed_trim_1' filter output pad 
0 (video) and the 'Parsed_atrim_2' filter input pad 0 (audio)
[AVFilterGraph @ 000000000061c7c0] Error linking filters
Failed to set value 
'split=2[i5][i6],[i5]trim=start_frame=481:end_frame=134047,atrim=start_sample=962962:end_sample=268360092[o5],[i6]trim=start_frame=138745:end_frame=
246719[o6],[o5][o6]concat=n=2,' for option 'filter_complex': Invalid argument
Error parsing global options: Invalid argument
-------------- next part --------------
Tip: Use "Save As" to save this list.

ffprobe version 2024-05-20-git-127ded5078-full_build-www.gyan.dev Copyright (c) 2007-2024 the FFmpeg developers
  built with gcc 13.2.0 (Rev5, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      59. 19.100 / 59. 19.100
  libavcodec     61.  5.104 / 61.  5.104
  libavformat    61.  3.103 / 61.  3.103
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
[mpegts @ 00000000005831c0] DTS discontinuity in stream 2: packet 12 with DTS 12859568, packet 13 with DTS 12970433
[mpegts @ 00000000005831c0] DTS discontinuity in stream 2: packet 20 with DTS 13302507, packet 21 with DTS 13417133
[mpegts @ 00000000005831c0] DTS discontinuity in stream 2: packet 28 with DTS 14965402, packet 29 with DTS 15080059
[mpegts @ 00000000005831c0] DTS discontinuity in stream 2: packet 36 with DTS 15502195, packet 37 with DTS 15613087
[mpegts @ 00000000005831c0] DTS discontinuity in stream 2: packet 44 with DTS 19788998, packet 45 with DTS 19903601
[mpegts @ 00000000005831c0] DTS discontinuity in stream 2: packet 52 with DTS 21207988, packet 53 with DTS 21543919
Input #0, mpegts, from 'E:\00305.m2ts':
  Duration: 01:36:12.73, start: 11.650667, bitrate: 20913 kb/s
  Program 1
  Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbn
  Stream #0:1[0x1100]: Audio: dts (dca) (DTS-HD MA) ([134][0][0][0] / 0x0086), 48000 Hz, mono, s32p (24 bit)
  Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle (pgssub) ([144][0][0][0] / 0x0090), 1920x1080
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_tag_string=HDMV
codec_tag=0x564d4448
width=1920
height=1080
coded_width=1920
coded_height=1080
closed_captions=0
film_grain=0
has_b_frames=4
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=41
color_range=unknown
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=progressive
refs=1
is_avc=false
nal_length_size=0
ts_id=0
ts_packetsize=192
id=0x1011
r_frame_rate=24000/1001
avg_frame_rate=24000/1001
time_base=1/90000
start_pts=1048560
start_time=11.650667
duration_ts=519545275
duration=5772.725278
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
extradata_size=199
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:non_diegetic=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
[/STREAM]
[STREAM]
index=1
codec_name=dts
codec_long_name=DCA (DTS Coherent Acoustics)
profile=DTS-HD MA
codec_type=audio
codec_tag_string=[134][0][0][0]
codec_tag=0x0086
sample_fmt=s32p
sample_rate=48000
channels=1
channel_layout=mono
bits_per_sample=0
initial_padding=0
ts_id=0
ts_packetsize=192
id=0x1100
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/90000
start_pts=1048560
start_time=11.650667
duration_ts=519544320
duration=5772.714667
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=24
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:non_diegetic=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
[/STREAM]
[STREAM]
index=2
codec_name=hdmv_pgs_subtitle
codec_long_name=HDMV Presentation Graphic Stream subtitles
profile=unknown
codec_type=subtitle
codec_tag_string=[144][0][0][0]
codec_tag=0x0090
width=1920
height=1080
ts_id=0
ts_packetsize=192
id=0x1200
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/90000
start_pts=7685190
start_time=85.391000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:non_diegetic=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
[/STREAM]


More information about the ffmpeg-user mailing list