Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ffmpeg faststart flag programmatically?

Tags:

c++

ffmpeg

mp4

I try to convert videos for playback on Android using H264, AAC codecs and mp4 container. Video plays normaly with non-system players. But system player shows error "Can't play this video". I found out that the problem is in moov atom, which is writed in the end of the file. When I use "-movflags +faststart" ffmeg flag to convert video, it plays normal, but when I try to do that programmatically, it gives no result. I use following code:

av_dict_set( &dict, "movflags", "faststart", 0 );
ret = avformat_write_header( ofmt_ctx, &dict );
like image 801
Evgeniy Kharchenko Avatar asked Apr 09 '26 20:04

Evgeniy Kharchenko


1 Answers

This code works fine:

av_dict_set( &dict, "movflags", "faststart", 0 );
ret = avformat_write_header( ofmt_ctx, &dict );

But problem is not solved. I still can't play converted videos on Android devices.

like image 79
Evgeniy Kharchenko Avatar answered Apr 11 '26 12:04

Evgeniy Kharchenko