LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Get image (jpg) from a Java live feed. (https://www.linuxquestions.org/questions/linux-general-1/get-image-jpg-from-a-java-live-feed-4175505342/)

dingo-den 05-17-2014 10:46 PM

Get image (jpg) from a Java live feed.
 
I have a web site that I capture an image every minute and put it on my site and then at midnight turn it into a movie.

Since the ISS is now streaming a live feed I thought it would be good to get am image from there and put it on my site and the next day could see a timelapse of the day.

This is where the live feed is http://www.ustream.tv/channel/live-iss-stream/theater

Just a thought if anyone knows of a way that would be great.

The server I have is Debian 6 64 bit and the scripts I use are either Bash or PHP.

jefro 05-19-2014 03:25 PM

I'm sure this is the long way around but

cron that runs capture from command line and increments file names.

gnome-screenshot

Or

imagemagick using import


I'd bet there are better ways.

arizonagroovejet 05-19-2014 03:49 PM

Looks like a Flash stream to me. I'm thinking maybe something using rtmpdump to capture say 1 second of video then shoving that through ffmpeg to extract an image. Maybe. The stream just shows a solid blue right now so not the best to experiment with.

arizonagroovejet 05-19-2014 04:38 PM

This does one image per second. Don't have patience to try one per minute. ;)
Code:

ffmpeg -i "http://sjc-uhls-vip04.ustream.tv/watch/playlist.m3u8?cid=9408562&appType=11&appVersion=2&locks=97d170e1550eee4afc0af065b78cda302a97674c" -f image2 -vf fps=fps=1 img%06d.jpg
Also
Code:

ffmpeg -i "http://sjc-uhls-vip02.ustream.tv/watch/playlist.m3u8?cid=17074538&appType=11&appVersion=2&locks=97d170e1550eee4afc0af065b78cda302a97674c"  -f image2 -vf fps=fps=1 img%06d.jpg
which is http://www.ustream.tv/channel/iss-hdev-payload

How?

1] Get Firefox to pretend it's an iPad.
2] Look at http headers.

See also
https://addons.mozilla.org/en-US/fir...gent-switcher/
https://addons.mozilla.org/en-US/fir...-http-headers/
https://trac.ffmpeg.org/wiki/Create%...%20the%20video

arizonagroovejet 05-19-2014 04:59 PM

It occurs to me that a problem with that method is that you have to stream the video all day to get the images. That'll suck bandwidth, which may or may not be an issue for you, and there's the risk ffmpeg will crap out at some point.

Better is something you can call from cron once a minute. I'm thinking this
Code:

ffmpeg  -i "http://sjc-uhls-vip04.ustream.tv/watch/playlist.m3u8?cid=9408562&appType=11&appVersion=2&locks=97d170e1550eee4afc0af065b78cda302a97674c"  -ss 00:00:05 -f image2 -vframes 1 $(date +%s).jpg
In theory that will grab a frame five seconds in to the stream (to give it time to get going, otherwise image is always grey) and save it as an image the name of which is a function of the current time. It seems to work. The stream is a crappy purple/black video right now though and the iss-hdev-payload is just black.

dingo-den 05-19-2014 08:29 PM

Quote:

Originally Posted by arizonagroovejet (Post 5173808)
It occurs to me that a problem with that method is that you have to stream the video all day to get the images. That'll suck bandwidth, which may or may not be an issue for you, and there's the risk ffmpeg will crap out at some point.

Better is something you can call from cron once a minute. I'm thinking this
Code:

ffmpeg  -i "http://sjc-uhls-vip04.ustream.tv/watch/playlist.m3u8?cid=9408562&appType=11&appVersion=2&locks=97d170e1550eee4afc0af065b78cda302a97674c"  -ss 00:00:05 -f image2 -vframes 1 $(date +%s).jpg
In theory that will grab a frame five seconds in to the stream (to give it time to get going, otherwise image is always grey) and save it as an image the name of which is a function of the current time. It seems to work. The stream is a crappy purple/black video right now though and the iss-hdev-payload is just black.

That seems to work except the image is very small and there is this message in red when run on the command line.


[buffer @ 0x25cfd80] Buffering several frames is not supported. Please consume all available frames before adding a new one.


Will have to try and find a way to make the image higher quality ?? The image I am using now
is about 138325 May 19 18:12 img-1096.jpg and these ones are a lot smaller 4036 May 19 18:04 1400547844.jpg

I added -s 640x480 to the output to make it a bit bigger.

This is the result
http://dingo-den.com/index.php?nav=cam1

dingo-den 05-19-2014 09:13 PM

I also make a video at midnight and would like to try and get a better quality. Do you know if I can change this to make the video quality better ?

/usr/bin/ffmpeg -y -i img-%d.jpg -an -qscale 1 -vcodec msmpeg4v2 webcam2-video-hi.avi

I also produce a mp4 from the avi later to upload to youtube and it would be good to make that a better quality as well ?

ffmpeg -i webcam2-video-hi.avi -acodec libfaac -ab 128k -vcodec libx264 webcam2-video-hi.mp4

I have tried a lot of things but can;t get a nice crisp image

arizonagroovejet 05-20-2014 02:48 AM

Quote:

Originally Posted by dingo-den (Post 5173875)
That seems to work except the image is very small and there is this message in red when run on the command line.


[buffer @ 0x25cfd80] Buffering several frames is not supported. Please consume all available frames before adding a new one.

If things work, I'd just ignore that. ffmpeg will complain about all sorts of things, whether those things matter or not is another matter. ;)
Quote:

Originally Posted by dingo-den (Post 5173875)
Will have to try and find a way to make the image higher quality ??

I just grabbed the first stream I found whilst pretending to be an iPad. Maybe you can find a higher quality stream.


Quote:

Originally Posted by dingo-den (Post 5173896)
I also make a video at midnight and would like to try and get a better quality. Do you know if I can change this to make the video quality better ?

/usr/bin/ffmpeg -y -i img-%d.jpg -an -qscale 1 -vcodec msmpeg4v2 webcam2-video-hi.avi

Given the quality of the source material I think trying to get ffmpeg make a better quality video is pointless. The best way to get a better quality video is to have better quality source material.

Quote:

Originally Posted by dingo-den (Post 5173896)
I also produce a mp4 from the avi later to upload to youtube and it would be good to make that a better quality as well ?

ffmpeg -i webcam2-video-hi.avi -acodec libfaac -ab 128k -vcodec libx264 webcam2-video-hi.mp4

I have tried a lot of things but can;t get a nice crisp image

The obvious way to get better quality is by making the mp4 from the original source images, not from the avi. Given the quality of the source material you probably won't be able to see the difference though. You aren't going to get a nice crisp image because your source material is fuzzy blurry images.

dingo-den 05-20-2014 09:42 AM

OK thanks for your help it is appreciated.

dingo-den 05-20-2014 09:22 PM

One more thing you might help me with. I just looked at the first video of the ISS that I made and it goes really really quick. I use this command to make the video, what can I add to make it play slower.

/usr/bin/ffmpeg -y -i img-%d.jpg -an -qscale 1 -vcodec msmpeg4v2 webcam2-video-hi.avi


Found the answer should have googled more than I did.

/usr/bin/ffmpeg -r 2 -y -i img-%d.jpg -an -qscale 1 -vcodec msmpeg4v2 -r 35 webcam2-video-hi.avi


All times are GMT -5. The time now is 11:39 AM.