<p>The key <strong>-drop_second_field 1</strong> fixed this issue. <br> And result command looks as follow: <br></p>

<blockquote>
  <p>ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -deint 2 -drop_second_field 1
  -i "udp://IP:PORT" <br> -vcodec h264_nvenc -acodec libfdk_aac -f flv rtmp://IP/test/name</p>
</blockquote>

<p><br>
What I think about this problem: at the moment in cuda decoding we can use only 2 deinterlace variants: </p>

<ul>
<li>-deint 1 it's bob deinterlacing,</li>
<li>-deint 2 it's adaptive deinterlacing.</li>
</ul>

<p>Both of these variants are increase bitrate, because after deinterlacing each field(half of frame) displaying as frame (framerate is doubled) Bitrate is grow and if fps is variable we got timestamps issue. And when we enable drop second field then everything looks fine with bitrate and timestamps.</p>

CC BY-SA 3.0
2017-05-26T13:21:51.173Z
2017-05-29T06:40:10.143Z
2017-05-29T06:40:10.143Z
Ivan Kolesnikov
<p>Please see my input udp stream information: </p>

<blockquote>
  <p>ffprobe udp://IP:PORT</p>
</blockquote>

<pre><code>Input #0, mpegts, from 'udp://IP:PORT':
  Duration: N/A, start: 42243.737022, bitrate: N/A
  Program 17
  . . .
    Stream #0:0[0x781]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg, top first), 720x576 [SAR 12:11 DAR 15:11], 24.67 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x782](Tam): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 64 kb/s
    Stream #0:2[0x783](Kan): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 64 kb/s
</code></pre>

<p>And run this command again:</p>

<blockquote>
  <p>ffprobe udp://IP:PORT</p>
</blockquote>

<pre><code>Input #0, mpegts, from 'IP:PORT':
  Duration: N/A, start: 42589.601022, bitrate: N/A
  . . . 
  Program 17
    Stream #0:0[0x781]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg, top first), 720x576 [SAR 12:11 DAR 15:11], 24.58 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x782](Tam): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 64 kb/s
    Stream #0:2[0x783](Kan): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 64 kb/s
</code></pre>

<p>Please pay attention to FPS value. In the first execution it <strong>24.67</strong> and in the second it <strong>24.58</strong></p>

<p>I want to transcode this stream with the following command:</p>

<blockquote>
  <p>ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -deint 2 -i
  "udp://IP:PORT" -map 0:#0x0781 -map 
  0:#0x0782 -vcodec h264_nvenc -acodec libfdk_aac -f flv rtmp://IP/test/name</p>
</blockquote>

<p>Please see the log:</p>

<pre><code>Past duration 0.981102 too large
frame=83 fps=0.0 q=18.0 size=502kB time=00:00:04.05 bitrate=1015.4kbits/s dup=0 drop=80 speed=7.42x  
frame=96 fps=90 q=18.0 size=643kB time=00:00:04.69 bitrate=1122.1kbits/s dup=0 drop=93 speed=4.38x  
frame=111 fps=70 q=18.0 size=802kB time=00:00:05.14 bitrate=1278.1kbits/s dup=0 drop=108 speed=3.26x 
frame=121 fps=57 q=19.0 size=921kB time=00:00:05.61 bitrate=1344.7kbits/s dup=0 drop=118 speed=2.64x 
frame=137 fps=49 q=19.0 size=1096kB time=00:00:06.25 bitrate=1436.4kbits/s dup=0 drop=134 speed=2.26x
</code></pre>

<p>I also can add the framerate parameter "-r". As follow:</p>

<blockquote>
  <p>ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -deint 2 -r 25 -i
  "udp://IP:PORT" -map 0:#0x0781 -map 
  0:#0x0782 -vcodec h264_nvenc -r 25 -acodec libfdk_aac -f flv rtmp://IP/test/name</p>
</blockquote>

<p>In this case this warning is not shows. But the transcoding FFmpeg process failed after 10-15 seconds, without any errors in the log. <br><br>
Everything works fine if I do it via software decoding:</p>

<blockquote>
  <p>ffmpeg -y -i
  "udp://IP:PORT" -map 0:#0x0781 -map 
  0:#0x0782 -vcodec h264_nvenc -acodec libfdk_aac -f flv rtmp://IP/test/name</p>
</blockquote>

<p>Also everything works fine if I transcoding it to the local file and specify framerate:</p>

<blockquote>
  <p>ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -deint 2 -r 25 -i
  "udp://IP:PORT" -map 0:#0x0781 -map 
  0:#0x0782 -vcodec h264_nvenc -r 25 -acodec libfdk_aac -f flv result.flv</p>
</blockquote>

<p><strong>This issue affects only for some input streams.</strong><br>
How can I transcode this UDP stream to FLV stream with CUDA decoding? </p>

<ffmpeg><decoding><cuvid>
FFmpeg. CUDA decode. Past duration too large. Variable FPS
Ivan Kolesnikov
# FFmpeg. CUDA decode. Past duration too large. Variable FPS

(Asked by: username_0 on 2017-05-24)

Please see my input udp stream information: 

ffprobe udp://IP:PORT

Input #0, mpegts, from 'udp://IP:PORT':
  Duration: N/A, start: 42243.737022, bitrate: N/A
  Program 17
  . . .
    Stream #0:0[0x781]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg, top first), 720x576 [SAR 12:11 DAR 15:11], 24.67 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x782](Tam): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 64 kb/s
    Stream #0:2[0x783](Kan): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 64 kb/s

And run this command again:

ffprobe udp://IP:PORT

Input #0, mpegts, from 'IP:PORT':
  Duration: N/A, start: 42589.601022, bitrate: N/A
  . . . 
  Program 17
    Stream #0:0[0x781]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg, top first), 720x576 [SAR 12:11 DAR 15:11], 24.58 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x782](Tam): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 64 kb/s
    Stream #0:2[0x783](Kan): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 64 kb/s

Please pay attention to FPS value. In the first execution it 24.67 and in the second it 24.58
I want to transcode this stream with the following command:

ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -deint 2 -i
  "udp://IP:PORT" -map 0:#0x0781 -map 
  0:#0x0782 -vcodec h264_nvenc -acodec libfdk_aac -f flv rtmp://IP/test/name

Please see the log:
Past duration 0.981102 too large
frame=83 fps=0.0 q=18.0 size=502kB time=00:00:04.05 bitrate=1015.4kbits/s dup=0 drop=80 speed=7.42x  
frame=96 fps=90 q=18.0 size=643kB time=00:00:04.69 bitrate=1122.1kbits/s dup=0 drop=93 speed=4.38x  
frame=111 fps=70 q=18.0 size=802kB time=00:00:05.14 bitrate=1278.1kbits/s dup=0 drop=108 speed=3.26x 
frame=121 fps=57 q=19.0 size=921kB time=00:00:05.61 bitrate=1344.7kbits/s dup=0 drop=118 speed=2.64x 
frame=137 fps=49 q=19.0 size=1096kB time=00:00:06.25 bitrate=1436.4kbits/s dup=0 drop=134 speed=2.26x

I also can add the framerate parameter "-r". As follow:

ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -deint 2 -r 25 -i
  "udp://IP:PORT" -map 0:#0x0781 -map 
  0:#0x0782 -vcodec h264_nvenc -r 25 -acodec libfdk_aac -f flv rtmp://IP/test/name

In this case this warning is not shows. But the transcoding FFmpeg process failed after 10-15 seconds, without any errors in the log. 
Everything works fine if I do it via software decoding:

ffmpeg -y -i
  "udp://IP:PORT" -map 0:#0x0781 -map 
  0:#0x0782 -vcodec h264_nvenc -acodec libfdk_aac -f flv rtmp://IP/test/name

Also everything works fine if I transcoding it to the local file and specify framerate:

ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -deint 2 -r 25 -i
  "udp://IP:PORT" -map 0:#0x0781 -map 
  0:#0x0782 -vcodec h264_nvenc -r 25 -acodec libfdk_aac -f flv result.flv

This issue affects only for some input streams.
How can I transcode this UDP stream to FLV stream with CUDA decoding?

**Tags:** ffmpeg, decoding, cuvid


---

## 1 answers

### Answer by username_0 on 2017-05-26. Score: 1 | Accepted answer

The key **-drop\_second\_field 1** fixed this issue.   
 And result command looks as follow:

> ffmpeg -y -hwaccel cuvid -c:v h264\_cuvid -deint 2 -drop\_second\_field 1
> -i "udp://IP:PORT"   
>  -vcodec h264\_nvenc -acodec libfdk\_aac -f flv rtmp://IP/test/name

What I think about this problem: at the moment in cuda decoding we can use only 2 deinterlace variants:

* -deint 1 it's bob deinterlacing,
* -deint 2 it's adaptive deinterlacing.

Both of these variants are increase bitrate, because after deinterlacing each field(half of frame) displaying as frame (framerate is doubled) Bitrate is grow and if fps is variable we got timestamps issue. And when we enable drop second field then everything looks fine with bitrate and timestamps.


---

