Recherche avancée

Médias (29)

Mot : - Tags -/Musique

Sur d’autres sites (126)

  • ffmpeg produces duplicate pts with "wallclock_as_timestamps 1" option on MKV

    15 avril, par Jax2171

    I need to get real time reference of every keyframe captured by an IP camera. The -wallclock_as_timestamps 1 option seems to do the trick for us, however we are forced to replace the TS output container with MKV to get a correct PTS epoch value 1712996356.833000.

    


    Here is the ffmpeg command used :

    


    ffmpeg -report -use_wallclock_as_timestamps 1 -rtsp_transport tcp -i rtsp://user:password1@192.168.5.21/cam/realmonitor?channel=1channel1[1]=1subtype=0 -c:v copy -c:a aac -copyts -f matroska -y rec.mkv


    


    The capture process runs without any relevant worning or error messages.

    


    However, playing the captured video with any player shows very short and evident but very annoying lags. Upon investigation I discovered that many frame PTSs have the same value. The command I used to show duplicate PTSs is as follows :

    


    ffprobe -v error -show_entries frame=pkt_pts_time -select_streams v -of csv=p=0 rec.mkv | sort | uniq -d


    


    On a recording of about 10 minutes the result of the duplicate PTS is the following :

    


    1713086493.367000
1713086493.368000
1713086493.370000
1713086493.372000
1713086543.714000
1713086558.793000
1713086558.817000
1713086558.872000
1713086561.780000
1713086564.642000
1713086564.657000
1713086564.778000
1713086565.794000
...


    


    I'm not sure if the lag problem is caused by this, however the problem does not occur with the TS container, which however I cannot use due to the PTS values being roundly 33 bit.

    


    The -vsync 0 or -vsync 2 options on input or output didn't help.

    


    This is the log using the -report option :

    


        ffmpeg started on 2024-04-15 at 09:04:38
Report written to "ffmpeg-20240415-090438.log"
Log level: 48
Command line:
ffmpeg -report -stats -hide_banner -use_wallclock_as_timestamps 1 -rtsp_transport tcp -i "rtsp://user:password1@192.168.5.21/cam/realmonitor?channel=1channel1[1]=1subtype=0" -c:v copy -c:a aac -copyts -f matroska -y rec.mkv
Splitting the commandline.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-stats' ... matched as option 'stats' (print progress report during encoding) with argument '1'.
Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'.
Reading option '-use_wallclock_as_timestamps' ... matched as AVOption 'use_wallclock_as_timestamps' with argument '1'.
Reading option '-rtsp_transport' ... matched as AVOption 'rtsp_transport' with argument 'tcp'.
Reading option '-i' ... matched as input url with argument 'rtsp://user:password1@192.168.5.21/cam/realmonitor?channel=1channel1[1]=1subtype=0'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'aac'.
Reading option '-copyts' ... matched as option 'copyts' (copy timestamps) with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'matroska'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option 'rec.mkv' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Applying option stats (print progress report during encoding) with argument 1.
Applying option hide_banner (do not show program banner) with argument 1.
Applying option copyts (copy timestamps) with argument 1.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url rtsp://user:password1@192.168.5.21/cam/realmonitor?channel=1channel1[1]=1subtype=0.
Successfully parsed a group of options.
Opening an input file: rtsp://user:password1@192.168.5.21/cam/realmonitor?channel=1channel1[1]=1subtype=0.
[tcp @ 0x1646660] No default whitelist set
[tcp @ 0x1646660] Original list of addresses:
[tcp @ 0x1646660] Address 192.168.5.21 port 554
[tcp @ 0x1646660] Interleaved list of addresses:
[tcp @ 0x1646660] Address 192.168.5.21 port 554
[tcp @ 0x1646660] Starting connection attempt to 192.168.5.21 port 554
[tcp @ 0x1646660] Successfully connected to 192.168.5.21 port 554
[rtsp @ 0x1645e70] SDP:
v=0
o=- 2251950012 2251950012 IN IP4 0.0.0.0
s=Media Server
c=IN IP4 0.0.0.0
t=0 0
a=control:*
a=packetization-supported:DH
a=rtppayload-supported:DH
a=range:npt=now-
a=x-packetization-supported:IV
a=x-rtppayload-supported:IV
m=video 0 RTP/AVP 96
a=control:trackID=0
a=framerate:25.000000
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=4D4028;sprop-parameter-sets=Z01AKKaAeAIn5ZuAgICgAAADACAAAAZQgAA=,aO48gAA=
a=recvonly
m=audio 0 RTP/AVP 97
a=control:trackID=1
a=rtpmap:97 MPEG4-GENERIC/16000
a=fmtp:97 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408
a=recvonly

[rtsp @ 0x1645e70] video codec set to: h264
[rtsp @ 0x1645e70] RTP Packetization Mode: 1
[rtsp @ 0x1645e70] RTP Profile IDC: 4d Profile IOP: 40 Level: 28
[rtsp @ 0x1645e70] Extradata set to 0x164af98 (size: 39)
[rtsp @ 0x1645e70] audio codec set to: aac
[rtsp @ 0x1645e70] audio samplerate set to: 16000
[rtsp @ 0x1645e70] audio channels set to: 1
[rtsp @ 0x1645e70] setting jitter buffer size to 0
[rtsp @ 0x1645e70] setting jitter buffer size to 0
[rtsp @ 0x1645e70] hello state=0
Failed to parse interval end specification ''
[h264 @ 0x164ab30] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x164ab30] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x164ab30] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x164ab30] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x164ab30] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x164ab30] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x164ab30] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x164ab30] Format yuvj420p chosen by get_format().
[h264 @ 0x164ab30] Reinit context to 1920x1088, pix_fmt: yuvj420p
[h264 @ 0x164ab30] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x164ab30] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x164ab30] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x164ab30] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x164ab30] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x164ab30] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[rtsp @ 0x1645e70] All info found
Input #0, rtsp, from 'rtsp://user:password1@192.168.5.21/cam/realmonitor?channel=1channel1[1]=1subtype=0':
  Metadata:
    title           : Media Server
  Duration: N/A, start: 1713164678.794625, bitrate: N/A
    Stream #0:0, 22, 1/90000: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1, 15, 1/16000: Audio: aac (LC), 16000 Hz, mono, fltp
Successfully opened the file.
Parsing a group of options: output url rec.mkv.
Applying option c:v (codec name) with argument copy.
Applying option c:a (codec name) with argument aac.
Applying option f (force format) with argument matroska.
Successfully parsed a group of options.
Opening an output file: rec.mkv.
[file @ 0x1699f30] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
detected 4 logical cores
[graph_0_in_0_1 @ 0x1682bb0] Setting 'time_base' to value '1/16000'
[graph_0_in_0_1 @ 0x1682bb0] Setting 'sample_rate' to value '16000'
[graph_0_in_0_1 @ 0x1682bb0] Setting 'sample_fmt' to value 'fltp'
[graph_0_in_0_1 @ 0x1682bb0] Setting 'channel_layout' to value '0x4'
[graph_0_in_0_1 @ 0x1682bb0] tb:1/16000 samplefmt:fltp samplerate:16000 chlayout:0x4
[format_out_0_1 @ 0x187f2e0] Setting 'sample_fmts' to value 'fltp'
[format_out_0_1 @ 0x187f2e0] Setting 'sample_rates' to value '96000|88200|64000|48000|44100|32000|24000|22050|16000|12000|11025|8000|7350'
[AVFilterGraph @ 0x164fd70] query_formats: 4 queried, 9 merged, 0 already done, 0 delayed
[matroska @ 0x169c330] get_metadata_duration returned: 0
Output #0, matroska, to 'rec.mkv':
  Metadata:
    title           : Media Server
    encoder         : Lavf58.45.100
    Stream #0:0, 0, 1/1000: Video: h264 (Main) (H264 / 0x34363248), yuvj420p(pc, bt709, progressive), 1920x1080, q=2-31, 25 fps, 25 tbr, 1k tbn, 90k tbc
    Stream #0:1, 0, 1/1000: Audio: aac (LC) ([255][0][0][0] / 0x00FF), 16000 Hz, mono, fltp, 69 kb/s
    Metadata:
      encoder         : Lavc58.91.100 aac
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:1 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[matroska @ 0x169c330] Starting new cluster with timestamp 1713164678731 at offset 770 bytes
[matroska @ 0x169c330] Writing block of size 581 with pts 1713164678731, dts 1713164678731, duration 64 at relative offset 14 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 517 with pts 1713164678795, dts 1713164678795, duration 64 at relative offset 602 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 376900 with pts 1713164678872, dts 1713164678872, duration 40 at relative offset 1126 in cluster at offset 770. TrackNumber 1, keyframe 1
[matroska @ 0x169c330] Writing block of size 8172 with pts 1713164678912, dts 1713164678912, duration 40 at relative offset 378034 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 672 with pts 1713164678912, dts 1713164678912, duration 64 at relative offset 386213 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 550 with pts 1713164679177, dts 1713164679177, duration 64 at relative offset 386892 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 7654 with pts 1713164679178, dts 1713164679178, duration 40 at relative offset 387449 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 7483 with pts 1713164679213, dts 1713164679213, duration 40 at relative offset 395110 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 7703 with pts 1713164679242, dts 1713164679242, duration 40 at relative offset 402600 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 565 with pts 1713164679242, dts 1713164679242, duration 64 at relative offset 410310 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 7650 with pts 1713164679271, dts 1713164679271, duration 40 at relative offset 410882 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 585 with pts 1713164679271, dts 1713164679271, duration 64 at relative offset 418539 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 8682 with pts 1713164679301, dts 1713164679301, duration 40 at relative offset 419131 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 8888 with pts 1713164679330, dts 1713164679330, duration 40 at relative offset 427820 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 506 with pts 1713164679330, dts 1713164679330, duration 64 at relative offset 436715 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 8019 with pts 1713164679360, dts 1713164679360, duration 40 at relative offset 437228 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 7919 with pts 1713164679361, dts 1713164679361, duration 40 at relative offset 445254 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 7822 with pts 1713164679361, dts 1713164679361, duration 40 at relative offset 453180 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 699 with pts 1713164679361, dts 1713164679361, duration 64 at relative offset 461009 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 619 with pts 1713164679361, dts 1713164679361, duration 64 at relative offset 461715 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 7768 with pts 1713164679362, dts 1713164679362, duration 40 at relative offset 462341 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 8469 with pts 1713164679362, dts 1713164679362, duration 40 at relative offset 470116 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 601 with pts 1713164679362, dts 1713164679362, duration 64 at relative offset 478592 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 559 with pts 1713164679363, dts 1713164679363, duration 64 at relative offset 479200 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 8265 with pts 1713164679366, dts 1713164679366, duration 40 at relative offset 479766 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 7766 with pts 1713164679406, dts 1713164679406, duration 40 at relative offset 488038 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 531 with pts 1713164679415, dts 1713164679415, duration 64 at relative offset 495811 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 7753 with pts 1713164679446, dts 1713164679446, duration 40 at relative offset 496349 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 8274 with pts 1713164679486, dts 1713164679486, duration 40 at relative offset 504109 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 569 with pts 1713164679496, dts 1713164679496, duration 64 at relative offset 512390 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 8445 with pts 1713164679526, dts 1713164679526, duration 40 at relative offset 512966 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 522 with pts 1713164679535, dts 1713164679535, duration 64 at relative offset 521418 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 7922 with pts 1713164679566, dts 1713164679566, duration 40 at relative offset 521947 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 7954 with pts 1713164679606, dts 1713164679606, duration 40 at relative offset 529876 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 503 with pts 1713164679615, dts 1713164679615, duration 64 at relative offset 537837 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 11167 with pts 1713164679646, dts 1713164679646, duration 40 at relative offset 538347 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 503 with pts 1713164679655, dts 1713164679655, duration 64 at relative offset 549521 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 10534 with pts 1713164679686, dts 1713164679686, duration 40 at relative offset 550031 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 7607 with pts 1713164679726, dts 1713164679726, duration 40 at relative offset 560572 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 478 with pts 1713164679772, dts 1713164679772, duration 64 at relative offset 568186 in cluster at offset 770. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 7842 with pts 1713164679774, dts 1713164679774, duration 40 at relative offset 568671 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 9862 with pts 1713164679806, dts 1713164679806, duration 40 at relative offset 576520 in cluster at offset 770. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Starting new cluster with timestamp 1713164679815 at offset 587166 bytes
[matroska @ 0x169c330] Writing block of size 449 with pts 1713164679815, dts 1713164679815, duration 64 at relative offset 14 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 379456 with pts 1713164679870, dts 1713164679870, duration 40 at relative offset 470 in cluster at offset 587166. TrackNumber 1, keyframe 1
[matroska @ 0x169c330] Writing block of size 415 with pts 1713164679903, dts 1713164679903, duration 64 at relative offset 379934 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 7008 with pts 1713164679905, dts 1713164679905, duration 40 at relative offset 380356 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 6917 with pts 1713164679925, dts 1713164679925, duration 40 at relative offset 387371 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 513 with pts 1713164679935, dts 1713164679935, duration 64 at relative offset 394295 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 7111 with pts 1713164679966, dts 1713164679966, duration 40 at relative offset 394815 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 753 with pts 1713164679975, dts 1713164679975, duration 64 at relative offset 401933 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 7091 with pts 1713164680006, dts 1713164680006, duration 40 at relative offset 402693 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 7045 with pts 1713164680045, dts 1713164680045, duration 40 at relative offset 409791 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 659 with pts 1713164680055, dts 1713164680055, duration 64 at relative offset 416843 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 6983 with pts 1713164680086, dts 1713164680086, duration 40 at relative offset 417509 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 6932 with pts 1713164680127, dts 1713164680127, duration 40 at relative offset 424499 in cluster at offset 587166. TrackNumber 1, keyframe 0
frame=   35 fps=0.0 q=-1.0 size=     512kB time=475879:04:40.20 bitrate=   0.0kbits/s speed=3.35e+09x    
[matroska @ 0x169c330] Writing block of size 691 with pts 1713164680135, dts 1713164680135, duration 64 at relative offset 431438 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 6990 with pts 1713164680166, dts 1713164680166, duration 40 at relative offset 432136 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 651 with pts 1713164680176, dts 1713164680176, duration 64 at relative offset 439133 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 7046 with pts 1713164680206, dts 1713164680206, duration 40 at relative offset 439791 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 7130 with pts 1713164680246, dts 1713164680246, duration 40 at relative offset 446844 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 601 with pts 1713164680255, dts 1713164680255, duration 64 at relative offset 453981 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 7205 with pts 1713164680286, dts 1713164680286, duration 40 at relative offset 454589 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 561 with pts 1713164680295, dts 1713164680295, duration 64 at relative offset 461801 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 6936 with pts 1713164680326, dts 1713164680326, duration 40 at relative offset 462369 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 6822 with pts 1713164680366, dts 1713164680366, duration 40 at relative offset 469312 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 621 with pts 1713164680375, dts 1713164680375, duration 64 at relative offset 476141 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 6845 with pts 1713164680405, dts 1713164680405, duration 40 at relative offset 476769 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 6848 with pts 1713164680445, dts 1713164680445, duration 40 at relative offset 483621 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 588 with pts 1713164680455, dts 1713164680455, duration 64 at relative offset 490476 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 6828 with pts 1713164680486, dts 1713164680486, duration 40 at relative offset 491071 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 546 with pts 1713164680495, dts 1713164680495, duration 64 at relative offset 497906 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 6845 with pts 1713164680526, dts 1713164680526, duration 40 at relative offset 498459 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 6924 with pts 1713164680566, dts 1713164680566, duration 40 at relative offset 505311 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 508 with pts 1713164680576, dts 1713164680576, duration 64 at relative offset 512242 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 6844 with pts 1713164680606, dts 1713164680606, duration 40 at relative offset 512757 in cluster at offset 587166. TrackNumber 1, keyframe 0
frame=   48 fps= 47 q=-1.0 size=     512kB time=475879:04:40.72 bitrate=   0.0kbits/s speed=1.66e+09x    
[matroska @ 0x169c330] Writing block of size 587 with pts 1713164680615, dts 1713164680615, duration 64 at relative offset 519608 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 6859 with pts 1713164680645, dts 1713164680645, duration 40 at relative offset 520202 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 6855 with pts 1713164680686, dts 1713164680686, duration 40 at relative offset 527068 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 573 with pts 1713164680695, dts 1713164680695, duration 64 at relative offset 533930 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 6881 with pts 1713164680726, dts 1713164680726, duration 40 at relative offset 534510 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 10773 with pts 1713164680766, dts 1713164680766, duration 40 at relative offset 541398 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 520 with pts 1713164680775, dts 1713164680775, duration 64 at relative offset 552178 in cluster at offset 587166. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 6923 with pts 1713164680805, dts 1713164680805, duration 40 at relative offset 552705 in cluster at offset 587166. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Starting new cluster with timestamp 1713164680815 at offset 1146808 bytes
[matroska @ 0x169c330] Writing block of size 580 with pts 1713164680815, dts 1713164680815, duration 64 at relative offset 14 in cluster at offset 1146808. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 380085 with pts 1713164680864, dts 1713164680864, duration 40 at relative offset 601 in cluster at offset 1146808. TrackNumber 1, keyframe 1
[matroska @ 0x169c330] Writing block of size 9916 with pts 1713164680896, dts 1713164680896, duration 40 at relative offset 380694 in cluster at offset 1146808. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 541 with pts 1713164680901, dts 1713164680901, duration 64 at relative offset 390617 in cluster at offset 1146808. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 5877 with pts 1713164680925, dts 1713164680925, duration 40 at relative offset 391165 in cluster at offset 1146808. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] Writing block of size 529 with pts 1713164680935, dts 1713164680935, duration 64 at relative offset 397049 in cluster at offset 1146808. TrackNumber 2, keyframe 1
[matroska @ 0x169c330] Writing block of size 6661 with pts 1713164680966, dts 1713164680966, duration 40 at relative offset 397585 in cluster at offset 1146808. TrackNumber 1, keyframe 0
[matroska @ 0x169c330] end duration = 1713164681006
[matroska @ 0x169c330] stream 0 end duration = 1713164681006
[matroska @ 0x169c330] stream 1 end duration = 1713164680999
frame=   54 fps= 42 q=-1.0 Lsize=    1515kB time=475879:04:40.99 bitrate=   0.0kbits/s speed=1.33e+09x    
video:1493kB audio:20kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.099897%
Input file #0 (rtsp://user:password1@192.168.5.21/cam/realmonitor?channel=1channel1[1]=1subtype=0):
  Input stream #0:0 (video): 54 packets read (1529156 bytes); 
  Input stream #0:1 (audio): 35 packets read (9268 bytes); 35 frames decoded (35840 samples); 
  Total: 89 packets (1538424 bytes) demuxed
