Board index FlightGear Support Interfacing

Capture Video Doesn't work

Connecting two computers, using generic protocol, connecting with Matlab?

Capture Video Doesn't work

Postby dersh » Wed Jun 09, 2021 12:29 am

In the past I've been able to capture a video stream from FlightGear based on this:
https://wiki.flightgear.org/Phi#Motion_JPEG

So, I've just run fgfs with --httpd=5432
Then, I could run:
Code: Select all
ffmpeg  -i "http://localhost:5432/screenshot?window=WindowA&stream=y" -vcodec copy -f mjpeg test.mpeg

and capture a video. But, that is no longer working. Although, the issue shows up in ffmpeg, where it complains:

Code: Select all
[mpjpeg @ 0x7f87cb00dc00] Unexpected Content-Type : image/jpg
[mpjpeg @ 0x7f87cb00dc00] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown)): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, mpjpeg, from 'http://localhost:5432/screenshot?window=WindowA&stream=y':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: mjpeg, none(bt470bg/unknown/unknown), 25 tbr, 25 tbn, 25 tbc
Output #0, mjpeg, to 'test.mpeg':
Output file #0 does not contain any stream


I can still see connect with Phi, so I know that FlightGear and that seems to be working. It seems most likely that there has been a change in how FlightGear handles streaming video. Although, it could also be a problem with FFmpeg?

Any ideas? What I'm trying to do is just to capture a video file from FG.

Thanks,
dersh
 
Posts: 11
Joined: Fri Sep 16, 2011 10:19 pm

Re: Capture Video Doesn't work

Postby Hooray » Wed Jun 09, 2021 7:18 am

I'd suggest to try another video player first, to be sure that this isn't specific to your current one - for instance, maybe you removed some required codecs accidentally during some system/driver upgrade ?

VLC works normally really for all sorts of streams/streaming.

Once you have tried different capturing methods and if the problem persists, we can revisit the FlightGear side of things.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Capture Video Doesn't work

Postby dersh » Wed Jun 09, 2021 2:49 pm

I just tried VLC and it is also not getting data. It is seeing the stream, but not any video. So, it seems to be reading in some data, but not finding any video frames in it, and not saving any data (except a 160 byte file). So, it seems like some of the header or other encoding information is no longer showing up correctly in the stream?
dersh
 
Posts: 11
Joined: Fri Sep 16, 2011 10:19 pm

Re: Capture Video Doesn't work

Postby V12 » Sun Jun 27, 2021 11:17 am

Use OBS. Very configurable and easy to use.
Fly high, fly fast - fly Concorde !
V12
 
Posts: 2757
Joined: Thu Jan 12, 2017 5:27 pm
Location: LZIB
Callsign: BAWV12

Re: Capture Video Doesn't work

Postby Johan G » Sun Jun 27, 2021 5:39 pm

Ditto. OBS Studio (Open Broadcaster Software Studio) works very well here as well.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Capture Video Doesn't work

Postby dersh » Sun Jun 27, 2021 7:48 pm

I just tried OBS. I used the Browser input and a url of http://localhost:5432/screenshot?window ... A&stream=y All it seems to capture is a single frame.
So, it still seems like something is not correct with how flightgear is outputting frames on httpd. I can do screen captures in a few different ways (Quicktime, OBS etc).
dersh
 
Posts: 11
Joined: Fri Sep 16, 2011 10:19 pm

Re: Capture Video Doesn't work

Postby wkitty42 » Sun Jun 27, 2021 8:14 pm

AFAIK, Phi only generates image files of the current sim screen... JPG IIRC... and it does them limited to the set delay value in the page... i've not been able to get it to generate any faster than one screen every 10 seconds IIRC... maybe every 5 seconds... it has been a while since i tried, though... i generally use it to view the current flight screen from another system when i show folks what i'm doing... i have not tried it with my new, much faster, gaming system, though...

you can look through the Phi code in your fgdata and see if you can find something that may be wrong or typoed... be aware that there are some files in there that are old leftovers that have not been removed for various reasons...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Capture Video Doesn't work

Postby Johan G » Mon Jun 28, 2021 12:55 pm

dersh wrote in Wed Jun 09, 2021 12:29 am:In the past I've been able to capture a video stream from FlightGear based on this:
https://wiki.flightgear.org/Phi#Motion_JPEG

dersh wrote in Sun Jun 27, 2021 7:48 pm:I just tried OBS. I used the Browser input and a url of http://localhost:5432/screenshot?window ... A&stream=y All it seems to capture is a single frame.
So, it still seems like something is not correct with how flightgear is outputting frames on httpd.

Have you tried using Window Capture or Screen Capture instead of Browser as source? (I use window capture.)
dersh wrote in Sun Jun 27, 2021 7:48 pm:I can do screen captures in a few different ways (Quicktime, OBS etc).

Does that mean you have been able to capture video?
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Capture Video Doesn't work

Postby dersh » Mon Jun 28, 2021 2:54 pm

Yes, I can just do a screen capture of any screen, FlightGear or other, and that does work.
But, in the past FlightGear was able to output a stream of motion jpegs and ffmpeg could directly capture those. It seems like that feature no longer works.
If I get the chance, I will look through the code.
dersh
 
