Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 27th March 2008, 02:30   #261  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
WRITE TIMECODES TO A FILE. Fix it yourself using that. This was also very harshly answered earlier in the thread.

For the <edit mod: removed profanity> of you trying to compile ffmpeg source this is what you need and what will happen:
A recent gcc compile like 4.2.3. Have fun compiling it yourself with mingw.
A recent ffmpeg. Straightforward IF it compiles.
Uneventfully compile zlib but forget --prefix=/mingw and confuse yourself.
Make an empty dll project in vs2005 and add all files. Also add a list of obscure gcc include libraries to appease ffmpeg.
Compile.
You are now likely to be the proud owner of a miscompiled ffmpegsource. Order a pizza and watch tv instead.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet

Last edited by Wilbert; 28th March 2008 at 18:58.
Myrsloik is offline   Reply With Quote
Old 27th March 2008, 03:09   #262  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by Myrsloik View Post
For the fools of you trying to compile ffmpeg source you need and what will happen:
A recent gcc compile like 4.2.3. Have fun compiling it yourself with mingw.
A recent ffmpeg. Straightforward IF it compiles.
Uneventfully compile zlib but forget --prefix=/mingw and confuse yourself.
Make an empty dll project in vs2005 and add all files. Also add a list of obscure gcc include libraries to appease ffmpeg.
Compile.
You are now likely to be the proud owner of a miscompiled ffmpegsource. Order a pizza and watch tv instead.
After successfully compiling Aegisub with ffmpeg in VS2005 (with your help) I wrote some slightly more detailed instructions on how to statically link ffmpeg with something compiled in MSVC. The configure flags are not completely identical (remember to add libpostproc and its corresponding .a) and you'll need zlib as well but maybe it helps somewhat.
TheFluff is offline   Reply With Quote
Old 27th March 2008, 19:52   #263  |  Link
Shinta
Registered User
 
Join Date: Feb 2003
Posts: 14
@Myrsloik: Thanks for the loud and extremly confusing answer.
@TheFluff: Thx for the slightly more helpful one.

After fixing a small problem running sh-scripts with exe-extension in msys (in ./configure) and adding a missing #define to rtsp.c, I was finally able (about 3 hours) to compile ffmpeg. The compiling of ffmpegsource (I tried this using precompiled ffmpeg libs, but this results in a very small ffmpegsource.dll (292 kBytes), which was obviously crap) was just (re-)linking.

So, if someone is interessted in a VS2005 project (including ffmpegsource and zlib sources and the ffmpeg libs compiled by me), you may send me a PM.

.oO(Now, lets see, what can I do to make the filter returning frames with cfr on vfr videos)°
Shinta is offline   Reply With Quote
Old 28th March 2008, 17:48   #264  |  Link
Shinta
Registered User
 
Join Date: Feb 2003
Posts: 14
Current source and a bug?

Is the source at https://spaceboyz.net/svn/aegisub/trunk/FFmpegSource the current version (1.16)?
The file ffmpegsource.html holds only changelog entries until 1.14...

Also, in matroskacodecs.cpp lines 137++:
Code:
case MAKEFOURCC('Z', 'L', 'I', 'B'):
	return CODEC_ID_FLV1;
case MAKEFOURCC('F', 'L', 'V', '1'):
	return CODEC_ID_ZLIB;
Shouldn't this be...?:
Code:
case MAKEFOURCC('Z', 'L', 'I', 'B'):
	return CODEC_ID_ZLIB;
case MAKEFOURCC('F', 'L', 'V', '1'):
	return CODEC_ID_FLV1;
Shinta is offline   Reply With Quote
Old 28th March 2008, 22:16   #265  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
That's a really obscure bug. Why were you reading the whole codec list anyway?

Version 1.16 + that fix is now in the svn.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 29th March 2008, 12:07   #266  |  Link
Shinta
Registered User
 
Join Date: Feb 2003
Posts: 14
Quote:
Originally Posted by Myrsloik View Post
That's a really obscure bug. Why were you reading the whole codec list anyway?
I was just speed-reading the code and it caught my eye.

But another thing. I really don't understand the whole video decoding stuff completely yet, so don't be mad if I understood it wrong.

In ffmpegsource.cpp & ffmatroskasource.cpp:
Code:
// Flush the last frame
if (CurrentFrame == VI.num_frames - 1  && VideoCodecContext->has_b_frames)
	Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, NULL, 0);
Is it really only the last frame that isn't decoded at this moment? Aren't it as much as frames as the number of (deferred?) b-frames since the last seek?

Code:
// Flush the last frames
if (CurrentFrame <= VI.num_frames - 1  && VideoCodecContext->has_b_frames)
	Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, NULL, 0);
Just one thing more: In FFBase::SaveTimecodesToFile you sort the timecodes before writing them to the file. Shouldn't the frames (or their DTSs) be sorted for seeking too?
Shinta is offline   Reply With Quote
Old 29th March 2008, 12:26   #267  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by Shinta View Post
In ffmpegsource.cpp & ffmatroskasource.cpp:
Code:
// Flush the last frame
if (CurrentFrame == VI.num_frames - 1  && VideoCodecContext->has_b_frames)
	Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, NULL, 0);
Is it really only the last frame that isn't decoded at this moment? Aren't it as much as frames as the number of (deferred?) b-frames since the last seek?

Code:
// Flush the last frames
if (CurrentFrame <= VI.num_frames - 1  && VideoCodecContext->has_b_frames)
	Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, NULL, 0);
This makes no sense. Even if there were more than one frame, which I highly doubt (read the loop above the mentioned code again), your fix wouldn't output more than one frame because avcodec_decode_video() only outputs one frame at a time. By the way the frame that is "decoded" is just NULL, so... (see avcodec.h)
TheFluff is offline   Reply With Quote
Old 29th March 2008, 13:05   #268  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
Due to b-frame reordering decodign will never lag more than one frame. Example:

Shown: IBPBPI
Stored: IPBPBI

Shown: IBBPBBPI
Stored: IPBBPBBI

Meaning that you will never have more than a one frame lag (indicated by has_b_frames). Thus there are no more frames to flush. As thefluff pointed out that part is also only triggered if all the other logic failed which is for the last frame with decoding lag OR for very unusual decoding errors and then only for the last frame.



FFBase::SaveTimecodesToFile - The whole DTS relation is a bit special. That function only sorts them because mkvmerge expects it as input (historical note: old versions used unsorted).

The reason ffmpegsource doesn't care about it being sorted or not is that the position of keyframes is independent of the reordering. As the only value extracted from it is "what frame number does this DTS correspond to?" and we know that seeking always goes to keyframes (minus bugs and that stuff). So the only thing the other DTS values in between are really used for are placeholders.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 29th March 2008, 13:06   #269  |  Link
Shinta
Registered User
 
Join Date: Feb 2003
Posts: 14
For videos with only one b-frame your right, but I found a video that seems to have 2 frames left to decode after reaching EOF.

Using this code...
Code:
// Flush the last frames
if (CurrentFrame <= VI.num_frames - 1 && VideoCodecContext->has_b_frames)
	Ret = avcodec_decode_video(VideoCodecContext, AFrame, &FrameFinished, NULL, 0);

FILE* err=fopen("err.txt", "a");
if(err)
{
	fprintf(err, "%d %d %d %d %d\r\n", CurrentFrame, VI.num_frames-1, Ret, FrameFinished, VideoCodecContext->has_b_frames);
	fclose(err);
}
I got this err.txt:
Code:
90286 90287 0 200 2
90287 90287 0 200 2
I don't know what the 200s in the 4th column means exactly, but they're not zero and thus the frame were decoded.
Shinta is offline   Reply With Quote
Old 29th March 2008, 13:37   #270  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
To debug these things it's usually much easier to encode a clip with similar settings and clearly number every frame. Does your clip by any chance have open GOPs?
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 29th March 2008, 13:55   #271  |  Link
Shinta
Registered User
 
Join Date: Feb 2003
Posts: 14
Maybe it has something to do with this:

(From the german wikipedia on h264)
Quote:
Long-Term Prediction: P- und B-Frames können nicht nur Referenzen auf den jeweils letzten I- oder P-Frame enthalten, sondern auch zu theoretisch beliebig vielen vorhergehenden, um eine effizientere Kodierung von periodischen Bewegungen zu ermöglichen. In den Profiles und Levels ist die Anzahl von Referenzbildern allerdings auf maximal fünf begrenzt.
My translation (hope it is good enough):
Quote:
Long-Term Prediction: P- and B-frames doesn't have to reference only the last I- or P-frame, but also to theoreticaly any number of previous (I- or P-)frames, to increase encoding performance on recurring movements. The profiles and levels limits the number of referenced frame to five.
Quote:
To debug these things it's usually much easier to encode a clip with similar settings and clearly number every frame. Does your clip by any chance have open GOPs?
I don't know, and don't know how to find that out. But I've splitted the video at the last keyframe and can send you this 74 kByte mkv.
Shinta is offline   Reply With Quote
Old 29th March 2008, 14:13   #272  |  Link
Shinta
Registered User
 
Join Date: Feb 2003
Posts: 14
Lets try an attachment: (it is that 74kb mkv)
Attached Files
File Type: zip test.zip (62.8 KB, 50 views)
Shinta is offline   Reply With Quote
Old 29th March 2008, 14:26   #273  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
Seeking in h264 should be limited to IDR frames which means the assumption is still true (I is just another letter in between). Find some place to upload the file to and I will look at it.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 29th March 2008, 14:36   #274  |  Link
Shinta
Registered User
 
Join Date: Feb 2003
Posts: 14
Or, http://www.megaupload.com/?d=Y9QNAHQB
Shinta is offline   Reply With Quote
Old 29th March 2008, 21:39   #275  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
The one-frame lag implied by bframes is valid for all codecs prior to H264. For h264, the possibility to create b-reference (and thus pyramidal b-gops) may create longer lags (one level of byramid is commonly used with x264 and creates a two frame lag)
__________________
Manao is offline   Reply With Quote
Old 30th March 2008, 16:42   #276  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
Bug fixed and put in the svn. As Manao hinted it only applied to h264 with pyramid stuff and would usually result in the last frame being dropped and the now second to last frame duplicated.

No new compile today though, ffmpeg svn is having one of those broken weeks it seems.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 31st March 2008, 01:28   #277  |  Link
thetoof
Sleepy overworked fellow
 
Join Date: Feb 2008
Location: Maple syrup's homeland
Posts: 933
Feature request: handling of the anamorphic flags
thetoof is offline   Reply With Quote
Old 31st March 2008, 17:50   #278  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
So I've read the AR from the stream, now what? Return it in a variable with a user specified name? Rescale the video and kill kittens?
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 2nd April 2008, 19:53   #279  |  Link
jase99
*nix
 
jase99's Avatar
 
Join Date: Feb 2008
Posts: 34
I regularly use the filter with anamorphic sources, what additional support is needed?
jase99 is offline   Reply With Quote
Old 4th April 2008, 16:30   #280  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
How aspect ratio reporting is done now:
FFSAR_NUM, FFSAR_DEN and FFSAR are set to the container values for mkv and the video decoder values for all other filetypes.
The problem:
Several mp4 files report a SAR of 0/1 which isn't right or very helpful. Should the cases with 0 be converted to 1/1 or left as it is?
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:18.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.