yqh1988 / ffmpeg4iphone

Automatically exported from code.google.com/p/ffmpeg4iphone
1 stars 0 forks source link

fixes for ffplay #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I tried to run the ffplay xcode project on my iPhone, and I got only sound
but no video. After googling around, it seems that it is a problem with SDL.
More precisely, in main.c, vp->bmp wasn't allocated after calling this
function.
vp->bmp = SDL_CreateYUVOverlay(is->video_st->codec->width,
                                   is->video_st->codec->height,
                                   SDL_YV12_OVERLAY,
                                   screen);
I think you also had this problem earlier, based on this post (I assume
it's the same Yonas :P):
http://www.nabble.com/libmpeg2-and-ffplay-broken-with-SDL-1.3-td21045319.html
Did you find the solution to this issue yet?

Original issue reported on code.google.com by ducn...@gmail.com on 15 Apr 2009 at 4:11

GoogleCodeExporter commented 8 years ago
Unfortunately, still broken. I haven't worked on ffplay since then. Were you 
able to
test the vp-bmp fix? I'd be uber happy if that was the only problem :)

Original comment by yonas.ya...@gmail.com on 15 Apr 2009 at 5:36

GoogleCodeExporter commented 8 years ago
You're right. To test, I added:

    if (!vp->bmp)
    {
        fprintf(stderr, "Error 1: %s\n", SDL_GetError());
        exit(1);
    }

which caught an error: "YUV overlays are not supported in OpenGL mode".

Original comment by yonas.ya...@gmail.com on 15 Apr 2009 at 8:00

GoogleCodeExporter commented 8 years ago
Do you have any pointers on how I can replace YUV layers with RGB ones?

Original comment by ducn...@gmail.com on 16 Apr 2009 at 9:53

GoogleCodeExporter commented 8 years ago
Not sure how to do that, but I found these related links:

http://article.gmane.org/gmane.comp.lib.sdl/29702
http://www.dranger.com/ffmpeg/tutorial08.html

Original comment by yonas.ya...@gmail.com on 16 Apr 2009 at 12:21

GoogleCodeExporter commented 8 years ago
So I changed dst_pix_fmt from PIX_FMT_YUV420P to PIX_FMT_RGB24, called 
sws_scale to
convert the src_frame into a RGB AVPicture. Then I used 
SDL_CreateRGBSurfaceFrom to
make a SDL_Surface from that picture and displayed it on screen with the 
combination
of SDL_DisplayFormat, SDL_BlitSurface and SDL_Flip.

The result: now I got the video images, but the quality is terrible (bad color 
and
the screen keeps blinking). Besides, the app crashes after playing for a few 
seconds.
I'm not a computer graphics guy so it's a bit tough for me to figure out the 
reasons.
Do you have a better approach to display a SDL_Surface on screen than using
SDL_BlitSurface and SDL_Flip?

Original comment by ducn...@gmail.com on 17 Apr 2009 at 1:10

GoogleCodeExporter commented 8 years ago
Awesome! :) Could you copy your ffplay.c to pastebin.com and send me the url? 

I don't know of a better way, but let's ask the ffmpeg-devel and SDL mailing 
lists.

Original comment by Yona...@gmail.com on 17 Apr 2009 at 10:35

GoogleCodeExporter commented 8 years ago
http://pastebin.com/m72856e01
I fixed the crash, but the video quality is still very bad (a bit clearer on
simulator but the blinking is still there). Maybe it has something to do with 
the
decoder.

Original comment by ducn...@gmail.com on 18 Apr 2009 at 9:38

GoogleCodeExporter commented 8 years ago
I've never been able to make an ffplay simulator project to compile...can you 
please
send me your copy?

Original comment by yonas.ya...@gmail.com on 19 Apr 2009 at 4:42

GoogleCodeExporter commented 8 years ago
Well in fact it's a friend of mine who compiled it for me so I don't really 
know how
he did it. I think he followed this blog post:
http://latenitesoft.blogspot.com/2008/10/iphone-programming-tips-building-unix.h
tml
but I'm not too sure. I only have the compiled libs if you want.

Original comment by ducn...@gmail.com on 20 Apr 2009 at 9:45

