Jump to content
Cesbo Community
  • Announcements

    • RadioSintetica

      Information   10/21/18

      Registration on the forum temporarily closed! For support requests, please contacat us: https://cesbo.com/help
      Our community in Telegram: @cesbo_en (English language) , @cesbo_ru (Russian language) , @cesbo_es (Spanish Language)
Sign in to follow this  
sasskass

FFmpeg nvdec nvenc HLS dvbsub problem

Recommended Posts

Hi,

The source is UDP Mpeg-TS h264 stream with video, audio and dvb_subtitle pids.  FFmpeg nvdec video/audio and nvenc video/audio + mux HLS is working super.

The problem is with dvb_subtitles and  FFmpeg HLS mux .

UDP-ts in mux=HLS out - NOT working

 ffmpeg -re -y -err_detect aggressive -threads 1 -thread_queue_size 1024 -hwaccel cuvid -c:v h264_cuvid -drop_second_field 1 -vsync 1 -deint 1 -timeout 4000 -i "udp://239.2.1.8:1234?fifo_size=50000000" -filter:v scale_npp=w=1920:h=1080:format=nv12:interp_algo=lanczos -c:v hevc_nvenc -gpu 0 -g 75 -profile:v main10 -preset slow -rc vbr_hq -rc-lookahead 32 -b:v 3M -c:s copy -c:a aac -f hls -hls_time 4 -hls_list_size 4 -hls_allow_cache 0 -hls_flags delete_segments -segment_list_flags +live /var/www/html/hls/etv/live.m3u8

Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> hevc (hevc_nvenc))
  Stream #0:5 -> #0:1 (mp2 (native) -> aac (native))
  Stream #0:1 -> #0:2 (copy) -c:s webvtt the same error
Press [q] to stop, [?] for help
[hls @ 0x435fcc0] Opening '/var/www/html/hls/etv/live0.ts' for writing
[hls @ 0x435fcc0] Opening '/var/www/html/hls/etv/live0.vtt' for writing
[webvtt @ 0x567e3c0] Exactly one WebVTT stream is needed.
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
 

UDP-ts in mux=ssegment HLS out - working

ffmpeg -re -y -err_detect aggressive -threads 1 -thread_queue_size 1024 -hwaccel cuvid -c:v h264_cuvid -drop_second_field 1 -vsync 1 -deint 1 -timeout 4000 -i "udp://239.2.1.8:1234?fifo_size=50000000" -filter:v scale_npp=w=1920:h=1080:format=nv12:interp_algo=lanczos -map 0:0 -map 0:1 -map 0:5 -c:s copy -c:v hevc_nvenc -gpu 0 -g 75 -profile:v main10 -preset slow -rc vbr_hq -rc-lookahead 32 -b:v 3M  -c:a aac -f ssegment  -hls_flags delete_segments -segment_list_type hls -segment_list_size 4 -segment_list /var/www/html/hls/etv/playlist.m3u8 -segment_list_flags +live -segment_time 10 /var/www/html/hls/etv/out%03d.ts

 

UDP-ts in UDP-ts out - WORKING

ffmpeg -re -y -err_detect aggressive -threads 1 -thread_queue_size 1024 -hwaccel cuvid -c:v h264_cuvid -drop_second_field 1 -vsync 1 -deint 1 -timeout 4000 -i "udp://239.2.1.8:1234?fifo_size=50000000" -filter:v scale_npp=w=1920:h=1080:format=nv12:interp_algo=lanczos -c:v hevc_nvenc -gpu 0 -g 75 -profile:v main10 -preset slow -rc vbr_hq -rc-lookahead 32 -b:v 3M -c:s copy -c:a aac -f  mpegts udp://239.33.2.1:1234?pkt_size=1316
 

We can use mux ssegment, but we cannot find a solution how to delete old segments, the hls mux has this function (-hls_flags delete_segments)

Or transcode udp to upd and make HLS with Astra ?

Is there any solutin (low CPU) exept subtitles "burning" like -filter_complex "[0:v][0:s]overlay[v]" -map "[v]" -map 0:a:0   --- this procedure takes a huge amount of CPU and not acceptable.

Can understand if You answer in Russian

Kind Regards

Aleksander

 

Share this post


Link to post
Share on other sites

there is something strange at

[webvtt @ 0x567e3c0] Exactly one WebVTT stream is needed.

Quote

if (ctx->nb_streams != 1 || par->codec_id != AV_CODEC_ID_WEBVTT) {
    av_log(ctx, AV_LOG_ERROR, "Exactly one WebVTT stream is needed.\n");
    return AVERROR(EINVAL);
}

need more debug

may be a bug ?

can you change the line to and recompile

av_log(ctx, AV_LOG_ERROR, "Exactly one (got %d) WebVTT stream is needed. id %d != %d\n", ctx->nb_streams, par->codec_id,  AV_CODEC_ID_WEBVTT);

Share this post


Link to post
Share on other sites
Quote

We can use mux ssegment, but we cannot find a solution how to delete old segments, the hls mux has this function (-hls_flags delete_segments)

 You can just delete the old segments using a bash script as a workaround, if that suits you.

Share this post


Link to post
Share on other sites

Hi,

Digging the hlsenc.c and saw that in 2015 june they changed to Webvtt subtitle standard. 

