<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=GB2312" http-equiv=Content-Type>
<STYLE>
BLOCKQUOTE {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
P {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
BODY {
LINE-HEIGHT: 1.5; FONT-FAMILY: ΢ÈíÑźÚ; COLOR: #000000; FONT-SIZE: 10.5pt
}
</STYLE>
<META name=GENERATOR content="MSHTML 9.00.8112.16506"></HEAD>
<BODY style="MARGIN: 10px">
<DIV>Hi to all,</DIV>
<DIV>I am trying develop an video chat app on
android and have ported ffmpeg 2.0.1 to android successfully.
<SPAN style="FONT-FAMILY: ΢ÈíÑźÚ">The code to open camera is very
simple:</SPAN></DIV>
<DIV style="FONT-FAMILY: Consolas"><SPAN style="BACKGROUND-COLOR: #ffffff"><FONT
style="BACKGROUND-COLOR: #c0c0c0">
<DIV style="TEXT-INDENT: 2em"><SPAN
style="BACKGROUND-COLOR: #ffffff"><SPAN>AVFormatContext *fmt_ctx =
NULL;</SPAN></SPAN></DIV>
<DIV><SPAN style="BACKGROUND-COLOR: #ffffff"></SPAN></DIV>
<DIV style="TEXT-INDENT: 2em"><SPAN
style="BACKGROUND-COLOR: #ffffff">AVInputFormat *input_fmt;</SPAN></DIV>
<DIV><SPAN style="BACKGROUND-COLOR: #ffffff"></SPAN></DIV>
<DIV><SPAN style="BACKGROUND-COLOR: #ffffff"></SPAN></DIV>
<DIV style="TEXT-INDENT: 2em"><SPAN style="BACKGROUND-COLOR: #ffffff">input_fmt
= av_find_input_format("video4linux2"); </SPAN></DIV>
<DIV style="TEXT-INDENT: 2em"><SPAN style="BACKGROUND-COLOR: #ffffff">if
(input_fmt == NULL)</SPAN></DIV>
<DIV style="TEXT-INDENT: 4em"><SPAN style="BACKGROUND-COLOR: #ffffff">return
-1£»</SPAN></DIV>
<DIV><SPAN style="BACKGROUND-COLOR: #ffffff"></SPAN> </DIV>
<DIV style="TEXT-INDENT: 2em"><SPAN style="BACKGROUND-COLOR: #ffffff">char
f_name[] = "/dev/video0";</SPAN></DIV>
<DIV style="TEXT-INDENT: 2em"><SPAN style="BACKGROUND-COLOR: #ffffff">if ((ret =
avformat_open_input(&fmt_ctx, f_name, input_fmt, NULL)) <
0) <STRONG>// stuck
here</STRONG></SPAN></DIV>
<DIV style="TEXT-INDENT: 2em"><SPAN
style="BACKGROUND-COLOR: #ffffff">{</SPAN></DIV>
<DIV><SPAN style="BACKGROUND-COLOR: #ffffff"></SPAN></DIV>
<DIV style="TEXT-INDENT: 4em"><SPAN style="BACKGROUND-COLOR: #ffffff">LOG_D("can
not open camera, ret = %d", ret);</SPAN></DIV>
<DIV style="TEXT-INDENT: 4em"><SPAN style="BACKGROUND-COLOR: #ffffff">return
ret;</SPAN></DIV>
<DIV style="TEXT-INDENT: 2em"><SPAN
style="BACKGROUND-COLOR: #ffffff">}</SPAN></DIV>
<DIV><SPAN style="BACKGROUND-COLOR: #ffffff; FONT-FAMILY: ΢ÈíÑźÚ">the strange
thing is the ret value is always negative with the following logcat output by
av_log:</SPAN></DIV>
<DIV><SPAN style="BACKGROUND-COLOR: #ffffff"><SPAN
style="BACKGROUND-COLOR: #c0c0c0">09-26 15:27:48.901: E/Codec-FFMpeg(17716):
ioctl(VIDIOC_G_PARM): Invalid argument</SPAN></SPAN></DIV>
<DIV><SPAN style="BACKGROUND-COLOR: #ffffff; FONT-FAMILY: ΢ÈíÑźÚ">Do i forget
anything before calling avformat_open_input()? Thank
you!</SPAN></FONT></SPAN></DIV></DIV>
<DIV><SPAN>
<DIV style="FONT-FAMILY: verdana; FONT-SIZE: 10pt">
<DIV> </DIV>
<DIV>Regards,</DIV>
<DIV>craig</DIV></DIV></SPAN></DIV></BODY></HTML>