GoogleCodeExporter commented 8 years ago
I can compile the libraries for Mac OSX, which is what simulator uses, but I'm 
having
trouble with the XCode project. Could you send me your XCode project?

Original comment by yonas.ya...@gmail.com on 20 Apr 2009 at 4:16

GoogleCodeExporter commented 8 years ago
http://rapidshare.com/files/223890139/ffplay-simulator.zip.html
MD5: 4E8F364B4CC0FBA9D1495221438A536C 
This version of ffplay works very well for most videos in simulator. When 
ported to
iPhone, the image quality is acceptable for some videos  although the frame 
rate is
slow (I think because of the whole SDL_Surface -> openGL texture conversion), 
and it
doesn't work with MPEG-4 video codec.

My version of ffmpeg is different from yours, so there are a few slight 
modifications
in the method signature.

Original comment by ducn...@gmail.com on 21 Apr 2009 at 7:25

GoogleCodeExporter commented 8 years ago
It worked in the simulator and device. A sample m4v from apple.com had no 
problems.
M4V/MPG/WMV stuttered after a few seconds.

Keep up the awesome work!!

Original comment by yonas.ya...@gmail.com on 22 Apr 2009 at 5:06

GoogleCodeExporter commented 8 years ago
Thanks. 
How do I know when I reach the end of the movie/stream? It continues to play 
(image
stands still and weird sound), never gets out of the loop for(;;) in 
decode_thread. I
added the quit function to mouse down event so that I can quit manually, but 
I'd like
it to stop when the video is done.

Original comment by ducn...@gmail.com on 22 Apr 2009 at 11:22

GoogleCodeExporter commented 8 years ago
I think it's around line 1988:

if(url_feof(ic->pb)) { ...

Original comment by yonas.ya...@gmail.com on 22 Apr 2009 at 3:44

GoogleCodeExporter commented 8 years ago
I guess it's a bug. For a .m4v video that I tested, a SDL_QUIT event was sent 
at the
end of the video, so the do_exit() function was executed. But in another mp4 
video,
nothing was sent, so the video just hanged there.

Do your audio and video streams synced with each other?

Original comment by ducn...@gmail.com on 22 Apr 2009 at 4:08

GoogleCodeExporter commented 8 years ago
Yup, it's good before the stuttering/looping. I think m4v works well because the
iPhone normally works with m4v/3gp/etc, but not mpeg, wmv, etc. The hardware 
might
even be specialized for these codecs.

Original comment by yonas.ya...@gmail.com on 22 Apr 2009 at 4:17

GoogleCodeExporter commented 8 years ago
Yonas, I still have problem compiling the libs with optimization, perhaps 
that's the
reason why my streams are not synced and the frame rate is bad (even with m4v 
or any
format). I attached here my script and patch. Can you take a look, especially 
at the
arm optimization part? Or maybe can you send me the XCode project that you 
tested
with good result along with the libraries? Thanks.

Install script:
http://pastebin.com/m72de82f0
Patch:
http://pastebin.com/m6ee4b9cd

Original comment by ducn...@gmail.com on 22 Apr 2009 at 4:58

GoogleCodeExporter commented 8 years ago
I'm using the patch from the download section:

http://ffmpeg4iphone.googlecode.com/files/ffmpeg4iphone-svn-2009-30-01-v0.0.4.pa
tch
and
http://ffmpeg4iphone.googlecode.com/files/configure-iphone-v0.0.4

Your patch file looks like ffmpeg4iphone v0.0.4.

Compared to my configure script, I don't use these in ./configure:

--enable-hardcoded-tables --enable-swscale-alpha --disable-mmx2 --disable-neon 
--disable-yasm --disable-ipv6 --enable-network --enable-fastdiv
--enable-runtime-cpudetect

Original comment by yonas.ya...@gmail.com on 22 Apr 2009 at 5:08

GoogleCodeExporter commented 8 years ago
The libs:
http://rapidshare.com/files/224479147/ffmpeg-libs.tar.bz2.html

I'm using your ffplay project :)

Original comment by yonas.ya...@gmail.com on 22 Apr 2009 at 5:16

GoogleCodeExporter commented 8 years ago
or download from svn:

http://code.google.com/p/ffmpeg4iphone/source/browse/#svn/trunk

Original comment by yonas.ya...@gmail.com on 22 Apr 2009 at 5:21

GoogleCodeExporter commented 8 years ago
I've added you to the Project Members list. You should be able to use this 
project's svn.

Original comment by yonas.ya...@gmail.com on 22 Apr 2009 at 5:23

GoogleCodeExporter commented 8 years ago
Did you compile with the "armv6" optimization? I couldn't do it because the 
directive
ltorg didn't pass.

Using your libs, the image quality is even worse than what we had before (see 
the
image attached). I send you the whole XCode project along with the test video. 
To
config, you just change the "Headers Search Path", "Libraries Search Path" and 
"Other
Linker Flags" options in Project Properties.

Do you get good quality video with this test video?

http://rapidshare.com/files/224487986/ffplay-xproj.zip.html
MD5: 0E5F7A0F966D810F45CAE239576C3694 

Original comment by ducn...@gmail.com on 22 Apr 2009 at 5:46

Attachments:

GoogleCodeExporter commented 8 years ago
Found another forum about this:
http://74.125.95.132/search?q=cache:XlIG3deMmY0J:macgeeks.cn/bbs/viewtopic.php%3
Fid%3D3597+MPMoviePlayerController+mux&cd=1&hl=en&ct=clnk&gl=ca

Original comment by yonas.ya...@gmail.com on 22 Apr 2009 at 6:57

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Yea, I used armv6 optimizations. The ltorg error shouldn't show up if you used 
v0.0.4
patch. 

Original comment by yonas.ya...@gmail.com on 22 Apr 2009 at 8:19

GoogleCodeExporter commented 8 years ago
Alright, I tested with your XCode project and I get the same bad display.

Original comment by yonas.ya...@gmail.com on 22 Apr 2009 at 8:59

GoogleCodeExporter commented 8 years ago
Issue 7 has been merged into this issue.

Original comment by yonas.ya...@gmail.com on 25 Apr 2009 at 3:36

GoogleCodeExporter commented 8 years ago
So I continued to work on this issue last week, and it seems that the greeny 
distorts
come from arm optimization. I haven't found the solution yet though.

Have you seen this code: http://sites.google.com/site/mplayer4iphone/ ? They've
succeeded to port the mplayer to iPhone, and they used different optimization.

Original comment by ducn...@gmail.com on 29 Apr 2009 at 7:10

GoogleCodeExporter commented 8 years ago
Yea, I used that code for some of the ffmpeg porting :) mru (from ffmpeg-devel) 
and I
did the arm optimization port. I converted some videos to test the code, and it
seemed to work well, so I'm not sure why it would give problems here.

Original comment by yonas.ya...@gmail.com on 29 Apr 2009 at 8:15

