免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 10696 | 回复: 7
打印 上一主题 下一主题

[C] FFmpeg中ffplay源代码的修改 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-09-21 19:52 |只看该作者 |倒序浏览
20可用积分
本帖最后由 mp4 于 2010-06-21 09:19 编辑

已解决

论坛徽章:
0
2 [报告]
发表于 2008-09-21 20:27 |只看该作者
刚找了个FFmpeg编程指南(How to Write a Video Player in Less Than 1000 Lines)
http://www.dranger.com/ffmpeg/

里面第一个示例程序编译就通不过
root:~/ffmpeg# gcc -o tutorial01 tutorial01.c -lavutil -lavformat -lavcodec -lz -lavutil -lm
tutorial01.c: In function 'main':
tutorial01.c:82: error: invalid type argument of '->'
tutorial01.c:90: error: incompatible types in assignment
郁闷。。。

论坛徽章:
0
3 [报告]
发表于 2008-09-22 12:49 |只看该作者
为什么不试试mplayer呢?

论坛徽章:
0
4 [报告]
发表于 2008-09-22 13:12 |只看该作者
在 av_read_frame 函数执行失败的时候调用exit就行了.

论坛徽章:
0
5 [报告]
发表于 2008-09-22 19:55 |只看该作者
原帖由 bushuhui 于 2008-9-22 12:49 发表
为什么不试试mplayer呢?


mplayer播放完后会自动退出,也可以按q键退出,不过太庞大了,不想杀鸡用牛刀,而且mplayer用的也是FFmpeg的源代码

论坛徽章:
0
6 [报告]
发表于 2008-09-22 20:15 |只看该作者
原帖由 随风缘 于 2008-9-22 13:12 发表
在 av_read_frame 函数执行失败的时候调用exit就行了.


我当初也是这么改的,不管用啊

我找到循环读数据的那段,加了两句:
     printf("\a\n");
       goto fail;
结果一运行就马上退出,什么声音都还没播出

/* this thread gets the stream from the disk or the network */
static int decode_thread(void *arg)
{

。。。

      ret = av_read_frame(ic, pkt);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ret < 0) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("\a\n");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goto fail;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (url_ferror(&ic->pb) == 0) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SDL_Delay(100); /* wait for user event */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

。。。

fail:
&nbsp;&nbsp;&nbsp;&nbsp;/* disable interrupting */
&nbsp;&nbsp;&nbsp;&nbsp;global_video_state = NULL;

&nbsp;&nbsp;&nbsp;&nbsp;/* close each stream */
&nbsp;&nbsp;&nbsp;&nbsp;if (is->audio_stream >= 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream_component_close(is, is->audio_stream);
&nbsp;&nbsp;&nbsp;&nbsp;if (is->video_stream >= 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream_component_close(is, is->video_stream);
&nbsp;&nbsp;&nbsp;&nbsp;if (is->subtitle_stream >= 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream_component_close(is, is->subtitle_stream);
&nbsp;&nbsp;&nbsp;&nbsp;if (is->ic) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;av_close_input_file(is->ic);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is->ic = NULL; /* safety */
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;url_set_interrupt_cb(NULL);

&nbsp;&nbsp;&nbsp;&nbsp;if (ret != 0) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SDL_Event event;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.type = FF_QUIT_EVENT;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.user.data1 = is;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SDL_PushEvent(&event);
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;return 0;
}


把那两句加到continue后,结果和没改过一样,看了下av_read_frame接口函数的说明,返值小于0就是遇到文件尾了啊?

int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream. The information is stored as a packet in pkt.

The returned packet is valid until the next av_read_frame() or until av_close_input_file() and must be freed with av_free_packet. For video, the packet contains exactly one frame. For audio, it contains an integer number of frames if each frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames have a variable size (e.g. MPEG audio), then it contains one frame.

pkt->pts, pkt->dts and pkt->duration are always set to correct values in AVStream.timebase units (and guessed if the format cannot provided them). pkt->pts can be AV_NOPTS_VALUE if the video format has B frames, so it is better to rely on pkt->dts if you do not decompress the payload.

Returns: 0 if OK, < 0 if error or end of file.

论坛徽章:
0
7 [报告]
发表于 2008-09-25 20:43 |只看该作者
Hacker高手怎么还没出现啊?我再追加悬赏20分!

红外接收头电路图,成本不超过5块钱

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
8 [报告]
发表于 2008-09-25 21:02 |只看该作者
原帖由 mp4 于 2008-9-22 20:15 发表


我当初也是这么改的,不管用啊

我找到循环读数据的那段,加了两句:
     printf("\a\n");
       goto fail;
结果一运行就马上退出,什么声音都还没播出

/* this thread gets the stream from th ...


不会啊,av_read_frame到文件尾了,就返回小于0了. 那个时候exit当然可以了.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP