Opened 13 years ago
Closed 13 years ago
#614 closed defect (invalid)
mpegts issue on localhost
Reported by: | burek | Owned by: | Michael Niedermayer |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | git-master | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Hi,
In response to https://ffmpeg.org/trac/ffmpeg/ticket/602 (cehoyos), I'll try to provide my experience with mpegts format.
Here is the first issue. I have 2 ffmpeg processes, the first one should send the a/v (aac+h264) to the localhost:port using udp, and the 2nd ffmpeg process should pick it up and just save to the .ts file.
This is the command line of the first ffmpeg:
ffmpeg -y -re \ -f video4linux2 -r 30 -s qvga -i /dev/v4l/by-id/usb-046d_0809_33A881A3-video-index0 \ -f alsa -ar 44100 -ac 2 -i default:CARD=Intel \ -vcodec libx264 -crf 20 -threads 0 \ -acodec aac -ab 32k -ar 44100 -ac 2 \ -strict experimental \ -vbsf h264_mp4toannexb \ -absf aac_adtstoasc \ -f mpegts udp://127.0.0.1:10001
And this is the command of the 2nd ffmpeg:
ffmpeg -muxdelay 15 -f mpegts -i udp://localhost:10001 -acodec copy -vcodec copy out.ts
Now, when I try to play the .ts file in VLC, I can watch the video, but in the message log I can see a lot of those:
main warning: late picture skipped (35805 > -268) main warning: late picture skipped (2472 > -268) main warning: late picture skipped (7218 > -262) main warning: late picture skipped (1171 > -334) main warning: late picture skipped (24818 > -266) main warning: late picture skipped (19257 > -277) main warning: late picture skipped (14977 > -303) main warning: late picture skipped (57074 > -266) main warning: late picture skipped (23740 > -266) main warning: late picture skipped (5374 > -265) main warning: late picture skipped (1929 > -15969) main warning: late picture skipped (1376 > -264)
I'm sure the network is not an issue here :) and also, I've monitored cpu usage (on a dual core) and it didn't go over 40% at any time.
Also, when I record a live stream this way for a very long time (like 12 hours or more) the audio and video get totally async, meaning audio is progressively advancing before the video and after like 3-4 hours of recording, the drift is around 10 seconds and will get even bigger for the longer period of the recording.
I can send you samples of .ts files, only I'll need to record for that long, so you can see that it really happens.
Other issues are related to remuxing from .ts to .flv (also with h264+aac), but I'll see to create new tickets for that.
Change History (13)
comment:1 by , 13 years ago
Component: | FFmpeg → undetermined |
---|
comment:2 by , 13 years ago
Well, I didn't try just recording to .ts file for that long, more rational way was to stream to an udp port because that way I could duplicate the data and watch it, while it is being saved to a file.
Anyway, for the absf, I don't remember now where exactly did I pick up that option (was it in ffmpeg channel or google), I just know that without it, when I play the udp stream in VLC, then the audio is a lot more quirky, skipping up/down-sampling and stuff... And since there is no official documentation on that filter ( http://ffmpeg.org/ffmpeg.html#aac_005fadtstoasc ), I didn't have chance to read about its real intended usage, so it might be the reason of the async behavior.
Can You give me one working example (default or something) of using mpegts (h264+aac) over udp, just to test it, because I've tried so many different combinations and variations I can't even remember now and none of them gave the smooth and clean playback without async (I'm talking about 100/100 LAN network). What could be the simplest way to start such a stream?
comment:3 by , 13 years ago
I meant the video bitstream filter that should only make sense when stream copying from mp4.
To clarify:
Does creating the transport stream without using udp (and without audio and without the video bitstream filter) produce a file that does not show the warnings in vlc?
comment:4 by , 13 years ago
why without audio?
and yes, it does:
ffmpeg:
ffmpeg -y -re \ -f video4linux2 -r 30 -s qvga -i /dev/v4l/by-id/usb-046d_0809_33A881A3-video-index0 \ -vcodec libx264 -crf 20 -threads 0 \ out.ts
vlc:
main debug: processing request item out.ts node Playlist skip 0 main debug: resyncing on out.ts main debug: out.ts is at 0 main debug: starting new item main debug: creating new input thread main debug: Creating an input for 'out.ts' main debug: thread (input) created at priority 1 (../.././src/input/input.c:220) qt4 debug: IM: Setting an input main debug: thread started main debug: using timeshift granularity of 50 MiB main debug: using timeshift path 'C:\DOCUME~1\YourUsernameHere\LOCALS~1\Temp' main debug: `file:///C:/Documents%20and%20Settings/YourUsernameHere/Desktop/out.ts' gives access `file' demux `' path `C:\Documents and Settings\YourUsernameHere\Desktop\out.ts' main debug: creating demux: access='file' demux='' path='C:\Documents and Settings\YourUsernameHere\Desktop\out.ts' main debug: looking for access_demux module: 2 candidates main debug: no access_demux module matching "file" could be loaded main debug: TIMER module_need() : 38.501 ms - Total 38.501 ms / 1 intvls (Avg 38.501 ms) main debug: creating access 'file' path='C:\Documents and Settings\YourUsernameHere\Desktop\out.ts' main debug: looking for access module: 2 candidates filesystem debug: opening file `C:\Documents and Settings\YourUsernameHere\Desktop\out.ts' main debug: using access module "filesystem" main debug: TIMER module_need() : 36.555 ms - Total 36.555 ms / 1 intvls (Avg 36.555 ms) main debug: Using AStream*Stream main debug: pre buffering main debug: received first data after 0 ms main debug: pre-buffering done 1024 bytes in 0s - 6060 KiB/s main debug: looking for stream_filter module: 2 candidates main debug: no stream_filter module matching "any" could be loaded main debug: TIMER module_need() : 0.427 ms - Total 0.427 ms / 1 intvls (Avg 0.427 ms) main debug: looking for stream_filter module: 1 candidate main debug: using stream_filter module "stream_filter_record" main debug: TIMER module_need() : 0.412 ms - Total 0.412 ms / 1 intvls (Avg 0.412 ms) main debug: creating demux: access='file' demux='' path='C:\Documents and Settings\YourUsernameHere\Desktop\out.ts' main debug: looking for demux module: 52 candidates ts debug: PATCallBack called ts debug: new PAT ts_id=1 version=0 current_next=1 ts debug: * number=1 pid=4096 ts debug: PMTCallBack called ts debug: new PMT program number=1 version=0 pid_pcr=256 ts debug: * es pid=256 type=27 fcc=h264 main debug: selecting program id=1 filesystem warning: unimplemented query 4097 in control main debug: using demux module "ts" main debug: TIMER module_need() : 2.874 ms - Total 2.874 ms / 1 intvls (Avg 2.874 ms) main debug: looking for a subtitle file in C:\Documents and Settings\YourUsernameHere\Desktop\ main debug: looking for decoder module: 34 candidates avcodec debug: libavcodec already initialized avcodec debug: trying to use direct rendering avcodec debug: ffmpeg codec (H264 - MPEG-4 AVC (part 10)) started main debug: using decoder module "avcodec" main debug: TIMER module_need() : 2.785 ms - Total 2.785 ms / 1 intvls (Avg 2.785 ms) main debug: looking for packetizer module: 21 candidates main debug: using packetizer module "packetizer_h264" main debug: TIMER module_need() : 0.528 ms - Total 0.528 ms / 1 intvls (Avg 0.528 ms) main debug: thread (decoder) created at priority 0 (../.././src/input/decoder.c:301) main debug: thread started ts debug: DEMUX_SET_GROUP 0 00000000 main debug: looking for meta reader module: 2 candidates lua debug: Trying Lua scripts in C:\Documents and Settings\YourUsernameHere\Application Data\vlc\lua\meta\reader lua debug: Trying Lua scripts in C:\Program Files\VideoLAN\VLC\lua\meta\reader lua debug: Trying Lua playlist script C:\Program Files\VideoLAN\VLC\lua\meta\reader\filename.lua main debug: no meta reader module matching "any" could be loaded main debug: TIMER module_need() : 38.648 ms - Total 38.648 ms / 1 intvls (Avg 38.648 ms) main debug: `file:///C:/Documents%20and%20Settings/YourUsernameHere/Desktop/out.ts' successfully opened main debug: Buffering 0% main debug: Buffering 33% main debug: Buffering 66% main debug: Buffering 100% main debug: Stream buffering done (400 ms in 39 ms) packetizer_h264 debug: found NAL_SPS (sps_id=0) packetizer_h264 debug: found NAL_PPS (pps_id=0 sps_id=0) main debug: no usable vout present, spawning one main debug: looking for text renderer module: 2 candidates freetype debug: Using Arial as font from file C:\WINDOWS\Fonts\ARIAL.TTF freetype debug: using fontsize: 2 main debug: using text renderer module "freetype" main debug: TIMER module_need() : 28.828 ms - Total 28.828 ms / 1 intvls (Avg 28.828 ms) main debug: looking for video filter2 module: 18 candidates swscale debug: 32x32 chroma: YUVA -> 16x16 chroma: YUVA with scaling using Bicubic (good quality) main debug: using video filter2 module "swscale" main debug: TIMER module_need() : 22.706 ms - Total 22.706 ms / 1 intvls (Avg 22.706 ms) main debug: looking for video filter2 module: 18 candidates yuvp debug: YUVP to YUVA converter main debug: using video filter2 module "yuvp" main debug: TIMER module_need() : 128.555 ms - Total 128.555 ms / 1 intvls (Avg 128.555 ms) main debug: window size: 320x240 main debug: Deinterlacing available main debug: deinterlace 0, mode blend, is_needed 0 main debug: looking for video output module: 1 candidate vout_wrapper debug: Opening vout display wrapper main debug: looking for vout display module: 8 candidates directx debug: creating Vout EventThread directx debug: DirectXCreateWindow main debug: looking for vout window hwnd module: 3 candidates qt4 debug: requesting video... qt4 debug: Video was requested 0, 0 main debug: using vout window hwnd module "qt4" main debug: TIMER module_need() : 35.024 ms - Total 35.024 ms / 1 intvls (Avg 35.024 ms) directx debug: created video sub-window directx debug: Vout EventThread running directx debug: disabling screen saver directx debug: directx-device: directx debug: DirectXEnumCallback: RADEON 9250, \\.\DISPLAY1 directx debug: selecting RADEON 9250, \\.\DISPLAY1 directx debug: screen dimensions (0x0,1280x768) directx debug: DirectDraw Capabilities: overlay=1 yuvoverlay=1 can_deinterlace_overlay=1 colorkey=1 stretch=1 bltfourcc=1 main debug: VoutDisplayEvent 'resize' 328x274 window directx debug: YUV overlay surface created successfully main debug: using vout display module "directx" main debug: TIMER module_need() : 163.982 ms - Total 163.982 ms / 1 intvls (Avg 163.982 ms) main debug: using video output module "vout_wrapper" main debug: TIMER module_need() : 192.057 ms - Total 192.057 ms / 1 intvls (Avg 192.057 ms) main debug: got 1 direct buffer(s) main debug: pic render sz 320x240, of (0,0), vsz 320x240, 4cc I420, sar 1:1, msk r0x0 g0x0 b0x0 main debug: pic in sz 320x240, of (0,0), vsz 320x240, 4cc I420, sar 1:1, msk r0x0 g0x0 b0x0 main debug: pic out sz 320x240, of (0,0), vsz 320x240, 4cc I420, sar 1:1, msk r0x0 g0x0 b0x0 main debug: direct render, mapping render pictures 0-23 to system pictures 1-24 avcodec debug: using direct rendering main debug: VoutDisplayEvent 'resize' 427x240 window main debug: End of video preroll main debug: Received first picture main debug: Decoder buffering done in 546 ms main debug: Post-processing available main warning: vlc_object_find_name(postproc) is not safe! freetype debug: using fontsize: 15 main debug: looking for video blending module: 1 candidate blend debug: chroma: YUVA -> I420 main debug: using video blending module "blend" main debug: TIMER module_need() : 33.145 ms - Total 33.145 ms / 1 intvls (Avg 33.145 ms) main debug: auto hidding mouse ts debug: PSINewTableCallBack: table 0x42(66) ext=0x1(1) ts debug: SDTCallBack called ts debug: new SDT ts_id=1 version=0 current_next=1 network_id=1 ts debug: * service id=1 eit schedule=0 present=0 running=4 free_ca=0 ts debug: - type=1 provider=FFmpeg name=Service01 main debug: EsOutProgramMeta: number=1 main warning: late picture skipped (21217 > -396) main warning: late picture skipped (54550 > -396) main warning: late picture skipped (16039 > -387) main warning: late picture skipped (5155 > -398) main warning: late picture skipped (9904 > -252) main warning: late picture skipped (25470 > -262) main warning: late picture skipped (33866 > -261) main warning: late picture skipped (533 > -261) main warning: late picture skipped (10743 > -260) main warning: late picture skipped (11036 > -261) main warning: late picture skipped (10930 > -262) main warning: late picture skipped (6950 > -258) main warning: late picture skipped (3569 > -258) main warning: late picture skipped (33738 > -261) main warning: late picture skipped (404 > -261) main warning: late picture skipped (10463 > -258) main warning: late picture skipped (6305 > -268) main warning: late picture skipped (11728 > -253) ts debug: eof ? main debug: EOF reached
comment:5 by , 13 years ago
encoding audio only works just fine:
ffmpeg -y -re \ -f alsa -ar 44100 -ac 2 -i default:CARD=Intel \ -acodec aac -ab 32k -ar 44100 -ac 2 \ -strict experimental \ out.ts
No warnings, errors, nothin, just clear audio :)
comment:6 by , 13 years ago
Is this only reproducible with an external library (-vcodec libx264) or also with an internal encoder?
Please post complete, uncut console output (including command line) without -threads 0.
And do you have any idea what the vlc warnings mean? Are there any visible problems with the resulting file? Do other players (ffplay, MPlayer, WMP 12) show any problems?
comment:7 by , 13 years ago
Same scenario with this example (mpeg2video):
ffmpeg -y -re \ -f video4linux2 -r 30 -s qvga -i /dev/v4l/by-id/usb-046d_0809_33A881A3-video-index0 \ out.ts ffmpeg version N-34519-g54a09f1, Copyright (c) 2000-2011 the FFmpeg developers built on Nov 6 2011 12:46:05 with gcc 4.6.1 configuration: --enable-static --enable-shared --enable-gpl --enable-nonfree --enable-postproc --enable-libx264 --enable-libaacplus --enable-libmp3lame --enable-libv4l2 --enable-libvo-aacenc --enable-version3 libavutil 51. 23. 0 / 51. 23. 0 libavcodec 53. 28. 0 / 53. 28. 0 libavformat 53. 19. 0 / 53. 19. 0 libavdevice 53. 4. 0 / 53. 4. 0 libavfilter 2. 47. 0 / 2. 47. 0 libswscale 2. 1. 0 / 2. 1. 0 libpostproc 51. 2. 0 / 51. 2. 0 [video4linux2,v4l2 @ 0x1f9c980] Estimating duration from bitrate, this may be inaccurate Input #0, video4linux2,v4l2, from '/dev/v4l/by-id/usb-046d_0809_33A881A3-video-index0': Duration: N/A, start: 27501.143731, bitrate: 27648 kb/s Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240, 27648 kb/s, 30 tbr, 1000k tbn, 30 tbc [buffer @ 0x1f9c800] w:320 h:240 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param: [mpegts @ 0x1f97040] muxrate VBR, pcr every 3 pkts, sdt every 200, pat/pmt every 40 pkts Output #0, mpegts, to 'out.ts': Metadata: encoder : Lavf53.19.0 Stream #0:0: Video: mpeg2video, yuv420p, 320x240, q=2-31, 200 kb/s, 90k tbn, 30 tbc Stream mapping: Stream #0.0 -> #0.0 (rawvideo -> mpeg2video) Press [q] to stop, [?] for help frame= 976 fps= 30 q=5.7 Lsize= 1257kB time=00:00:32.50 bitrate= 317.0kbits/s dup=638 drop=0 video:1070kB audio:0kB global headers:0kB muxing overhead 17.558359%
And here is libx264 without -threads:
# ffmpeg -y -re \ -f video4linux2 -r 30 -s qvga -i /dev/v4l/by-id/usb-046d_0809_33A881A3-video-index0 \ -vcodec libx264 -crf 20 \ out.ts ffmpeg version N-34519-g54a09f1, Copyright (c) 2000-2011 the FFmpeg developers built on Nov 6 2011 12:46:05 with gcc 4.6.1 configuration: --enable-static --enable-shared --enable-gpl --enable-nonfree --enable-postproc --enable-libx264 --enable-libaacplus --enable-libmp3lame --enable-libv4l2 --enable-libvo-aacenc --enable-version3 libavutil 51. 23. 0 / 51. 23. 0 libavcodec 53. 28. 0 / 53. 28. 0 libavformat 53. 19. 0 / 53. 19. 0 libavdevice 53. 4. 0 / 53. 4. 0 libavfilter 2. 47. 0 / 2. 47. 0 libswscale 2. 1. 0 / 2. 1. 0 libpostproc 51. 2. 0 / 51. 2. 0 [video4linux2,v4l2 @ 0x707980] Estimating duration from bitrate, this may be inaccurate Input #0, video4linux2,v4l2, from '/dev/v4l/by-id/usb-046d_0809_33A881A3-video-index0': Duration: N/A, start: 27685.969253, bitrate: 27648 kb/s Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240, 27648 kb/s, 30 tbr, 1000k tbn, 30 tbc [buffer @ 0x708440] w:320 h:240 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param: [libx264 @ 0x7025a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64 [libx264 @ 0x7025a0] profile High, level 1.3 [mpegts @ 0x702040] muxrate VBR, pcr every 3 pkts, sdt every 200, pat/pmt every 40 pkts Output #0, mpegts, to 'out.ts': Metadata: encoder : Lavf53.19.0 Stream #0:0: Video: h264, yuv420p, 320x240, q=-1--1, 90k tbn, 30 tbc Stream mapping: Stream #0.0 -> #0.0 (rawvideo -> libx264) Press [q] to stop, [?] for help frame= 636 fps= 29 q=-1.0 Lsize= 626kB time=00:00:21.13 bitrate= 242.5kbits/s dup=442 drop=0 video:497kB audio:0kB global headers:0kB muxing overhead 25.792506% [libx264 @ 0x7025a0] frame I:3 Avg QP:14.98 size: 15692 [libx264 @ 0x7025a0] frame P:424 Avg QP:19.03 size: 1074 [libx264 @ 0x7025a0] frame B:209 Avg QP:25.71 size: 33 [libx264 @ 0x7025a0] consecutive B-frames: 56.1% 0.0% 0.5% 43.4% [libx264 @ 0x7025a0] mb I I16..4: 2.4% 62.2% 35.3% [libx264 @ 0x7025a0] mb P I16..4: 0.0% 0.1% 0.0% P16..4: 33.9% 9.4% 7.7% 0.0% 0.0% skip:48.9% [libx264 @ 0x7025a0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 3.4% 0.0% 0.0% direct: 0.2% skip:96.3% L0:54.6% L1:44.0% BI: 1.4% [libx264 @ 0x7025a0] 8x8 transform intra:64.4% inter:74.7% [libx264 @ 0x7025a0] coded y,uvDC,uvAC intra: 97.3% 99.6% 98.7% inter: 9.6% 30.5% 18.6% [libx264 @ 0x7025a0] i16 v,h,dc,p: 3% 3% 29% 65% [libx264 @ 0x7025a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 20% 13% 3% 9% 5% 17% 5% 9% [libx264 @ 0x7025a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 20% 8% 5% 10% 6% 15% 9% 9% [libx264 @ 0x7025a0] i8c dc,h,v,p: 62% 19% 10% 9% [libx264 @ 0x7025a0] Weighted P-Frames: Y:0.7% UV:0.2% [libx264 @ 0x7025a0] ref P L0: 63.4% 6.8% 7.9% 21.7% 0.1% [libx264 @ 0x7025a0] ref B L0: 85.1% 13.1% 1.8% [libx264 @ 0x7025a0] ref B L1: 91.4% 8.6% [libx264 @ 0x7025a0] kb/s:192.20
The problem still exists.
That message tells that the timestamps are somehow wrong, I guess. Sometimes I can see the image freezes for a fraction of a second and the image goes distorted just like a wrong keyframe was used for all the subsequent delta frames, but it gets back to normal after a couple of seconds.
comment:8 by , 13 years ago
Are the problems only reproducible with -vcodec mpeg2video -f mpegts or also for -vcodec mpeg2video -f avi/mpg/mkv ?
comment:9 by , 13 years ago
-vcodec mpeg2video -f avi: no warnings at all
-vcodec mpeg2video -f mpeg: warnings are there constantly, just like with mpegts
-vcodec mpeg2video -f matroska: no warnings at all
comment:10 by , 13 years ago
Is the problem also reproducible with
ffmpeg -f video4linux2 -i /dev/v4l/by-id/usb-046d_0809_33A881A3-video-index0 out.ts
?
Or is -r 30 needed to make the conversion work at all?
comment:11 by , 13 years ago
-r 30 just tells the driver to correctly sample the video input, so we don't have to resample it afterwards
here is the log:
# ffmpeg -f video4linux2 -i /dev/v4l/by-id/usb-046d_0809_33A881A3-video-index0 out.ts ffmpeg version N-34519-g54a09f1, Copyright (c) 2000-2011 the FFmpeg developers built on Nov 6 2011 12:46:05 with gcc 4.6.1 configuration: --enable-static --enable-shared --enable-gpl --enable-nonfree --enable-postproc --enable-libx264 --enab le-libaacplus --enable-libmp3lame --enable-libv4l2 --enable-libvo-aacenc --enable-version3 libavutil 51. 23. 0 / 51. 23. 0 libavcodec 53. 28. 0 / 53. 28. 0 libavformat 53. 19. 0 / 53. 19. 0 libavdevice 53. 4. 0 / 53. 4. 0 libavfilter 2. 47. 0 / 2. 47. 0 libswscale 2. 1. 0 / 2. 1. 0 libpostproc 51. 2. 0 / 51. 2. 0 [video4linux2,v4l2 @ 0x1daf780] The driver changed the time per frame from 32767/1996117544 to 1/30 [video4linux2,v4l2 @ 0x1daf780] Estimating duration from bitrate, this may be inaccurate Input #0, video4linux2,v4l2, from '/dev/v4l/by-id/usb-046d_0809_33A881A3-video-index0': Duration: N/A, start: 25528.008073, bitrate: 27648 kb/s Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240, 27648 kb/s, 30 tbr, 1000k tbn, 30 tbc [buffer @ 0x1dbdf40] w:320 h:240 pixfmt:yuv420p tb:1/1000000 sar:0/1 sws_param: [mpegts @ 0x1dbd0a0] muxrate VBR, pcr every 3 pkts, sdt every 200, pat/pmt every 40 pkts Output #0, mpegts, to 'out.ts': Metadata: encoder : Lavf53.19.0 Stream #0:0: Video: mpeg2video, yuv420p, 320x240, q=2-31, 200 kb/s, 90k tbn, 30 tbc Stream mapping: Stream #0.0 -> #0.0 (rawvideo -> mpeg2video) Press [q] to stop, [?] for help frame= 480 fps= 37 q=10.3 Lsize= 754kB time=00:00:15.96 bitrate= 386.9kbits/s dup=287 drop=0 video:658kB audio:0kB global headers:0kB muxing overhead 14.622744%
and warnings are also there again :/
comment:12 by , 13 years ago
I apologize, it seems that this error is related to a slow hardware (??) although I'm not sure why, because the cpu usage never gets over 30-40%, but they say its related to a slow decoder/cpu or something like that, so this bug report can be closed without further examination, I guess.
comment:13 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Assuming this is not reproducible with
Isn't this more an udp issue?
And why are you using the bsf?