Dvbsubs are bitmaps and Webvtt is text, so i think it is impossible to do water from stone... Except brake the new apple/google "standard" and  pass the subtitles to the ts file the old way. 

Flussonic goes to Tesseract OCR method but think there must be a better solution .

Will try to play with hlsenc.c and recompile.

MUX=ssegment old file deletion:

-segment_wrap (int) does the trick but anyway segmentation is not working as good as hls does

Aleksander

Share this post


Link to post
Share on other sites

Make infinite file names, jus externally delete the old chunks like :

 

#!/bin/bash
find /path/* -maxdepth 1 -mmin +1 -exec rm {} \;
sleep 10
find /path/* -maxdepth 1 -mmin +1 -exec rm {} \;
sleep 10
find /path/* -maxdepth 1 -mmin +1 -exec rm {} \;
sleep 10
find /path/* -maxdepth 1 -mmin +1 -exec rm {} \;

 Run this on cron every minute and it will be good if you use 10/6  :) It's dirty and simple , but it works. Hope it helps. 

Share this post


Link to post
Share on other sites

Hi 

Recompiled with Hack changes:

 

 Program 3601 
    Metadata:
      service_name    : ETV HD
      service_provider: STV
    Stream #0:0[0x65]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x68](est): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:2[0x69](rus): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:3[0x6a](ned): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:4[0x6b](art): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:5[0x66](est): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 320 kb/s
    Stream #0:6[0x67](a00): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 320 kb/s (hearing impaired)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> hevc (hevc_nvenc))
  Stream #0:5 -> #0:1 (mp2 (native) -> aac (native))
  Stream #0:1 -> #0:2 (copy)
Press [q] to stop, [?] for help
[mp2 @ 0x4164f40] Header missing
Error while decoding stream #0:5: Invalid data found when processing input
[hls @ 0x41e7700] Opening '/var/www/html/hls/etv/live0.ts' for writingpeed=N/A    
[hls @ 0x41e7700] Opening '/var/www/html/hls/etv/live0.vtt' for writing
[webvtt @ 0x52e1200] Exactly one (got 1) WebVTT stream is needed. id 94209 != 96265
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 -- 
[aac @ 0x4175f00] Qavg: 172.085
[aac @ 0x4175f00] 2 frames left in the queue on closing
Conversion failed!
 

Think its not a bug, but "the new standard" and bitmap to the text is not possible on the fly with ffmpeg the easy way, so easier is to hack the hlsenc.c file to bring the real standard back and bypass the Webvtt stuff

Aleksander

 

Share this post


Link to post
Share on other sites

i see, can't copy diff subtitle

[webvtt @ 0x52e1200] Exactly one (got 1) WebVTT stream is needed. id AV_CODEC_ID_DVB_SUBTITLE != AV_CODEC_ID_WEBVT

Share this post


Link to post
Share on other sites

remove this line in hlsenc.c

vs->has_subtitle += vs->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE;

and subtitle should pass as mpegts stream. not as webvtt

Share this post


Link to post
Share on other sites

Hi Hacker

Thank You for the suggestion, but not working...

-map 0

Input #0, mpegts, from 'udp://239.2.1.8:1234?fifo_size=50000000':
  Duration: N/A, start: 23346.530256, bitrate: N/A
  Program 3601 
    Metadata:
      service_name    : ETV HD
      service_provider: STV
    Stream #0:0[0x65]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x68](est): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:2[0x69](rus): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:3[0x6a](ned): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:4[0x6b](art): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:5[0x66](est): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 320 kb/s
    Stream #0:6[0x67](a00): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 320 kb/s (hearing impaired)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> hevc (hevc_nvenc))
  Stream #0:1 -> #0:1 (dvb_subtitle (dvbsub) -> webvtt (native))
  Stream #0:2 -> #0:2 (dvb_subtitle (dvbsub) -> webvtt (native))
  Stream #0:3 -> #0:3 (dvb_subtitle (dvbsub) -> webvtt (native))
  Stream #0:4 -> #0:4 (dvb_subtitle (dvbsub) -> webvtt (native))
  Stream #0:5 -> #0:5 (mp2 (native) -> aac (native))
  Stream #0:6 -> #0:6 (mp2 (native) -> aac (native))
Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height

 

-c:s copy 

Input #0, mpegts, from 'udp://239.2.1.8:1234?fifo_size=50000000':
  Duration: N/A, start: 23455.922244, bitrate: N/A
  Program 3601 
    Metadata:
      service_name    : ETV HD
      service_provider: STV
    Stream #0:0[0x65]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x68](est): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:2[0x69](rus): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:3[0x6a](ned): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:4[0x6b](art): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
    Stream #0:5[0x66](est): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 320 kb/s
    Stream #0:6[0x67](a00): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 320 kb/s (hearing impaired)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> hevc (hevc_nvenc))
  Stream #0:5 -> #0:1 (mp2 (native) -> aac (native))
  Stream #0:1 -> #0:2 (copy)
Press [q] to stop, [?] for help
[mp2 @ 0x39c59c0] Header missing
Segmentation fault (core dumped)/A time=-577014:32:22.77 bitrate=N/A speed=N/A 

Kind Regards

Aleksander

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×