Discussion:
[Libav-user] Decoding a H.264 stream from TCP
Jeremy Graham
2012-06-21 20:43:46 UTC
Permalink
Hello, everyone:

I am working with the Parrot AR.Drone 2.0. I don't know if anyone is
familiar with that device, but to make a long story short, it transmits
video data from an on-board camera via TCP and the video is encoded with
H.264. I am trying to make a program that continuously receives the TCP
packets from the drone and decodes them in order to get the images sent
from the camera.

Could anyone steer me in the possibly correct direction toward
accomplishing this goal? I tried to do it based off of code like what
can be found here
http://libav.org/doxygen/master/libavcodec_2api-example_8c-example.html
or here http://dranger.com/ffmpeg/tutorial01.html. However, I am
getting nowhere. I guess getting frame data from network packets is not
like getting it from an actual video file.

I am a complete novice when it comes to video, codecs, and streaming
video over a network. If someone could help me figure out where to even
begin I would be so appreciative.

Thanks!
Carl Eugen Hoyos
2012-06-22 07:55:23 UTC
Permalink
Post by Jeremy Graham
I am working with the Parrot AR.Drone 2.0. I don't know if anyone is
familiar with that device, but to make a long story short, it transmits
video data from an on-board camera via TCP and the video is encoded with
H.264.
Did you try ffmpeg -i http://xxxx ?
Does it work?

Carl Eugen
Jeremy Graham
2012-06-22 14:43:42 UTC
Permalink
I typed in the following command while the drone was streaming data:

***@jeramboquai-NV55S:~/Documents$ ffmpeg -i http://192.168.1.1:5555

It immediately output this and then paused, I assume to attempt to
interpret the stream:

ffmpeg version git-2012-06-20-b2e2287 Copyright (c) 2000-2012 the FFmpeg
developers
***@jeramboquai-NV55S:~/Documents$ ffmpeg -i
http://192.168.1.1:5555
ffmpeg version git-2012-06-20-b2e2287 Copyright (c) 2000-2012 the FFmpeg
developers
built on Jun 20 2012 17:25:25 with gcc 4.6.3
configuration: --enable-gpl --enable-libfaac --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora
--enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree
--enable-version3 --enable-x11grab
libavutil 51. 59.100 / 51. 59.100
libavcodec 54. 27.100 / 54. 27.100
libavformat 54. 9.100 / 54. 9.100
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 82.100 / 2. 82.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100

When I stopped the stream it then output this:

[h264 @ 0xada1260] non-existing PPS referenced
[h264 @ 0xada1260] non-existing PPS 0 referenced
[h264 @ 0xada1260] decode_slice_header error
[h264 @ 0xada1260] no frame!
[h264 @ 0xad993e0] max_analyze_duration 5000000 reached at 5000000
[h264 @ 0xad993e0] Estimating duration from bitrate, this may be inaccurate

...and then after a few seconds, it output this and quit.

Input #0, h264, from 'http://192.168.1.1:5555':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p, 640x360, 25 fps, 25
tbr, 1200k tbn, 50 tbc
At least one output file must be specified


It appears that it tried to decode SOMETHING, but couldn't. So no, it
apparently didn't work. :(
Post by Carl Eugen Hoyos
Post by Jeremy Graham
I am working with the Parrot AR.Drone 2.0. I don't know if anyone is
familiar with that device, but to make a long story short, it transmits
video data from an on-board camera via TCP and the video is encoded with
H.264.
Did you try ffmpeg -i http://xxxx ?
Does it work?
Carl Eugen
_______________________________________________
Libav-user mailing list
http://ffmpeg.org/mailman/listinfo/libav-user
Carl Eugen Hoyos
2012-06-22 14:46:44 UTC
Permalink
Post by Jeremy Graham
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuv420p, 640x360, 25 fps, 25
tbr, 1200k tbn, 50 tbc
At least one output file must be specified
It appears that it tried to decode SOMETHING, but couldn't. So no, it
apparently didn't work. :(
Afaict, it works fine.
You can either specify an output file if you want to transcode
or use ffplay for playback.

Please do not top-post here.

Carl Eugen
Jeremy Graham
2012-06-22 20:02:29 UTC
Permalink
Hmm...using ffplay did open a window but nothing showed but an entirely
black image.

In either case, I was actually interested in decoding frames as they
appear in the network socket so that I can get the images from the
camera to do some real-time processing. With that in mind, would you
happen to have any advice?

My apologizes for the "top post". Just for my own information, is
top-posting where you quote a prior message in a thread in your response?

Thanks for your input too!
Michael Bradshaw
2012-06-22 20:12:21 UTC
Permalink
In either case, I was actually interested in decoding frames as they appear
in the network socket so that I can get the images from the camera to do
some real-time processing.  With that in mind, would you happen to have any
advice?
If you want to use libav* to decode the video in your own program, you
certainly can do that. When you open a "file" you pass it a URL (if
it's just a file on your local hard drive, you can pass something like
"video.mov" and it will open it with the file protocol). If your
"filename" was something like "http://192.168.1.1:5555" it should open
it just fine, and you can decode incoming frames like normal.
My apologizes for the "top post".  Just for my own information, is
top-posting where you quote a prior message in a thread in your response?
"top posting" is when you quote someone and put your response above
theirs (on top of theirs). Bottom posting (which is what's encouraged
on these mailing lists) is when you quote someone and put your
response below theirs (like Carl and I have done). (Relevant Wikipedia
article: http://en.wikipedia.org/wiki/Posting_style)

--mbradshaw
Jeremy Graham
2012-06-25 19:59:06 UTC
Permalink
Post by Michael Bradshaw
If you want to use libav* to decode the video in your own program, you
certainly can do that. When you open a "file" you pass it a URL (if
it's just a file on your local hard drive, you can pass something like
"video.mov" and it will open it with the file protocol). If your
"filename" was something like "http://192.168.1.1:5555" it should open
it just fine, and you can decode incoming frames like normal.
Interesting. This sounds like something to try. Are you referring to
using a URL in conjunction with a function like fopen or is there a
function specified somewhere in libav* that you had in mind?

Loading...