Please select To the mobile version | Continue to access the desktop computer version

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
View: 1657|Reply: 3

Mini tutu: almost real time video srteaming between two orange pi one / PC

[Copy link]

5

Threads

34

Posts

151

Credits

Registered member

Rank: 2

Credits
151
Post time 2019-4-23 23:12:45 | Show all posts |Read mode
Edited by DoubleHP at 2019-4-24 03:05

Hello.

I am mid step in some project. It's time to publish some tips.

Final goal: build a dash camera system for my car.

Status of the day: recording live stream to disk, and network diffusion. Lag is 2.5s.

After digging many things, Raspi tools are not available on Orange Pis. Mplayer sux. So I ended up with the only tool that can read the camera properly: motion.

Hardware:
Orange Pi One with CSI cam and HDMI monitor.

https://www.aliexpress.com/item/Orange-Pi-One-SET-9-Orange-Pi-One-and-Camera-Camera-with-wide-angle-lens-for/32660642513.html?spm=a2g0s.9042311.0.0.27424c4dE39tpD
set 9

https://www.aliexpress.com/item/3-5-inch-LCD-HDMI-USB-Touch-Screen-Real-HD-1920x1080-LCD-Display-Py-for-Raspberri/32818537950.html?spm=a2g0s.9042311.0.0.27424c4dE39tpD
https://www.aliexpress.com/item/raspberry-pi-3-5-inch-HDMI-LCD-touchscreen-touch-screen-60-fps-high-speed-better-480/32819353553.html?spm=a2g0s.9042311.0.0.27424c4dE39tpD

