diff --git a/FFmpegSource2/ffavisynth.h b/FFmpegSource2/ffavisynth.h index 6e592431d..28d4afc7d 100644 --- a/FFmpegSource2/ffavisynth.h +++ b/FFmpegSource2/ffavisynth.h @@ -44,7 +44,6 @@ private: public: AvisynthVideoSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, const char *PP, int Threads, int SeekMode, IScriptEnvironment* Env, char *ErrorMsg, unsigned MsgSize); ~AvisynthVideoSource(); - int GetTrack() { return FFMS_GetVSTrack(VS); } bool __stdcall GetParity(int n) { return false; } void __stdcall SetCacheHints(int cachehints, int frame_range) { } const VideoInfo& __stdcall GetVideoInfo() { return VI; } @@ -59,7 +58,6 @@ private: public: AvisynthAudioSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, IScriptEnvironment* Env, char *ErrorMsg, unsigned MsgSize); ~AvisynthAudioSource(); - int GetTrack() { return FFMS_GetASTrack(AS); } bool __stdcall GetParity(int n) { return false; } void __stdcall SetCacheHints(int cachehints, int frame_range) { } const VideoInfo& __stdcall GetVideoInfo() { return VI; } diff --git a/FFmpegSource2/ffavsfilters.cpp b/FFmpegSource2/ffavsfilters.cpp index bbc0c25fb..1161a1dd5 100644 --- a/FFmpegSource2/ffavsfilters.cpp +++ b/FFmpegSource2/ffavsfilters.cpp @@ -130,6 +130,18 @@ AVSValue __cdecl CreateFFVideoSource(AVSValue Args, void* UserData, IScriptEnvir } } + if (Track == -1) + Track = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_VIDEO, ErrorMsg, MsgSize); + if (Track < 0) + Env->ThrowError("FFVideoSource: No video track found"); + + if (strcmp(Timecodes, "")) { + if (FFMS_WriteTimecodes(FFMS_GetTITrackIndex(Index, Track, ErrorMsg, MsgSize), Timecodes, ErrorMsg, MsgSize)) { + FFMS_DestroyFrameIndex(Index); + Env->ThrowError("FFVideoSource: %s", ErrorMsg); + } + } + AvisynthVideoSource *Filter; try { @@ -139,14 +151,6 @@ AVSValue __cdecl CreateFFVideoSource(AVSValue Args, void* UserData, IScriptEnvir throw; } - if (strcmp(Timecodes, "")) { - if (FFMS_WriteTimecodes(FFMS_GetTITrackIndex(Index, Filter->GetTrack(), ErrorMsg, MsgSize), Timecodes, ErrorMsg, MsgSize)) { - FFMS_DestroyFrameIndex(Index); - delete Filter; - Env->ThrowError("FFVideoSource: %s", ErrorMsg); - } - } - FFMS_DestroyFrameIndex(Index); return Filter; } @@ -187,6 +191,11 @@ AVSValue __cdecl CreateFFAudioSource(AVSValue Args, void* UserData, IScriptEnvir } } + if (Track == -1) + Track = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_AUDIO, ErrorMsg, MsgSize); + if (Track < 0) + Env->ThrowError("FFAudioSource: No audio track found"); + AvisynthAudioSource *Filter; try { diff --git a/FFmpegSource2/ffms.cpp b/FFmpegSource2/ffms.cpp index 27c9f1a2c..ff6fd2770 100644 --- a/FFmpegSource2/ffms.cpp +++ b/FFmpegSource2/ffms.cpp @@ -90,16 +90,6 @@ FFMS_API(void) FFMS_DestroyAudioSource(AudioBase *AB) { delete AB; } -FFMS_API(int) FFMS_GetVSTrack(VideoBase *VB) { - return VB->GetTrack(); -} - -FFMS_API(int) FFMS_GetASTrack(AudioBase *AB) { - // FIXME - // return AB->GetTrack(); - return 0; -} - FFMS_API(const VideoProperties *) FFMS_GetVideoProperties(VideoBase *VB) { return &VB->GetVideoProperties(); } @@ -132,6 +122,14 @@ FFMS_API(void) FFMS_DestroyFrameIndex(FrameIndex *FI) { delete FI; } +FFMS_API(int) FFMS_GetFirstTrackOfType(FrameIndex *TrackIndices, int TrackType, char *ErrorMsg, unsigned MsgSize) { + for (int i = 0; i < TrackIndices->size(); i++) + if ((*TrackIndices)[i].TT == TrackType) + return i; + _snprintf(ErrorMsg, MsgSize, "No suitable track found"); + return -1; +} + FFMS_API(int) FFMS_GetNumTracks(FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize) { return TrackIndices->size(); } diff --git a/FFmpegSource2/ffms.h b/FFmpegSource2/ffms.h index 9347b20f1..7c017c569 100644 --- a/FFmpegSource2/ffms.h +++ b/FFmpegSource2/ffms.h @@ -145,6 +145,8 @@ struct VideoProperties { int CropBottom; int CropLeft; int CropRight; + double FirstTime; + double LastTime; }; struct AudioProperties { @@ -160,8 +162,6 @@ FFMS_API(VideoBase *) FFMS_CreateVideoSource(const char *SourceFile, int Track, FFMS_API(AudioBase *) FFMS_CreateAudioSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize); FFMS_API(void) FFMS_DestroyVideoSource(VideoBase *VB); FFMS_API(void) FFMS_DestroyAudioSource(AudioBase *AB); -FFMS_API(int) FFMS_GetVSTrack(VideoBase *VB); -FFMS_API(int) FFMS_GetASTrack(AudioBase *AB); FFMS_API(const VideoProperties *) FFMS_GetVideoProperties(VideoBase *VB); FFMS_API(const AudioProperties *) FFMS_GetAudioProperties(AudioBase *AB); FFMS_API(const AVFrameLite *) FFMS_GetFrame(VideoBase *VB, int n, char *ErrorMsg, unsigned MsgSize); @@ -170,6 +170,7 @@ FFMS_API(int) FFMS_GetAudio(AudioBase *AB, void *Buf, int64_t Start, int64_t Cou FFMS_API(int) FFMS_SetOutputFormat(VideoBase *VB, int TargetFormat, int Width, int Height); FFMS_API(void) FFMS_ResetOutputFormat(VideoBase *VB); FFMS_API(void) FFMS_DestroyFrameIndex(FrameIndex *FI); +FFMS_API(int) FFMS_GetFirstTrackOfType(FrameIndex *TrackIndices, int TrackType, char *ErrorMsg, unsigned MsgSize); FFMS_API(int) FFMS_GetNumTracks(FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize); FFMS_API(int) FFMS_GetTrackType(FrameInfoVector *FIV, char *ErrorMsg, unsigned MsgSize); FFMS_API(int) FFMS_GetNumFrames(FrameInfoVector *FIV, char *ErrorMsg, unsigned MsgSize); diff --git a/FFmpegSource2/ffmpegsource2.html b/FFmpegSource2/ffms2.html similarity index 95% rename from FFmpegSource2/ffmpegsource2.html rename to FFmpegSource2/ffms2.html index 4e53ea092..52b520647 100644 --- a/FFmpegSource2/ffmpegsource2.html +++ b/FFmpegSource2/ffms2.html @@ -186,8 +186,16 @@ Note that --enable-w32threads is required for multithreaded decoding to work.