Posts: 11
Joined: Fri Sep 16, 2011 10:19 pm

Re: Capture Video Doesn't work

Postby wkitty42 » Mon Jun 28, 2021 4:28 pm

dersh wrote in Sun Jun 27, 2021 7:48 pm:I just tried OBS. I used the Browser input and a url of http://localhost:5432/screenshot?window=WindowA&stream=y All it seems to capture is a single frame.

i don't know where you got that link from... when i use Phi's screenshot tab in the interface, it goes to (eg) http://myFGsystem:5500/#Simulator/Screenshot which emits one jpg file every 5 seconds... if i click on one of those images and select view image, the url changes to (eg) http://myFGsystem:5500/screenshot?type=jpg&t=1624893287409 which i've not been aware of before... adjusting that slightly, based on your link, i do get a stream of jpgs in my browser... it flashes like crazy but seems to work... i removed the window parameter and the stream of images smoothed out but was still flashy... i don't know but i suspect that ffmpeg should still be able to work with it... i think the key is the "type=jpg" part... so maybe you might try these links and see if one of them works for you?

http://localhost:5432/screenshot?type=jpg&window=WindowA&stream=y
http://localhost:5432/screenshot?type=jpg&stream=y

note that i have disabled automatic URL parsing by the forum software in this post so you should have to copy the links manually and paste them into your browser to test them...
i should also note that this is done with the latest Next branch of the sim so it is the very latest code available...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Capture Video Doesn't work

Postby dersh » Mon Jun 28, 2021 5:48 pm

That link is mentioned on the Phi page about "Motion JPEG"

https://wiki.flightgear.org/Phi

Although, I think that I had seen it before on other video capture information about FlightGear.
I'll a few versions.
dersh
 
Posts: 11
Joined: Fri Sep 16, 2011 10:19 pm

Re: Capture Video Doesn't work

Postby wkitty42 » Mon Jun 28, 2021 7:20 pm

ahhh! ok... i was just coming back to write that i've spent the last few hours mucking about trying to get this to work... apparently it is possible to crash something in FG so nothing is output when doing this but i did finally realize that and restarted FG at which point i was able to grab mjpeg data and save it to a file... it is grainy and i had to force wall clock time stamps to get (eg) accurate 15 seconds of video... otherwise it would take like 2+ minutes for 15 seconds and the playback was really fast... i don't know anything about this stuff but some tweaking is needed somewhere and whatever bug(s) i triggered when i was testing also need to be found and stomped out but that'll have to come later...

so FWIW: here's the ffmpeg command line i used...
Code: Select all
ffmpeg -y -report -loglevel debug -f mjpeg -use_wallclock_as_timestamps 1 -i "http://myFGsystem:5500/screenshot?stream=y" -t 15 FGTest.mpg

specifically i had to:
1. force mjpeg with "-f mjpeg"
2. force wall clock with "-use_wallclock_as_timestamps 1" for accurate recording length of 15 seconds

i also used -report to get a log and i forced the debug logging so i could see on the screen when things started working as desired... this after a couple of hours of nothing being recorded until i finally restarted FG... i have a log ffmpeg log file if you're interested in seeing it... apparently FG is spewing a LOT of frames that ffmpeg is detecting as dupes... and there's also something about buffer underruns but i haven't taken the time to try to determine the proper buffer size needed as this was just a fun experiment since you got my curiosity up about it ;)

i will note that my FG is set to 2560x1600 resolution and is being run in a window on a 4k monitor via an RTX2060 GPU... during this testing, FG was running at KRDU with OSM data enabled and was averaging 30fps consistently at 1500ASL in the UFO with it spinning in place at one right-arrow speed (easiest way to describe it)...

whatever the bugs are i've stumbled across, FG terminates with a core dump... sometimes it does that by itself and other times when i exit the sim via ESC and Enter... i did have it hang on exit with a thread still running one time when i exited while ffmpeg was still recording... so apparently there's something in the web server stuff that needs some love and attention...

i should also note that i was testing this with FG on one system and recording via ffmpeg on another system...

so anyway, there it is... it does work but there may be problems encountered...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Capture Video Doesn't work

Postby dersh » Mon Jun 28, 2021 9:22 pm

Thanks. ffmpeg needs the -f flag before the -i input flag or it doesn't seem to apply it.
dersh
 
Posts: 11
Joined: Fri Sep 16, 2011 10:19 pm

Re: Capture Video Doesn't work

Postby wkitty42 » Mon Jun 28, 2021 10:37 pm

correct...

could you also share your ffmpeg command line? i'd like to see how it works over here on my setup... see if it is any better than what i was able to get with the fairly simplistic ones i was trying to work with...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Capture Video Doesn't work

Postby dersh » Tue Jun 29, 2021 2:16 am

Simplistic seems to work. I did the same thing that you had done, and it works:
ffmpeg -y -f mjpeg -use_wallclock_as_timestamps 1 -i "http://localhost:5432/screenshot?stream=y" -t 10 FGTest.mpg
dersh
 
Posts: 11
Joined: Fri Sep 16, 2011 10:19 pm

Next

Return to Interfacing

Who is online

Users browsing this forum: No registered users and 2 guests