Output file #0 (rec.mkv):
  Output stream #0:0 (video): 54 packets muxed (1529156 bytes); 
  Output stream #0:1 (audio): 35 frames encoded (35840 samples); 36 packets muxed (20446 bytes); 
  Total: 90 packets (1549602 bytes) muxed
35 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x1667620] Statistics: 2 seeks, 7 writeouts
[aac @ 0x1673880] Qavg: 142.738
Exiting normally, received signal 15.


    


    In this short 3 second capture the duplicate timestamps are 1713164679.361000 and 1713164679.362000.

    


    How can I solve this problem ? What different approach could I use to achieve this goal ?

    


    Thanks in advance.

    


  • ffmpeg mp4 to mp3 conversion generates 1 second audio files only [closed]

    24 janvier, par doesnotcompile

    I am having the following problem : I am having trouble converting an mp4 to an mp3.

    


    I have mp4 audio recordings that I need to convert in to mp3 audio files. The mp4 files have been recorded on iOS.

    


    I am currently doing this by using ffmpeg in python like so :

    


    subprocess.run(
            [
                "ffmpeg",
                "-loglevel", "error",
                "-i", ,
                "-q:a", "0",
                "-map", "a",
                
            ]
        )


    


    This runs with no error outputs.

    


    However, the resulting mp3 is only 1 second long, even though the input mp4 is around 5 seconds long.

    


    The mp4 is playable in Quicktime and Apple Music.

    


    ffprobe output :

    


    > ffprobe -v error -show_format input.mp4