Software configuration:
- Armbian_5.75_Orangepione_Ubuntu_xenial_default_3.4.113_desktop (full details here : http://www.orangepi.org/orangepi ... ead&tid=4270&extra= ). This is the ONLY Linux image that can work on opiOne+CSI as of today, with ubuntu_lxde_desktop_OrangePipc_v0_9_1.img.xz . For now, 4.19 does not support CSI; I have read 4.21 may bring CSI in ... but the source is uncertain.
- motion
- ffmpeg

5

Threads

34

Posts

151

Credits

Registered member

Rank: 2

Credits
151
 Author| Post time 2019-4-23 23:38:11 | Show all posts
Edited by DoubleHP at 2019-4-23 23:58

Major points:
- control recording of pictures on disk with "output_pictures" (I disabled them to not kill my SD; I will re-enable them later when I receive my High Endurance uSD, a model specific to NVRs)
- control stream diffusion over network with "stream_localhost"
- 'motion -s' will produce normal image files, but ghost/black network video.

Once this conf is set, run the server simply: 'motion -n'

And the client: ffplay -f mjpeg -probesize 32 -i "http://192.168.0.2:8081/"
You can also use VLC as client, but mplayer does not work.

When server dies, ffplay does not suicide; when server comes back; client is stuck on old image. To kill the client, I run this test in a look:
echo -n "" | telnet localhost 8081 2>/dev/null | grep -q "Escape character is" || kill_ffplay.sh

5

Threads

34

Posts

151

Credits

Registered member

Rank: 2

Credits
151
 Author| Post time 2019-4-23 23:34:42 | Show all posts
Edited by DoubleHP at 2019-4-23 23:56

Here are the changes I made in /etc/motion/motion.conf :

  1. root@orangepione:/etc/motion# diff motion.conf.orig  motion.conf
  2. 87c87,88
  3. < rotate 0
  4. ---
  5. > #rotate 0
  6. > rotate 180
  7. 90c91,92
  8. < width 320
  9. ---
  10. > #width 320
  11. > width 640
  12. 93c95,96
  13. < height 240
  14. ---
  15. > #height 240
  16. > height 480
  17. 97c100,101
  18. < framerate 2
  19. ---
  20. > #framerate 2
  21. > framerate 5
  22. 173c177,178
  23. < threshold 1500
  24. ---
  25. > #threshold 1500
  26. > threshold 1
  27. 222c227
  28. < post_capture 0
  29. ---
  30. > post_capture 10
  31. 230c235,236
  32. < event_gap 60
  33. ---
  34. > #event_gap 60
  35. > event_gap 120
  36. 234c240
  37. < max_movie_time 0
  38. ---
  39. > max_movie_time 600
  40. 250c256,257
  41. < output_pictures on
  42. ---
  43. > #output_pictures on
  44. > output_pictures off
  45. 253a261
  46. > #output_debug_pictures on
  47. 256a265
  48. > quality 95
  49. 270c279,280
  50. < ffmpeg_output_movies on
  51. ---
  52. > ffmpeg_output_movies off
  53. > #ffmpeg_output_movies off
  54. 328a339
  55. > #use_extpipe on
  56. 332c343
  57. < ;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me-vf denoise3d=16:12:48:4,pp=lb -of   avi -o %f.avi - -fps %fps
  58. ---
  59. > #;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 -x264encopts bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me -vf denoise3d=16:12:48:4,pp=lb -of   avi -o %f.avi - -fps %fps
  60. 360c371,372
  61. < locate_motion_mode off
  62. ---
  63. > #locate_motion_mode off
  64. > locate_motion_mode preview
  65. 436c448,449
  66. < picture_filename %v-%Y%m%d%H%M%S-%q
  67. ---
  68. > #picture_filename %v-%Y%m%d%H%M%S-%q
  69. > picture_filename %Y-%m-%d_%H-%M-%S_%q
  70. 467c480,481
  71. < stream_quality 50
  72. ---
  73. > #stream_quality 50
  74. > stream_quality 90
  75. 471c485,486
  76. < stream_motion off
  77. ---
  78. > #stream_motion off
  79. > stream_motion 1
  80. 474c489,490
  81. < stream_maxrate 1
  82. ---
  83. > #stream_maxrate 1
  84. > stream_maxrate 10
  85. 477c493,494
  86. < stream_localhost on
  87. ---
  88. > #stream_localhost on
  89. > stream_localhost off
  90. 503a521
  91. > #webcontrol_localhost off
Copy the Code

5

Threads

34

Posts

151

Credits

Registered member

Rank: 2

Credits
151
 Author| Post time 2019-4-23 23:35:02 | Show all posts
Edited by DoubleHP at 2019-4-23 23:53

Or, the stripped file:

  
  1.   root@orangepione:/etc/motion# cat motion.conf | grep -v -e "^#" -e ";" | sort | uniq

  2.     auto_brightness off
  3.     brightness 0
  4.     contrast 0
  5.     daemon on
  6.     despeckle_filter EedDl
  7.     emulate_motion off
  8.     event_gap 120
  9.     ffmpeg_bps 500000
  10.     ffmpeg_deinterlace off
  11.     ffmpeg_output_debug_movies off
  12.     ffmpeg_output_movies off
  13.     ffmpeg_timelapse 0
  14.     ffmpeg_timelapse_mode daily
  15.     ffmpeg_variable_bitrate 0
  16.     ffmpeg_video_codec mpeg4
  17.     framerate 5
  18.     frequency 0
  19.     height 480
  20.     hue 0
  21.     input -1
  22.     ipv6_enabled off
  23.     lightswitch 0
  24.     locate_motion_mode preview
  25.     locate_motion_style box
  26.     logfile /var/log/motion/motion.log
  27.     log_level 6
  28.     log_type all
  29.     max_movie_time 600
  30.     minimum_frame_time 0
  31.     minimum_motion_frames 1
  32.     movie_filename %v-%Y%m%d%H%M%S
  33.     netcam_keepalive off
  34.     netcam_tolerant_check off
  35.     noise_level 32
  36.     noise_tune on
  37.     norm 0
  38.     output_debug_pictures off
  39.     output_pictures off
  40.     picture_filename %Y-%m-%d_%H-%M-%S_%q
  41.     picture_type jpeg
  42.     post_capture 10
  43.     pre_capture 0
  44.     process_id_file /var/run/motion/motion.pid
  45.     quality 75
  46.     quality 95
  47.     quiet on
  48.     rotate 180
  49.     roundrobin_frames 1
  50.     roundrobin_skip 1
  51.     saturation 0
  52.     sdl_threadnr 0
  53.     setup_mode off
  54.     smart_mask_speed 0
  55.     snapshot_filename %v-%Y%m%d%H%M%S-snapshot
  56.     snapshot_interval 0
  57.     stream_auth_method 0
  58.     stream_limit 0
  59.     stream_localhost off
  60.     stream_maxrate 10
  61.     stream_motion 1
  62.     stream_port 8081
  63.     stream_quality 90
  64.     switchfilter off
  65.     target_dir /var/lib/motion
  66.     text_changes off
  67.     text_double off
  68.     text_event %Y%m%d%H%M%S
  69.     text_right %Y-%m-%d\n%T-%q
  70.     threshold 1
  71.     threshold_tune off
  72.     timelapse_filename %Y%m%d-timelapse
  73.     track_auto off
  74.     track_iomojo_id 0
  75.     track_move_wait 10
  76.     track_speed 255
  77.     track_step_angle_x 10
  78.     track_step_angle_y 10
  79.     track_stepsize 40
  80.     track_type 0
  81.     use_extpipe off
  82.     v4l2_palette 17
  83.     videodevice /dev/video0
  84.     webcontrol_html_output on
  85.     webcontrol_localhost on
  86.     webcontrol_port 8080
  87.     width 640
Copy the Code

You have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2020-7-8 09:19 GMT+8 , Processed in 0.029041 second(s), 23 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list