LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-17-2014, 10:46 PM   #1
dingo-den
Member
 
Registered: Aug 2005
Location: Apr-Oct Enderby, BC Canada Oct-Mar Somewhere warm
Distribution: Debian 6 and 7
Posts: 46

Rep: Reputation: 0
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.
 
Old 05-19-2014, 03:25 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
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.
 
Old 05-19-2014, 03:49 PM   #3
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
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.
 
Old 05-19-2014, 04:38 PM   #4
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
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
 
Old 05-19-2014, 04:59 PM   #5
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
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.
 
Old 05-19-2014, 08:29 PM   #6
dingo-den
Member
 
Registered: Aug 2005
Location: Apr-Oct Enderby, BC Canada Oct-Mar Somewhere warm
Distribution: Debian 6 and 7
Posts: 46

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by arizonagroovejet View Post
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
 
Old 05-19-2014, 09:13 PM   #7
dingo-den
Member
 
Registered: Aug 2005
Location: Apr-Oct Enderby, BC Canada Oct-Mar Somewhere warm
Distribution: Debian 6 and 7
Posts: 46

Original Poster
Rep: Reputation: 0
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

Last edited by dingo-den; 05-19-2014 at 09:23 PM.
 
Old 05-20-2014, 02:48 AM   #8
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
Quote:
Originally Posted by dingo-den View Post
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 View Post
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 View Post
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 View Post
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.
 
Old 05-20-2014, 09:42 AM   #9
dingo-den
Member
 
Registered: Aug 2005
Location: Apr-Oct Enderby, BC Canada Oct-Mar Somewhere warm
Distribution: Debian 6 and 7
Posts: 46

Original Poster
Rep: Reputation: 0
OK thanks for your help it is appreciated.
 
Old 05-20-2014, 09:22 PM   #10
dingo-den
Member
 
Registered: Aug 2005
Location: Apr-Oct Enderby, BC Canada Oct-Mar Somewhere warm
Distribution: Debian 6 and 7
Posts: 46

Original Poster
Rep: Reputation: 0
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

Last edited by dingo-den; 05-20-2014 at 11:25 PM. Reason: Found the answer
 
  


Reply

Tags
image, jpg, streaming



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Zoneminder 1.25.0 on CentOS 6.3 - black image without live feed deeonline Linux - Software 1 04-28-2013 04:32 AM
converting eps image to jpg DeepSeaNautilus Linux - Software 1 04-13-2009 10:20 PM
How to read jpg image in C waqasdaar Programming 8 03-01-2009 11:36 AM
convert image.png image.jpg changing colours MikeyCarter Linux - Software 1 11-17-2006 10:16 AM
Recording a Live Video Feed sonikntails Linux - Software 1 10-22-2002 05:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration