How to correctly apply select filter after trim in ffpeg?

I am using the following ffmpeg command to trim and select certain portions of the video.

ffmpeg -v verbose -i test.mp4 -filter_complex 
"[0:v]trim=start=5:end=40,setpts=PTS-STARTPTS[v_trimmed]; 
 [v_trimmed]select='between(t,10,20)',setpts=N/FRAME_RATE/TB[v]; 
 [0:a]atrim=start=5:end=40,asetpts=PTS-STARTPTS[a_trimmed]; 
 [a_trimmed]aselect='between(t,10,20)',asetpts=N/SR/TB[a]" 
-map "[v]" -map "[a]" -y -r 30 output_video.mp4

The above command errors out with the following trace

[h264 @ 0x12570a0e0] Reinit context to 1280x720, pix_fmt: yuv420p
[graph 0 input from stream 0:0 @ 0x600001ff8000] w:1280 h:720 pixfmt:yuv420p tb:1/30000 fr:30000/1001 sar:1/1 csp:bt709 range:tv
[graph_0_in_0:1 @ 0x600001ff80b0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:stereo
[Parsed_trim_0 @ 0x600001ffc420] TB:0.000033 FRAME_RATE:29.970030 SAMPLE_RATE:nan
[Parsed_select_2 @ 0x600001ffc580] TB:0.000033 FRAME_RATE:nan SAMPLE_RATE:nan
[Parsed_atrim_4 @ 0x600001ffc630] TB:0.000023 FRAME_RATE:nan SAMPLE_RATE:44100.000000
[Parsed_aselect_6 @ 0x600001ffc790] TB:0.000023 FRAME_RATE:nan SAMPLE_RATE:44100.000000
[graph 0 input from stream 0:0 @ 0x600001ff8000] video frame properties congruent with link at pts_time: 0
[vost#0:0/libx264 @ 0x125707800] *** dropping frame 0 at ts -9223372036854775808
    Last message repeated 298 times
[fc#0 @ 0x600001ae81b0] Input 1 no longer accepts new data
[aist#0:1/aac @ 0x1257100b0] [dec:aac @ 0x12570ea40] Decoder returned EOF, finishing
[aist#0:1/aac @ 0x1257100b0] [dec:aac @ 0x12570ea40] Terminating thread with return code 0 (success)
[aist#0:1/aac @ 0x1257100b0] All consumers of this stream are done
[fc#0 @ 0x600001ae81b0] Filtergraph returned EOF, finishing
[fc#0 @ 0x600001ae81b0] All consumers returned EOF
[vost#0:0/libx264 @ 0x125707800] *** dropping frame 0 at ts -9223372036854775808
[vost#0:0/libx264 @ 0x125707800] Encoder thread received EOF
[vost#0:0/libx264 @ 0x125707800] Could not open encoder before EOF
[vost#0:0/libx264 @ 0x125707800] Task finished with error code: -22 (Invalid argument)
[vost#0:0/libx264 @ 0x125707800] Terminating thread with return code -22 (Invalid argument)
[aost#0:1/aac @ 0x1257084b0] Encoder thread received EOF
[fc#0 @ 0x600001ae81b0] Terminating thread with return code 0 (success)
[vist#0:0/h264 @ 0x12570ecf0] [dec:h264 @ 0x1257094e0] Decoder returned EOF, finishing
[vist#0:0/h264 @ 0x12570ecf0] [dec:h264 @ 0x1257094e0] Terminating thread with return code 0 (success)
[vist#0:0/h264 @ 0x12570ecf0] All consumers of this stream are done
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100] All consumers are done
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100] Terminating thread with return code 0 (success)
[aost#0:1/aac @ 0x1257084b0] Terminating thread with return code 0 (success)
[out#0/mp4 @ 0x600001de8000] Nothing was written into output file, because at least one of its streams received no packets.
frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A dup=0 drop=301 speed=N/A    
[aac @ 0x1257087b0] Qavg: 645.507
[AVIOContext @ 0x125708d60] Statistics: 0 bytes written, 0 seeks, 0 writeouts
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100] Input file #0 (test.mp4):
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100]   Input stream #0:0 (video): 1219 packets read (1479521 bytes); 1201 frames decoded; 0 decode errors; 
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100]   Input stream #0:1 (audio): 1741 packets read (646974 bytes); 1732 frames decoded; 0 decode errors (1773568 samples); 
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0x6000014ec100]   Total: 2960 packets (2126495 bytes) demuxed
[AVIOContext @ 0x125705640] Statistics: 2699615 bytes read, 0 seeks
Conversion failed!

If I remove the setpts step after the trim, the above command will work as expected. What is the problem with using trim and setpts, and then, passing the output to the select filter?
Note: Using trim is important as per my current flow.

New contributor

lakhan dhingra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật