void V4SceneManager::SaveFile(const char *path) { GF_SMEncodeOptions opts; char rad_name[5000]; /* First dump the scene in a BT file */ strcpy(rad_name, "dump"); m_pSm->scene_graph->RootNode = NULL; gf_sm_dump(m_pSm, rad_name, 0); /* Then reload properly (overriding the current SceneManager)*/ GF_SceneLoader load; memset(&load, 0, sizeof(GF_SceneLoader)); load.fileName = "dump.bt"; load.ctx = m_pSm; gf_sm_load_init(&load); gf_sm_load_run(&load); gf_sm_load_done(&load); /* Finally encode the file */ GF_ISOFile *mp4 = gf_isom_open(path, GF_ISOM_WRITE_EDIT, NULL); m_pSm->max_node_id = gf_sg_get_max_node_id(m_pSm->scene_graph); memset(&opts, 0, sizeof(opts)); opts.flags = GF_SM_LOAD_MPEG4_STRICT; gf_sm_encode_to_file(m_pSm, mp4, &opts); gf_isom_set_brand_info(mp4, GF_ISOM_BRAND_MP42, 1); gf_isom_modify_alternate_brand(mp4, GF_ISOM_BRAND_ISOM, 1); gf_isom_close(mp4); }
GF_EXPORT GF_Err gf_beng_save_context(GF_BifsEngine *codec, char * ctxFileName) { u32 d_mode, do_enc; char szF[GF_MAX_PATH], *ext; GF_Err e; /*check if we dump to BT, XMT or encode to MP4*/ strcpy(szF, ctxFileName); ext = strrchr(szF, '.'); d_mode = GF_SM_DUMP_BT; do_enc = 0; if (ext) { if (!stricmp(ext, ".xmt") || !stricmp(ext, ".xmta")) d_mode = GF_SM_DUMP_XMTA; else if (!stricmp(ext, ".mp4")) do_enc = 1; ext[0] = 0; } if (do_enc) { GF_ISOFile *mp4; strcat(szF, ".mp4"); mp4 = gf_isom_open(szF, GF_ISOM_OPEN_WRITE, NULL); e = gf_sm_encode_to_file(codec->ctx, mp4, NULL); if (e) gf_isom_delete(mp4); else gf_isom_close(mp4); } else { e = gf_sm_dump(codec->ctx, szF, d_mode); } return e; }
GF_Err ISOR_CloseService(GF_InputService *plug) { GF_Err reply; ISOMReader *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; read = (ISOMReader *) plug->priv; reply = GF_OK; read->disconnected = GF_TRUE; while (gf_list_count(read->channels)) { ISOMChannel *ch = (ISOMChannel *)gf_list_get(read->channels, 0); gf_list_rem(read->channels, 0); isor_delete_channel(read, ch); } if (read->dnload) gf_service_download_del(read->dnload); read->dnload = NULL; if (read->mov) gf_isom_close(read->mov); read->mov = NULL; if (read->input->query_proxy && read->input->proxy_udta && read->input->proxy_type) { send_proxy_command(read, GF_TRUE, GF_FALSE, reply, NULL, NULL); } else { gf_service_disconnect_ack(read->service, NULL, reply); } return GF_OK; }
static GF_Err ISOW_Close(GF_StreamingCache *mc, Bool delete_cache) { GF_Err e; ISOMReader *cache = (ISOMReader *)mc->priv; if (!cache->mov || !cache->service) return GF_BAD_PARAM; while (gf_list_count(cache->channels)) { ISOMChannel *ch = (ISOMChannel *)gf_list_get(cache->channels, 0); gf_list_rem(cache->channels, 0); if (ch->cache_sample) { gf_isom_add_sample(cache->mov, ch->track, 1, ch->cache_sample); gf_isom_sample_del(&ch->cache_sample); } gf_free(ch); } if (delete_cache) { gf_isom_delete(cache->mov); e = GF_OK; } else { e = gf_isom_close(cache->mov); } cache->mov = NULL; cache->service = NULL; return e; }
static int close_file( hnd_t handle, int64_t largest_pts, int64_t second_largest_pts ) { mp4_hnd_t *p_mp4 = handle; if( !p_mp4 ) return 0; if( p_mp4->p_config ) gf_odf_avc_cfg_del( p_mp4->p_config ); if( p_mp4->p_sample ) { if( p_mp4->p_sample->data ) free( p_mp4->p_sample->data ); p_mp4->p_sample->dataLength = 0; gf_isom_sample_del( &p_mp4->p_sample ); } if( p_mp4->p_file ) { if( p_mp4->i_track ) { /* The mdhd duration is defined as CTS[final] - CTS[0] + duration of last frame. * The mdhd duration (in seconds) should be able to be longer than the tkhd duration since the track is managed by edts. * So, if mdhd duration is equal to the last DTS or less, we give the last composition time delta to the last sample duration. * And then, the mdhd duration is updated, but it time-wise doesn't give the actual duration. * The tkhd duration is the actual track duration. */ uint64_t mdhd_duration = (2 * largest_pts - second_largest_pts) * p_mp4->i_time_inc; if( mdhd_duration != gf_isom_get_media_duration( p_mp4->p_file, p_mp4->i_track ) ) { uint64_t last_dts = gf_isom_get_sample_dts( p_mp4->p_file, p_mp4->i_track, p_mp4->i_numframe ); uint32_t last_duration = (uint32_t)( mdhd_duration > last_dts ? mdhd_duration - last_dts : (largest_pts - second_largest_pts) * p_mp4->i_time_inc ); gf_isom_set_last_sample_duration( p_mp4->p_file, p_mp4->i_track, last_duration ); } /* Write an Edit Box if the first CTS offset is positive. * A media_time is given by not the mvhd timescale but rather the mdhd timescale. * The reason is that an Edit Box maps the presentation time-line to the media time-line. * Any demuxers should follow the Edit Box if it exists. */ GF_ISOSample *sample = gf_isom_get_sample_info( p_mp4->p_file, p_mp4->i_track, 1, NULL, NULL ); if( sample && sample->CTS_Offset > 0 ) { uint32_t mvhd_timescale = gf_isom_get_timescale( p_mp4->p_file ); uint64_t tkhd_duration = (uint64_t)( mdhd_duration * ( (double)mvhd_timescale / p_mp4->i_time_res ) ); gf_isom_append_edit_segment( p_mp4->p_file, p_mp4->i_track, tkhd_duration, sample->CTS_Offset, GF_ISOM_EDIT_NORMAL ); } gf_isom_sample_del( &sample ); recompute_bitrate_mp4( p_mp4->p_file, p_mp4->i_track ); } gf_isom_set_pl_indication( p_mp4->p_file, GF_ISOM_PL_VISUAL, 0x15 ); gf_isom_set_storage_mode( p_mp4->p_file, GF_ISOM_STORE_FLAT ); gf_isom_close( p_mp4->p_file ); } free( p_mp4 ); return 0; }
void dc_audio_muxer_free(AudioOutputFile * p_aoutf) { if (p_aoutf->p_isof != NULL) { gf_isom_close(p_aoutf->p_isof); } gf_isom_sample_del(&p_aoutf->p_sample); }
void dc_audio_muxer_free(AudioOutputFile *audio_output_file) { #ifndef GPAC_DISABLE_ISOM if (audio_output_file->isof != NULL) { gf_isom_close(audio_output_file->isof); } //gf_isom_sample_del(&audio_output_file->sample); #endif }
int dc_video_muxer_free(VideoOutputFile *video_output_file) { if (video_output_file->isof != NULL) { gf_isom_close(video_output_file->isof); } gf_isom_sample_del(&video_output_file->sample); return 0; }
void V4SceneGraph::SaveFile(const char *path) { char rad_name[5000]; strcpy(rad_name, "dump"); gf_sm_dump(m_pSm, rad_name, 0); GF_ISOFile *mp4 = gf_isom_open(path, GF_ISOM_WRITE_EDIT, NULL); m_pSm->max_node_id = gf_sg_get_max_node_id(m_pSm->scene_graph); gf_sm_encode_to_file(m_pSm, mp4, "c:\\log.txt", NULL, GF_SM_LOAD_MPEG4_STRICT, 0); gf_isom_close(mp4); }
GF_Err create_laser_mp4(GF_LoadCompare *lc, char *item_name, char *item_path, u32 *size) { char mp4_path[100], *ext; GF_Err e = GF_OK; GF_ISOFile *mp4; *size = 0; strcpy(mp4_path, item_name); ext = strrchr(mp4_path, '.'); strcpy(ext, ".mp4"); mp4 = gf_isom_open(mp4_path, GF_ISOM_WRITE_EDIT, NULL); if (!mp4) { if (lc->verbose) fprintf(stdout, "Could not open file %s for writing\n", mp4_path); e = GF_IO_ERR; } else { GF_SMEncodeOptions opts; memset(&opts, 0, sizeof(GF_SMEncodeOptions)); opts.auto_qant = 1; opts.resolution = 8; e = encode_laser(lc, item_path, mp4, &opts); if (e) { if (lc->verbose) fprintf(stdout, "Could not encode MP4 file from %s\n", item_path); gf_isom_delete(mp4); } else { gf_isom_close(mp4); mp4 = gf_isom_open(mp4_path, GF_ISOM_OPEN_READ, NULL); if (!mp4) { if (lc->verbose) fprintf(stdout, "Could not open file %s for reading\n", mp4_path); e = GF_IO_ERR; } else { e = get_laser_track_size(mp4, size); if (e) { if (lc->verbose) fprintf(stdout, "Could not get MP4 file size\n"); } gf_isom_close(mp4); } } } return e; }
int dc_gpac_video_isom_close(VideoOutputFile *video_output_file) { GF_Err ret; ret = gf_isom_close(video_output_file->isof); if (ret != GF_OK) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_close\n", gf_error_to_string(ret))); return -1; } return 0; }
//保存文件 bool EasyMP4Writer::SaveFile() { if (m_psps) { delete m_psps; m_psps = NULL; } if (m_ppps) { delete m_ppps; m_ppps = NULL; } m_spslen=0; m_ppslen=0; m_audiostartimestamp=-1; m_videostartimestamp=-1; if (p_file) { gf_isom_close(p_file); p_file=NULL; } if(p_config) { // delete p_config->pictureParameterSets; p_config->pictureParameterSets=NULL; // delete p_config->sequenceParameterSets; p_config->sequenceParameterSets=NULL; gf_odf_avc_cfg_del(p_config); p_config=NULL; } if( p_audiosample) { if( p_audiosample->data) { free(p_audiosample->data); p_audiosample->data=NULL; } gf_isom_sample_del(&p_audiosample); p_audiosample=NULL; } if( p_videosample) { if( p_videosample->data) { free(p_videosample->data); p_videosample->data=NULL; } gf_isom_sample_del(&p_videosample); p_audiosample=NULL; } return true; }
int dc_gpac_audio_isom_close(AudioOutputFile *audio_output_file) { GF_Err ret; ret = gf_isom_close(audio_output_file->isof); if (ret != GF_OK) { GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("%s: gf_isom_close\n", gf_error_to_string(ret))); return -1; } //audio_output_file->acc_samples = 0; return 0; }
int dc_gpac_audio_isom_close(AudioOutputFile * p_aoutf) { GF_Err ret; ret = gf_isom_close(p_aoutf->p_isof); if (ret != GF_OK) { fprintf(stderr, "%s: gf_isom_close\n", gf_error_to_string(ret)); return -1; } //p_aoutf->acc_samples = 0; return 0; }
GF_EXPORT void gf_isom_streamer_del(GF_ISOMRTPStreamer *streamer) { GF_RTPTrack *track = streamer->stream; while (track) { GF_RTPTrack *tmp = track; if (track->au) gf_isom_sample_del(&track->au); if (track->rtp) gf_rtp_streamer_del(track->rtp); track = track->next; gf_free(tmp); } if (streamer->isom) gf_isom_close(streamer->isom); gf_free(streamer->dest_ip); gf_free(streamer); }
GF_Err decode_svg(GF_LoadCompare *lc, char *item_name, char *item_path, char *svg_out_path) { GF_SceneManager *ctx; GF_SceneGraph *sg; GF_SceneLoader load; GF_ISOFile *mp4; GF_Err e = GF_OK; char mp4_path[256]; char *ext; strcpy(mp4_path, item_name); ext = strrchr(mp4_path, '.'); strcpy(ext, ".mp4"); mp4 = gf_isom_open(mp4_path, GF_ISOM_OPEN_READ, NULL); if (!mp4) { if (lc->verbose) fprintf(stdout, "Could not open file %s\n", mp4_path); e = GF_IO_ERR; } else { sg = gf_sg_new(); ctx = gf_sm_new(sg); memset(&load, 0, sizeof(GF_SceneLoader)); load.isom = mp4; load.ctx = ctx; e = gf_sm_load_init(&load); if (e) { fprintf(stderr, "Error loading MP4 file\n"); } else { e = gf_sm_load_run(&load); if (e) { fprintf(stderr, "Error loading MP4 file\n"); } else { gf_sm_load_done(&load); ext = strrchr(svg_out_path, '.'); ext[0] = 0; e = gf_sm_dump(ctx, svg_out_path, GF_SM_DUMP_SVG); if (e) { fprintf(stderr, "Error dumping SVG from MP4 file\n"); } } } gf_sm_del(ctx); gf_sg_del(sg); gf_isom_close(mp4); } return e; }
GF_EXPORT GF_Err gf_seng_save_context(GF_SceneEngine *seng, char *ctxFileName) { #ifdef GPAC_DISABLE_SCENE_DUMP return GF_NOT_SUPPORTED; #else u32 d_mode, do_enc; char szF[GF_MAX_PATH], *ext; GF_Err e; /*check if we dump to BT, XMT or encode to MP4*/ ext = NULL; if (ctxFileName) { strcpy(szF, ctxFileName); ext = strrchr(szF, '.'); } d_mode = GF_SM_DUMP_BT; do_enc = 0; if (ext) { if (!stricmp(ext, ".xmt") || !stricmp(ext, ".xmta")) d_mode = GF_SM_DUMP_XMTA; else if (!stricmp(ext, ".mp4")) do_enc = 1; ext[0] = 0; } if (do_enc) { #ifndef GPAC_DISABLE_SCENE_ENCODER GF_ISOFile *mp4; strcat(szF, ".mp4"); mp4 = gf_isom_open(szF, GF_ISOM_OPEN_WRITE, NULL); e = gf_sm_encode_to_file(seng->ctx, mp4, NULL); if (e) gf_isom_delete(mp4); else gf_isom_close(mp4); #else return GF_NOT_SUPPORTED; #endif } else { e = gf_sm_dump(seng->ctx, ctxFileName ? szF : NULL, d_mode); } return e; #endif }
GF_Err ISOR_CloseService(GF_InputService *plug) { GF_Err reply; ISOMReader *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; read = (ISOMReader *) plug->priv; reply = GF_OK; if (read->mov) gf_isom_close(read->mov); read->mov = NULL; while (gf_list_count(read->channels)) { ISOMChannel *ch = (ISOMChannel *)gf_list_get(read->channels, 0); gf_list_rem(read->channels, 0); isor_delete_channel(read, ch); } if (read->dnload) gf_term_download_del(read->dnload); read->dnload = NULL; gf_term_on_disconnect(read->service, NULL, reply); return GF_OK; }
GF_Err get_mp4_loadtime(GF_LoadCompare *lc, char *item_name, char *item_path, u32 *loadtime) { char mp4_path[100], *ext; GF_Err e = GF_OK; GF_ISOFile *mp4; *loadtime = 0; strcpy(mp4_path, item_name); ext = strrchr(mp4_path, '.'); strcpy(ext, ".mp4"); mp4 = gf_isom_open(mp4_path, GF_ISOM_OPEN_READ, NULL); if (!mp4) { if (lc->verbose) fprintf(stdout, "Could not open file %s for reading\n", mp4_path); e = GF_IO_ERR; } else { e = load_mp4(lc, mp4, loadtime); if (e) { if (lc->verbose) fprintf(stdout, "Could not get MP4 file load time\n"); } } gf_isom_close(mp4); return e; }
int main(int argc, char **argv) { /* The ISO progressive reader */ GF_ISOFile *movie; /* Error indicator */ GF_Err e; /* Number of bytes required to finish the current ISO Box reading */ u64 missing_bytes; /* Return value for the program */ int ret = 0; /* Maximum index of the segments*/ u32 seg_max = argc-2; /* Number of the segment being processed*/ u32 seg_curr = 0; u32 track_id = 1; u32 sample_index = 1; /* Usage */ if (argc < 2) { fprintf(stdout, "Usage: %s filename0 [filename1 filename2 ...]\n", argv[0]); return 1; } #if defined(DEBUG) || defined(_DEBUG) /* Enables GPAC memory tracking in debug mode only */ gf_sys_init(GF_TRUE); gf_log_set_tool_level(GF_LOG_CONTAINER, GF_LOG_INFO); gf_log_set_tool_level(GF_LOG_MEMORY, GF_LOG_INFO); #endif /* First or init segment */ fprintf(stdout, "Process segment %5d/%5d: %s\n", seg_curr, seg_max, argv[seg_curr+1]); e = gf_isom_open_progressive(argv[seg_curr+1], 0, 0, &movie, &missing_bytes); if ((e != GF_OK && e != GF_ISOM_INCOMPLETE_FILE) || movie == NULL) { fprintf(stdout, "Could not open file %s for reading (%s).\n", argv[seg_curr+1], gf_error_to_string(e)); return 1; } process_samples_from_track(movie, track_id, &sample_index); seg_curr++; /* Process segments */ while (seg_curr <= seg_max) { fprintf(stdout, "Process segment %5d/%5d: %s\n", seg_curr, seg_max, argv[seg_curr+1]); /* Open the segment */ e = gf_isom_open_segment(movie, argv[seg_curr+1], 0, 0, GF_FALSE); if (e != GF_OK) { fprintf(stdout, "Could not open segment %s for reading (%s).\n", argv[seg_curr+1], gf_error_to_string(e)); ret = 1; goto exit; } /* Process the segment */ process_samples_from_track(movie, track_id, &sample_index); /* Release the segment */ gf_isom_release_segment(movie, 1); seg_curr++; } exit: fprintf(stdout, "Total nb Samples: %d\n", gf_isom_get_sample_count(movie, gf_isom_get_track_by_id(movie, track_id) ) ); gf_isom_release_segment(movie, 1); gf_isom_close(movie); #if defined(DEBUG) || defined(_DEBUG) /* Closes GPAC memory tracking in debug mode only */ gf_sys_close(); #endif return ret; }
int main(int argc, char **argv) { /* The ISO progressive reader */ ISOProgressiveReader reader; /* Error indicator */ GF_Err e; /* input file to be read in the data buffer */ FILE *input; /* number of bytes read from the file at each read operation */ u32 read_bytes; /* number of bytes read from the file (total) */ u64 total_read_bytes; /* size of the input file */ u64 file_size; /* number of bytes required to finish the current ISO Box reading (not used here)*/ u64 missing_bytes; /* Thread used to run the ISO parsing in */ GF_Thread *reading_thread; /* Return value for the program */ int ret = 0; /* Usage */ if (argc != 2) { fprintf(stdout, "Usage: %s filename\n", argv[0]); return 1; } /* Initializing GPAC framework */ /* Enables GPAC memory tracking in debug mode only */ #if defined(DEBUG) || defined(_DEBUG) gf_sys_init(GF_MemTrackerSimple); gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_WARNING); gf_log_set_tool_level(GF_LOG_MEMORY, GF_LOG_INFO); #else gf_sys_init(GF_MemTrackerNone); gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_WARNING); #endif /* This is an input file to read data from. Could be replaced by any other method to retrieve the data (e.g. JavaScript, socket, ...)*/ input = gf_fopen(argv[1], "rb"); if (!input) { fprintf(stdout, "Could not open file %s for reading.\n", argv[1]); gf_sys_close(); return 1; } gf_fseek(input, 0, SEEK_END); file_size = gf_ftell(input); gf_fseek(input, 0, SEEK_SET); /* Initializing the progressive reader */ memset(&reader, 0, sizeof(ISOProgressiveReader)); reading_thread = gf_th_new("ISO reading thread"); reader.mutex = gf_mx_new("ISO Segment"); reader.do_run = GF_TRUE; /* we want to parse the first track */ reader.track_id = 1; /* start the async parsing */ gf_th_run(reading_thread, iso_progressive_read_thread, &reader); /* start the data reading */ reader.data_size = BUFFER_BLOCK_SIZE; reader.data = (u8 *)gf_malloc(reader.data_size); reader.valid_data_size = 0; total_read_bytes = 0; while (1) { /* block the parser until we are done manipulating the data buffer */ gf_mx_p(reader.mutex); if (reader.valid_data_size + BUFFER_BLOCK_SIZE > MAX_BUFFER_SIZE) { /* regulate the reader to limit the max buffer size and let some time to the parser to release buffer data */ fprintf(stdout, "Buffer full (%d/%d)- waiting to read next data \r", reader.valid_data_size, reader.data_size); gf_mx_v(reader.mutex); //gf_sleep(10); } else { /* make sure we have enough space in the buffer to read the next bloc of data */ if (reader.valid_data_size + BUFFER_BLOCK_SIZE > reader.data_size) { reader.data = (u8 *)gf_realloc(reader.data, reader.data_size + BUFFER_BLOCK_SIZE); reader.data_size += BUFFER_BLOCK_SIZE; } /* read the next bloc of data and update the data buffer url */ read_bytes = fread(reader.data+reader.valid_data_size, 1, BUFFER_BLOCK_SIZE, input); total_read_bytes += read_bytes; fprintf(stdout, "Read "LLD" bytes of "LLD" bytes from input file %s (buffer status: %5d/%5d)\r", total_read_bytes, file_size, argv[1], reader.valid_data_size, reader.data_size); if (read_bytes) { reader.valid_data_size += read_bytes; sprintf(reader.data_url, "gmem://%d@%p", reader.valid_data_size, reader.data); } else { /* end of file we can quit */ gf_mx_v(reader.mutex); break; } /* if the file is not yet opened (no movie), open it in progressive mode (to update its data later on) */ if (!reader.movie) { /* let's initialize the parser */ e = gf_isom_open_progressive(reader.data_url, 0, 0, &reader.movie, &missing_bytes); if (reader.movie) { gf_isom_set_single_moof_mode(reader.movie, GF_TRUE); } /* we can let parser try to work now */ gf_mx_v(reader.mutex); if ((e == GF_OK || e == GF_ISOM_INCOMPLETE_FILE) && reader.movie) { /* nothing to do, this is normal */ } else { fprintf(stdout, "Error opening fragmented mp4 in progressive mode: %s (missing "LLD" bytes)\n", gf_error_to_string(e), missing_bytes); ret = 1; goto exit; } } else { /* let inform the parser that the buffer has been updated with new data */ e = gf_isom_refresh_fragmented(reader.movie, &missing_bytes, reader.data_url); /* we can let parser try to work now */ gf_mx_v(reader.mutex); if (e != GF_OK && e != GF_ISOM_INCOMPLETE_FILE) { fprintf(stdout, "Error refreshing fragmented mp4: %s (missing "LLD" bytes)\n", gf_error_to_string(e), missing_bytes); ret = 1; goto exit; } } //gf_sleep(1); } } exit: /* stop the parser */ reader.do_run = GF_FALSE; gf_th_stop(reading_thread); /* clean structures */ gf_th_del(reading_thread); gf_mx_del(reader.mutex); gf_free(reader.data); gf_isom_close(reader.movie); gf_fclose(input); gf_sys_close(); return ret; }
int main(int argc, char **argv) { GF_ISOFile *movie; GF_ESD *esd; GF_Err e; Double gb_size = 5.0; u8 store_mode; u32 track, di, i, nb_samp; GF_ISOSample *samp; store_mode = GF_ISOM_OPEN_WRITE; for (i=1; i<argc; i++) { if (!strcmp(argv[i], "-flat")) store_mode = GF_ISOM_OPEN_WRITE; else if (!strcmp(argv[i], "-inter")) store_mode = GF_ISOM_WRITE_EDIT; else if (!strcmp(argv[i], "-size") && (i+1<argc)) { gb_size = atof(argv[i+1]); i++; } else if (!strcmp(argv[i], "-h")) { PrintUsage(); return 0; } } nb_samp = (u32) (gb_size*1024); fprintf(stdout, "Creating test file %s - %g GBytes - %d samples - %s mode\n", TEST_FILE_NAME, gb_size, nb_samp, (store_mode == GF_ISOM_OPEN_WRITE) ? "Flat" : "Interleaved"); movie = gf_isom_open(TEST_FILE_NAME, store_mode, NULL); if (!movie) { fprintf(stdout, "Error creating file: %s\n", gf_error_to_string(gf_isom_last_error(NULL))); return 1; } track = gf_isom_new_track(movie, 1, GF_ISOM_MEDIA_VISUAL, 25); esd = gf_odf_desc_esd_new(2); esd->decoderConfig->streamType = 4; gf_isom_new_mpeg4_description(movie, track, esd, NULL, NULL, &di); samp = gf_isom_sample_new(); samp->dataLength = 1024*1024; samp->data = gf_malloc(sizeof(char)*samp->dataLength); memset(samp->data, 0, sizeof(char)*samp->dataLength); for (i=0; i<nb_samp; i++) { if (samp->DTS % 25) samp->IsRAP = 0; else samp->IsRAP = 1; e = gf_isom_add_sample(movie, track, di, samp); samp->DTS += 1; fprintf(stdout, "Writing sample %d / %d \r", i+1, nb_samp); if (e) break; } gf_isom_sample_del(&samp); if (e) { fprintf(stdout, "\nError writing sample %d\n", i); gf_isom_delete(movie); return 1; } fprintf(stdout, "\nDone writing samples\n"); e = gf_isom_close(movie); if (e) { fprintf(stdout, "Error writing file\n"); return 1; } return 0; }