GoogleCodeExporter commented 8 years ago
no sound SDL_OpenAudio error , sdl audio not support iphone? 
    if (SDL_OpenAudio(&wanted_spec, &spec) < 0) {
            fprintf(stderr, "SDL_OpenAudio: %s\n", SDL_GetError());

Original comment by daemon0...@yahoo.com.tw on 7 May 2009 at 2:57

GoogleCodeExporter commented 8 years ago
I now ran into the exact same problem (green/purple distorts in the video). You 
can
find my posting regarding this here:
http://lists.mplayerhq.hu/pipermail/ffmpeg-user/2009-September/022179.html. It
probably has something to do with the decoding of MPEG videos, but I'm not yet 
sure
what. Might be due to the ARM patches. Was any one of you able to solve this?

Original comment by yonil...@gmail.com on 30 Sep 2009 at 4:24

GoogleCodeExporter commented 8 years ago
Yoni,

I would post your question in ffmpeg-devel instead of ffmpeg-user. I'm not sure 
how
many developers/hackers monitor ffmpeg-user.

Original comment by yonas.ya...@gmail.com on 30 Sep 2009 at 4:32

GoogleCodeExporter commented 8 years ago
yonas.yanfa - Thanks, but now that we know the problem is related to 
ffmpeg4iphone I
thought I'd have a greater chance of finding my answer here. 
Do you still experience this? Can you provide more info on this issue (for 
example,
which video formats still do work)? I want to post on ffmpeg-devel but not 
exactly
sure where the problem comes from, you should be most familiar with the ARM 
specific
patches, so maybe you know better.

Original comment by yonil...@gmail.com on 30 Sep 2009 at 4:42

GoogleCodeExporter commented 8 years ago
Hi guys, I've came across with the same problem when I tried to decode a flv 
file a
while ago. It shouldn't be difficult to find out whether it coming from 
ffmpeg4iphone
patch or not. Just turn off the arm optimization and see if the picture is ok. 

Original comment by mahak...@gmail.com on 2 Oct 2009 at 4:25

GoogleCodeExporter commented 8 years ago
Any progress on this yet, I tried both an avi and an mpg and get the green 
distorted
image persumably caused by the sdl issues.

Original comment by michelle...@gmail.com on 13 Jan 2010 at 1:11

GoogleCodeExporter commented 8 years ago
I haven't heard of any progress yet. 

Original comment by yonas.ya...@gmail.com on 13 Jan 2010 at 8:13

GoogleCodeExporter commented 8 years ago
The ffplay-xproj is the problem , it doesn't work.

Build the latest sources and use options similar to these
./configure 
--cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-
darwin9-gcc-4.2.1 --as='gas-
preprocessor.pl 
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-
darwin9-gcc-4.2.1' --
sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk --
enable-cross-compile --target-os=darwin --arch=arm --cpu=arm1176jzf-s --disable-
iwmmxt --enable-armv5te --enable-armv6 --enable-static --disable-shared 
--disable-
debug --disable-stripping --disable-parsers --disable-decoders --disable-bsfs  
--
disable-protocols --disable-filters --disable-muxers --enable-muxer=mov 
--disable-
demuxers --disable-encoders --enable-encoder=mpeg4 --disable-network 
--disable-zlib -
-disable-bzlib --enable-protocol=file --enable-encoder=pcm_s16le 
--extra-cflags="-
O3 -ftree-vectorize -ffast-math"

Also this project has a nice demo player

openframeworks.cc • View topic - ofVideoPlayer on iphone??

Works with very little changes.

Download the 006 openframework for the iphone

download the videoplayer sample and put that in the apps/examples folder (that 
will 
insue search headers are correct)
build the xcode project.

Using the above info it should be possible to fix the ffplay-xproj.

We are working on a custom app, when I get a chance I will post our ffmpeg mods 
somewhere. That may include an updated xcodeproj

Original comment by michelle...@gmail.com on 14 Jan 2010 at 2:42

GoogleCodeExporter commented 8 years ago
Could you post them here as an attachment? 

Original comment by yonas.ya...@gmail.com on 14 Jan 2010 at 7:36

GoogleCodeExporter commented 8 years ago
Yes, when I have something stable.

right now I am trying to get past the sdl 1.3 not working with 3.0 or 3.1 
problem, the only way I see to do that is 
to just use open gl.

Really I must say this project is NOT VERY well supported. 

Original comment by michelle...@gmail.com on 15 Jan 2010 at 4:51

GoogleCodeExporter commented 8 years ago
which project? 

Original comment by yonas.ya...@gmail.com on 15 Jan 2010 at 6:09

GoogleCodeExporter commented 8 years ago
ffmpeg4iphone off course?? But that was frustrated me throwing in the towel 
after 
working god knows how many hours on this the last  couple days.

Good night sleep and all and I am willing to try again.

I can get video to work, but its not stable and breaks up constantly. Also not 
being 
able to compile under 3.1 or at least 3.2 is a huge problem.

I don't mind putting some time and resources into helping to fix this, I know 
how 
open source projects are, and finding the time to keep up with patches is not 
easy.

But I need to know some details.

Not exactly sure what compile options did you use to configure ffplay-xproj, I 
can't 
seem to duplicate what you have. Which would be a starting point. What dev kit 
build 
framework, os 2.2, os 3.0 or 3.1. 

If I build under os 3.1 and move libraries to xproj , I get errors because sdl 
layer 
is not compatable with 3.0.

If I build using 2.21 I get lousy video.

If I use the opencommonsframework and build a simple player, I get better video 
quality than ffplay , but it too breaks up. I want to try some arm 
optimizations and 
see if that help.

With ffplay I use --arch=c , at suggetion of ffmpeg-mail-list otherwise you get 
distorted green picture You can email me directly if you like. 
michelle@mooncatventures..com

Original comment by michelle...@gmail.com on 15 Jan 2010 at 3:24

GoogleCodeExporter commented 8 years ago
Honestly, I don't know much about video graphics/OpenGL, but I was sure a lot of
others do, so I posted XCode ffplay project for others to play with.

I'm sure a lot of people, including me, will appreciate your work on 
ffplay4iphone
when you get it to work, but in the mean time, if it's making you very 
frustrated,
maybe take a break from it for a while and come back with new energy. That's 
how I
managed to do ffmpeg4iphone....I couldn't do it the 1st, 2nd, or 3rd time, but 
after
letting it sit for 2+ months, I narrowed down the problem to exactly which files
needed patching and asked for help from ffmpeg developers (i.e. mru).

Y.

Original comment by yonas.ya...@gmail.com on 15 Jan 2010 at 8:19

GoogleCodeExporter commented 8 years ago
By the way, I was building a uPnP browser for the iPhone last year and I came 
across
your site :)  I couldn't get the code to work, but knowing that you got it work 
was
very encouraging. I eventually got libplatinum to play nice with Rhythmbox on 
Ubuntu
by hacking http://sourceforge.net/projects/platinum

Original comment by yonas.ya...@gmail.com on 15 Jan 2010 at 8:25

GoogleCodeExporter commented 8 years ago
People tell me frustration makes me happier and just more determined to solve 
the issue. My comment the 
other day was not called for, I think this is a very good and important effort. 
The iphone is a very nice device 
but it could be better if Apple would release its reigns on the platform a bit. 
Its really maddening knowing 
what capability is there but you can't use it. Maybe with increased competition 
from Android that will happen. 
I plan oto do dual iphone and Android development. I've been doing java for a 
long time.

Nice subtle little way of telling me I don't support my work very well either. 
Think that is true of most open 
source projects, not only ours.

To my defense if you had emailed me I would of helped you to get the server 
working. I did many people. Our 
apns server is being used by a school in the netherlands for instance.

I was never really happy with the upnp bridge, at the time I think we were the 
first to attempt something like 
that. And that was for the 1st generation iphone.

But there were some major problems that made us abandon that effort. The server 
was just something I 
hacked together, and though multithreaded , at the time I don't think I knew 
that much about multithreading. 
aFter being involved with some really massive java projects at work , that 
looks so primitive now.

Secondly , now you have pure java based jdms for dns-sd, but than you only had 
the apple responder which 
required a JNI install. Well I was coding on a mac so that was transparent, but 
the majority of users I found 
were on windows and worse yet Linux which did not support apple bonjour.

Another issue is that cybergarage upnp lib isn't all that good, its used a lot, 
because I think it is one of the 
best documented but it has trouble with a lot of upnp discovery, We now are 
moveing toward sbbi which 
seems to be better.

Finally it soon became apparent that the idea was flawed, mobile safari just 
couldn't handle the throughput , 
especially when you had users who jumped from video to video and server to 
server. We tried using custom jsf 
components rather than the IUI javascript library but that only helped a bit , 
it was clear the performance we 
wanted would require a native iphone application.

Back then it was mostly me and the cats, now I occassionally have others 
helping and mooncatventures will 
become a true (small but real) company this years with the release of our first 
three iphone apps .

Streams will be the native version of the upnp app. Today it has a lot more 
competion, there's plug player and  
medialink that are pretty good. But most other upnp apps get bad reviews and I 
think there isn't a good upnp 
lib for the iphone yet. Discovery is slow and not very percise. I think our 
bridge approach is more robust. 
Discovery is instant.

However it does have one big flaw, it can only play formats native to the 
iphone. Air Video and streamforsure 
will eat our lunch , that is why we either need to come up with a transcoding 
server or a native player. We 
were approaching it from developing a transcoding server like air video does, 
and then I found your project.

I think we our close. I've worked out most of what you have, if you could 
please send me the configure file 
you used for ffplay I think we can duplicate that. 

If you like I can contact you when we begin the private beta of our streams 
app, the back end server now is 
based on jetty , its embedded and will be very easy to install.
http://sol3.typepad.com/tagalong_developer_journa/

Original comment by michelle...@gmail.com on 16 Jan 2010 at 2:02

GoogleCodeExporter commented 8 years ago
Thanks for all that info :) I'd love to test your beta streams app, send me an 
email
at yonas.yanfa@gmail.com

Unfortunately I don't have the config file for ffplay, but the only custom 
tuning I
had to do was telling ffmpeg configure script where I installed SDL and add "-I"
includes for every OpengGL/SDL header/library that was reported messing.

I also remember that the ./configure would try to test ./ffplay and fail 
because it
was ARM code (i.e. "wrong architecture" type of error), so I had to build 
ffplay and
ffserver first, then manually build only ffplay with no tests.

Original comment by yonas.ya...@gmail.com on 16 Jan 2010 at 4:12

GoogleCodeExporter commented 8 years ago
ssue 9 is fixed.

I've tested with avi, mp4 and mpg. they are work. I still need to get rtsp 
feeds to work, but I think that won't 
be to hard. I'm working on a proof of concept using darwin streaming server.

I don't want to release this just yet, there is one more problem to fix before 
we post these changes. could you 
please look at the project and see if you can see any obvious reason why the 
video doesn't scale properly. I 
may also run that against some of the folks on the ffmpeg mail list tommorrow.

its late tonight, tommorrow I will put a blog article up on this stuff. 

This version still uses sdk 2.2.1 , thats the best we can do until  the sdl 
project gets its 1.3 act together.

Meantime I'm working on a purely objective c video player that I think will be 
done in about a week, I'm also 
wondering if this ffplay can be compiled as a static library and called from a 
3.1 project.

Also I've been playing with the video classes from openframeworks, they are 
pretty cool and impressive but 
have synch inssues and no sound support. I may look into that.

Thanks for inspiring me to do this yonas.

I' have the changes in my svn repository please send me your email address and 
I will send you the password.

Michelle at mooncatventures.com 

Notice the scaling is off on the attached screen print if we can solve that 
than ffplay is working nicely

Original comment by michelle...@gmail.com on 19 Jan 2010 at 6:12

Attachments:

GoogleCodeExporter commented 8 years ago
As our test shows, streaming videos such as xvid's seem to play better than 
local videos.
Except for the distortion issue. Its not really pixulated in the avi's its 
almost a bluring effect. kind of like if you 
enlarge a jpg to a greater resolution that its pixel depth. interesting.

As for formats

avi, mp4's and mpgs (xvid only tested) work streaming or local. but streaming 
definitely looks better.

frame rate is good without stuttering (but I only tested on 3gs so far)

rtsp, doesn't work, never did I think. but I know how I can make it work. Done 
something similar with audio 
only.

Some more testing is required before releasing this into the wild. Yanas,  I 
posted the slight distortion issue to 
the ffmpeg-devl mail list.

Quality, well its not great but its better  than some of the on-the-fly 
transcoding solutions i've seem.

Original comment by michelle...@gmail.com on 19 Jan 2010 at 5:48

GoogleCodeExporter commented 8 years ago
All problems are fixed, even extremely long videos play

tested with avi's, mpgs and xvids.

there are three of us testing, so it won't be long before we publish something.

There may be some other little surpises to download too, you can do a lot with 
ffmpeg.

for now here are the updated screen captures.

http://web.me.com/cannonwc/Site/Photos_5.html

Original comment by michelle...@gmail.com on 21 Jan 2010 at 4:40

GoogleCodeExporter commented 8 years ago
Nice, I'm no longer working in this project, but I look forward to see your 
fixes.

Original comment by ducn...@gmail.com on 24 Jan 2010 at 4:40

GoogleCodeExporter commented 8 years ago
I'll be updating the svn here very soon, meantime you can get the changes to 
ffplay.c
and updated libs, here.

http://99.139.107.194/svn/test/portalServer/ffplay/

password and user name are both test.

Original comment by michelle...@gmail.com on 25 Jan 2010 at 12:43