Guest User

FFMPEG: streaming video generated from still images to RTMP

a guest
Jun 30th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.26 KB | None | 0 0
  1. This below text outlines my troubles in trying to stream a video, generated on-the-fly from a list of image files, to an RTMP server. I can generate a playable video file. I can successfully stream some videos. But I can't do both in a single step.
  2.  
  3. Successfully encoded images into a playable video:
  4. ffmpeg -framerate 1/10 -f image2 -i image%02d.png -r 25 -c:v libx264 -pix_fmt yuv420p video.mp4
  5.  
  6. Attempt to generate the same video for sending to RTMP server( notice -re tag at beginning and '-f flv' at the end):
  7. ffmpeg -re -framerate 1/10 -f image2 -i image%02d.png -r 25 -c:v libx264 -pix_fmt yuv420p -f flv rtmp://live-sjc.twitch.tv/app/$(cat ~/twitch_key)
  8. Some console output:
  9.  
  10. Input #0, image2, from 'image%02d.png':
  11. Duration: 00:02:10.00, start: 0.000000, bitrate: N/A
  12. Stream #0:0: Video: png, rgb24(pc), 640x480, 0.10 fps, 0.10 tbr, 0.10 tbn, 0.10 tbc
  13. [libx264 @ 0x7f8691098360] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX XOP FMA4 FMA3 LZCNT BMI1
  14. [libx264 @ 0x7f8691098360] profile High, level 3.0
  15. [libx264 @ 0x7f8691098360] 264 - core 144 r2533 c8a773e - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
  16. Output #0, flv, to 'rtmp://live-sjc.twitch.tv/app/live_94772137_zC3RWmdfCQFK9OKZN78x211LNtGrsL':
  17. Metadata:
  18. encoder : Lavf56.36.100
  19. Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 640x480, q=-1--1, 25 fps, 1k tbn, 25 tbc
  20. Metadata:
  21. encoder : Lavc56.41.100 libx264
  22. Stream mapping:
  23. Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
  24. Press [q] to stop, [?] for help
  25. frame= 0 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A
  26. // The 'frame' and 'fps' fields change as ffmpeg goes through each image, but every other field stays the same
  27. // and then it outputs this:
  28. Press [q] to stop, [?] for help
  29. [flv @ 0x7f9fb220b520] Failed to update header with correct duration.A
  30. [flv @ 0x7f9fb220b520] Failed to update header with correct filesize.
  31. frame= 13 fps=2.4 q=-1.0 Lsize= 780kB time=00:00:03.36 bitrate=1900.7kbits/s
  32. video:779kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.069447%
  33. [libx264 @ 0x7f9fb220bd00] frame I:1 Avg QP:21.75 size: 51592
  34. [libx264 @ 0x7f9fb220bd00] frame P:12 Avg QP:21.96 size: 62121
  35. [libx264 @ 0x7f9fb220bd00] mb I I16..4: 0.2% 46.4% 53.4%
  36. [libx264 @ 0x7f9fb220bd00] mb P I16..4: 4.4% 47.5% 48.0% P16..4: 0.1% 0.0% 0.0% 0.0% 0.0% skip: 0.0%
  37. [libx264 @ 0x7f9fb220bd00] 8x8 transform intra:47.4% inter:83.3%
  38. [libx264 @ 0x7f9fb220bd00] coded y,uvDC,uvAC intra: 88.8% 86.8% 71.0% inter: 81.2% 66.7% 25.0%
  39. [libx264 @ 0x7f9fb220bd00] i16 v,h,dc,p: 30% 32% 9% 29%
  40. [libx264 @ 0x7f9fb220bd00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 25% 14% 6% 6% 6% 9% 7% 10%
  41. [libx264 @ 0x7f9fb220bd00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 21% 10% 7% 8% 8% 9% 7% 9%
  42. [libx264 @ 0x7f9fb220bd00] i8c dc,h,v,p: 45% 27% 19% 9%
  43. [libx264 @ 0x7f9fb220bd00] Weighted P-Frames: Y:16.7% UV:8.3%
  44. [libx264 @ 0x7f9fb220bd00] ref P L0: 8.3% 2.1% 50.0% 39.6%
  45. [libx264 @ 0x7f9fb220bd00] kb/s:1476.00
  46.  
  47. Attempting to just stream the video file, output by the first commandline above, is also unsuccessful(this works for a couple of videos i've ripped from youtube):
  48.  
  49. ffmpeg -re -i image_vid.mp4 -c copy -f flv rtmp://live-sjc.twitch.tv/app/$(cat ~/twitch_key)
  50.  
  51. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'image_vid.mp4':
  52. Metadata:
  53. major_brand : isom
  54. minor_version : 512
  55. compatible_brands: isomiso2avc1mp41
  56. encoder : Lavf56.36.100
  57. Duration: 00:00:26.00, start: 0.000000, bitrate: 352 kb/s
  58. Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480, 349 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
  59. Metadata:
  60. handler_name : VideoHandler
  61. [flv @ 0x7fe51af79ea0] Codec for stream 0 does not use global headers but container format requires global headers
  62. Output #0, flv, to 'rtmp://live-sjc.twitch.tv/app/live_94772137_zC3RWmdfCQFK9OKZN78x211LNtGrsL':
  63. Metadata:
  64. major_brand : isom
  65. minor_version : 512
  66. compatible_brands: isomiso2avc1mp41
  67. encoder : Lavf56.36.100
  68. Stream #0:0(und): Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 640x480, q=2-31, 349 kb/s, 30 fps, 30 tbr, 1k tbn, 15360 tbc (default)
  69. Metadata:
  70. handler_name : VideoHandler
  71. Stream mapping:
  72. Stream #0:0 -> #0:0 (copy)
  73. Press [q] to stop, [?] for help
  74. [flv @ 0x7fe51af79ea0] Failed to update header with correct duration.358.6kbits/s
  75. [flv @ 0x7fe51af79ea0] Failed to update header with correct filesize.
  76. frame= 780 fps= 30 q=-1.0 Lsize= 1124kB time=00:00:25.90 bitrate= 355.5kbits/s
  77. video:1108kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.407449%
Advertisement
Add Comment
Please, Sign In to add comment