[FORMAT]
filename=input.mp4
nb_streams=1
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=0.000000
duration=5.120000
size=119636
bit_rate=186931
probe_score=100
TAG:major_brand=iso5
TAG:minor_version=1
TAG:compatible_brands=isomiso5hlsf
TAG:creation_time=2024-01-24T12:47:24.000000Z
[/FORMAT]


    


    No errors shown, and clearly 5 seconds long audio.

    


    Has anyone else experienced similar issues before ?

    


    Happy about any pointers !

    


  • avformat/rtsp : Send mode=record instead of mode=receive in Transport header

    15 janvier, par Paul Orlyk
    avformat/rtsp : Send mode=record instead of mode=receive in Transport header
    

    Fixes server compatibility issues with rtspclientsink GStreamer plugin.

    >From specification :
    RFC 7826 "Real-Time Streaming Protocol Version 2.0" (https://datatracker.ietf.org/doc/html/rfc7826), section 18.54 :
    mode : The mode parameter indicates the methods to be supported for
    this session. The currently defined valid value is "PLAY". If
    not provided, the default is "PLAY". The "RECORD" value was
    defined in RFC 2326 ; in this specification, it is unspecified
    but reserved. RECORD and other values may be specified in the
    future.
    RFC 2326 "Real Time Streaming Protocol (RTSP)" (https://datatracker.ietf.org/doc/html/rfc2326), section 12.39 :
    mode :
    The mode parameter indicates the methods to be supported for
    this session. Valid values are PLAY and RECORD. If not
    provided, the default is PLAY.

    mode=receive was always like this, from the initial commit 'a8ad6ffa rtsp : Add listen mode'.

    For comparison, Wowza was used to push RTSP stream to. Both GStreamer and FFmpeg had no issues.
    Here is the capture of Wowza responding to SETUP request :
    200 OK
    CSeq : 3
    Server : Wowza Streaming Engine 4.8.26+4 build20231212155517
    Cache-Control : no-cache
    Expires : Mon, 15 Jan 2024 19:40:31 GMT
    Transport : RTP/AVP/UDP ;unicast ;client_port=11640-11641 ;mode=record ;source=172.17.0.2 ;server_port=6976-6977
    Date : Mon, 15 Jan 2024 19:40:31 GMT
    Session : 1401457689 ;timeout=60

    Test setup :
    Server : ffmpeg -loglevel trace -y -rtsp_flags listen -i rtsp ://0.0.0.0:30800/live.stream t.mp4
    FFmpeg client : ffmpeg -re -i "Big Buck Bunny - FULL HD 30FPS.mp4" -c:v libx264 -f rtsp rtsp ://127.0.0.1:30800/live.stream
    GStreamer client : gst-launch-1.0 videotestsrc is-live=true pattern=smpte ! queue ! videorate ! videoscale ! video/x-raw,width=640,height=360,framerate=60/1 ! timeoverlay font-desc="Sans, 84" halignment=center valignment=center ! queue ! videoconvert ! tee name=t t. ! x264enc bitrate=9000 pass=cbr speed-preset=ultrafast byte-stream=false key-int-max=15 threads=1 ! video/x-h264,profile=baseline ! queue ! rsink. audiotestsrc ! voaacenc ! queue ! rsink. t. ! queue ! autovideosink rtspclientsink name=rsink location=rtsp ://localhost:30800/live.stream

    Test results :
    modified FFmpeg client -> stock server : ok
    stock FFmpeg client -> modified server : ok
    modified FFmpeg client -> modified server : ok
    GStreamer client -> modified server : ok

    Signed-off-by : Paul Orlyk <paul.orlyk@gmail.com>
    Signed-off-by : Michael Niedermayer <michael@niedermayer.cc>

    • [DH] libavformat/rtspdec.c