0

I'm trying to copy an hevc video from an RTSP feed into an mkv container.

This works: rtsp(hevc) -> out.hevc then out.hevc -> out.mkv

This doesn't work rtsp(hevc) -> out.mkv

Working below:

ffmpeg  -nostats  -hide_banner -loglevel info -rtsp_transport tcp -i rtsp://xx -an -vcodec copy -bsf:v hevc_metadata=tick_rate=1 /tmp/out.hevc -y
[hevc @ 0x564864b07680] VPS 0 does not exist
    Last message repeated 1 times
Input #0, rtsp, from 'rtsp://xx':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 0.040000, bitrate: N/A
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 1280x720, 2 fps, 1 tbr, 90k tbn, 2 tbc
Output #0, hevc, to '/tmp/out.hevc':
  Metadata:
    title           : Media Presentation
    encoder         : Lavf58.20.100
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 1280x720, q=2-31, 2 fps, 1 tbr, 2 tbn, 2 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=  110 fps=1.2 q=-1.0 Lsize=   10165kB time=00:01:48.50 bitrate= 767.5kbits/s speed=1.15x    
video:10165kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%

and checking the file:

ffprobe -hide_banner /tmp/out.hevc
Input #0, hevc, from '/tmp/out.hevc':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 1280x720, 1 fps, 1 tbr, 1200k tbn, 1 tbc

perfect! Putting it into an matroska container:

ffmpeg  -nostats  -hide_banner -loglevel error -i /tmp/out.hevc -an -vcodec copy -bsf:v hevc_metadata=tick_rate=1 /tmp/out.mkv -y

checking:

ffprobe -hide_banner /tmp/out.mkv 
Input #0, matroska,webm, from '/tmp/out.mkv':
  Metadata:
    ENCODER         : Lavf58.20.100
  Duration: 00:01:50.00, start: 0.000000, bitrate: 757 kb/s
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 1280x720, 1 fps, 1 tbr, 1k tbn, 1 tbc (default)
    Metadata:
      DURATION        : 00:01:50.000000000

however when I attempt to directly go from RTSP(hevc) -> Matroska(hevc):

ffmpeg  -nostats  -hide_banner -loglevel info -rtsp_transport tcp -i rtsp://xx -an -vcodec copy -bsf:v hevc_metadata=tick_rate=1 -f matroska /tmp/out.mkv -y 
[hevc @ 0x55fda6886840] VPS 0 does not exist
    Last message repeated 1 times
Input #0, rtsp, from 'rtsp://xx':
  Metadata:
    title           : Media Presentation
  Duration: N/A, start: 0.040000, bitrate: N/A
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 1280x720, 2 fps, 1 tbr, 90k tbn, 2 tbc
Output #0, matroska, to '/tmp/out.mkv':
  Metadata:
    title           : Media Presentation
    encoder         : Lavf58.20.100
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 1280x720, q=2-31, 2 fps, 1 tbr, 1k tbn, 90k tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[matroska @ 0x55fda6888900] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
frame=   51 fps=1.3 q=-1.0 Lsize=    4637kB time=00:00:49.00 bitrate= 775.2kbits/s speed=1.28x    
video:4636kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.034634%

and invalid file is created:

ffprobe -hide_banner /tmp/out.mkv
[AVBSFContext @ 0x55b897eb1980] No start code is found.
/tmp/out.mkv: Invalid data found when processing input

The Timestamps are unset in a packet for stream 0 warning is concerning,.

But I guess this is possible, but I've been unable to find the right incantation of bytestream magic to make this work. Ultimately I'm trying to produce a segmented seekable matroska files (-f segment -segment_format mkv -segment_time 3600 -strftime 1 camera01-%Y%m%d-%H%M%S.mkv) but seem to be stuck deeper in ffmpeg.

I've tried -live 1 and also the hevc_mp4toannexb to no effect.

Any ideas?

  • You may have to roundtrip via MP4. – Gyan Apr 29 at 18:15
  • I have tried that too: ffmpeg -nostats -hide_banner -loglevel info -rtsp_transport tcp -i rtsp://xxx -an -vcodec copy -bsf:v hevc_metadata=tick_rate=1 /tmp/out.mp4 -y yields ffprobe -hide_banner /tmp/out.mp4 [AVBSFContext @ 0x563dc3eec4c0] No start code is found. /tmp/out.mp4: Invalid data found when processing input – Imaginator Apr 29 at 18:30
  • incase it's useful here is out.hevc – Imaginator Apr 29 at 18:35
  • The dumped stream won't help. Is the rtsp still open? – Gyan Apr 29 at 18:55
  • opened again: rtsp://test:stackexchange123@f17gw.imaginator.com:554/ISAPI/streaming/channels/101 – Imaginator Apr 29 at 19:07
0

Do a piped roundtrip

ffmpeg -rtsp_transport tcp -i rtsp://xx -an -vcodec copy -bsf:v hevc_metadata=tick_rate=1 -f hevc - | ffmpeg -f hevc -i - -c copy out.mkv -y

ffmpeg looks for codec extradata only in first packet but the RTSP input appears to not have it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.