Skip to content

Instantly share code, notes, and snippets.

@laurieainley
Last active May 24, 2024 12:08
Show Gist options
  • Save laurieainley/7663756 to your computer and use it in GitHub Desktop.
Save laurieainley/7663756 to your computer and use it in GitHub Desktop.
Live streaming from a GoPro Hero3 camera to RTMP server using FFmpeg
Basic Requirements:
Computer with wired and wireless connection
FFmpeg installation: http://www.ffmpeg.org/
GoPro Hero 3+: http://gopro.com/
RTMP server e.g. FMS (http://www.adobe.com/products/adobe-media-server-family.html) or CDN ingest point
Overview:
GoPro Hero3 cameras produce HLS streams which are consumed by control apps and their removeable monitor.
It's simple to take this stream and rebroadcast over RTMP by following the instructions below.
Hopefully there are also a lot more interesting use cases for this, but this should provide a starting
point.
Instructions:
1. Turn on WiFi on GoPro.
2. Connect to GoPro from computer over WiFi.
3. Determine IP address of GoPro camera by finding the default gateway for your wireless connection -
this is usually 10.5.5.9 but may differ. Guide for Windows / Mac here:
http://www.noip.com/support/knowledgebase/finding-your-default-gateway/. This can be achieved in a
similar way on Linux using the command ifconfig on the command line.
4. Browse to the IP address of the camera on port 8080 to ensure you can connect to it and it is
capable of streaming video over WiFi. You can do this by putting http://[IP]:8080 in a browser window,
where [IP] is the IP of the GoPro camera identified in step 3. You should see a directory listing if
connected successfully.
5. Once confirmed, in the command below replace [IP] for the IP address as above, and replace [RTMP]
with the URL to the entry point for your FMS server/CDN e.g. rtmp://myserver.com/stream/stream_name.
If authentication is required, apply it as username:password@ after the protocol,
e.g. rtmp://username:password@myserver.com/stream/stream_name.
ffmpeg -re -i http://[IP]:8080/live/amba.m3u8 -c copy -c:a aac -strict experimental -b:a 96k -ac 2
-ar 44100 -f flv "[RTMP] live=1"
6. Execute the command and verify playback.
@langemike
Copy link

Seems like when you use (digest) authenticated URLs it give's some URL parsing errors.
For example when i run:
ffmpeg -re -i http://10.5.5.9:8080/live/amba.m3u8 -c copy -c:a aac -strict experimental -b:a 96k -ac 2 -ar 44100 -f flv "rtmp://username123:passwordABC@mystreamingserver/live live=1"
I get the error:
Problem accessing the DNS. (addr: username123)
rtmp://username123:passwordABC@mystreamingserver/live live=1: Unknown error occurred

Weird! Cause the documentation says it support authenticated URLs. See: https://www.ffmpeg.org/ffmpeg-protocols.html#rtmp

@laurieainley
Copy link
Author

Sorry, completely missed this comment. I don't think I tried with authentication - I'm aware some live stream providers/applications offer different methods of authentication though, for example via a query string parameter rather than via username/password. What RTMP server are you using?

@eapostol
Copy link

Hello, I found this page via standard search :) I have been having issues getting the Gopro 2 HD connected to FMS via ffmpeg as described. FMS appears to receive the connection with the following command

ffmpeg -re -i http://10.5.5.9:8080/live/amba.m3u8 -c copy -c:a aac -strict experimental -b:a 96k -ac 2 -ar 44100 -f flv "rtmp://myserver/live02/sampleStream/ live=1"

My main.asc for the live02 application appears to invoke (the application.onconnect fires) and I have additional methods which run as well. But in the command prompt window where ffmpeg is invoked, I get "Operation not permitted" error:

[applehttp @ 01D19500] Estimating duration from bitrate, this may be inaccurate
Input #0, applehttp, from 'http://10.5.5.9:8080/live/amba.m3u8':
Duration: N/A, start: 786.684900, bitrate: N/A
Stream #0:0: Video: h264 (Main) (HDMV / 0x564D4448), yuv420p, 432x240 [SAR 1
:1 DAR 9:5], 29.97 tbr, 90k tbn, 59.94 tbc
RTMP_ReadPacket, failed to read RTMP packet header
rtmp://myserver/live02/sampleStream/ live=1: Operation not permitted

Is there something I need to modify in the ffmpeg command invocation to get it working? Would appreciate any advice...soooo close. thanks!

@dakser
Copy link

dakser commented Jul 4, 2016

Hi, excuse me, how much quality could be expected using this method? Thanks in advance.

@FREDI5
Copy link

FREDI5 commented Sep 14, 2016

Check this article I think it will helps you about how to live streaming Via GoPro - https://www.yatko.com/live-streaming/gopro-live-streaming

@thebestapp
Copy link

thebestapp commented Sep 15, 2016

Can this tutorial about GoPro livestreaming really works? This is the link that I found -

@gogachinchaladze
Copy link

Hello, thanks for great tutorial!

I just have one question. If you are connected to gopro wifi, how can one access the rtmp on non-local server or resolve the DNS?

@sanat94
Copy link

sanat94 commented Jun 8, 2018

I get HTTP error 404 Not Found
http://10.5.5.9:8080/live/amba.m3u8: Server returned 404 not found

Please help me with this error.

@oneindelijk
Copy link

@sanat94
Check the following:

  1. are you connected directly to the Hero3's access point ?
  2. did your pc get an ip addres in the range 10.5.5.x ?
    (check this on windows in the terminal by typing 'ipconfig' or on linux 'ip addr' or on mac 'ifconfig')
  3. if you didn't you might have to manually supply an ip address (find howto's on the internet)
  4. if you did, try 'ping 10.5.5.9' or do a full network scan (nmap, netscanner, netdiscover) to find out if the Hero3 might be at a different ip address.
  5. make sure your pc doesn't have the same ip address as the Hero3
  6. make sure the main Cherokee page @ http://10.5.5.9:8080 is working...

@WHYDLM
Copy link

WHYDLM commented Apr 9, 2020

Hello,

I got a bit confused about the RTMP part, can't we just open the video flux in VLC ?
I'm a newbie so please excuse me...

Thanks you

@laurieainley
Copy link
Author

@WHYDLM This gist was written with rebroadcasting the feed as a live stream for distribution to a wider audience in mind - if you want to just monitor the output locally, then I believe you can just connect to it by its IP in VLC e.g. http://10.5.5.9:8080/live/amba.m3u8. Apologies I can't remember precisely, this was written 6 years ago.

@WHYDLM
Copy link

WHYDLM commented Apr 9, 2020

@laurieainley Hey thanks you very much, that's working !
Latency is high but for my use is ok.
Thanks you very much again !

@laurieainley
Copy link
Author

@WHYDLM no problem, happy to hear this is still useful after so long! Are you using this with a GoPro Hero 3?

@StanYago
Copy link

StanYago commented Jul 8, 2020

Worked for me on GoPro Hero 3, thank you! Just using the following command
ffplay -i http://10.5.5.9:8080/live/amba.m3u8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment