VideoHelp Forum
+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 34
Thread
  1. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    I am attempting to trim a video with an AVISynth file run thru FFMpeg. The resultant file plays fine but when loaded into VirtualDub, it shows a Gray screen and will not play. The frame number for the first frame is huge: Frame 18446744073701113439 (4294967218:4294967284:429496.

    Loading the AVISynth file into VirtualDub plays/displays correctly. The AVISynth script (trimming.avs) is:
    Directshowsource("C:\Users\Bud\Desktop\test.mp4")
    clipOne = Trim(0, 77)
    clipTwo = Trim(147, 0)
    AlignedSplice(clipOne, clipTwo)


    The ffmpeg script is:
    ffmpeg -i "Trimming.avs" -vcodec libx264 -crf 20 -acodec libvo_aacenc -ar 44.1k -b:a 128k "C:\Users\Bud\Desktop\Test_Frames_3.mp4"

    Any help as to what I am doing wrong would be greatly appreciated. My purpose is to get the edit to work correctly not to use VirtualDub. The problem is the trimmed file does not play correctly in VirtualDub, which means it did not edit correctly.
    Quote Quote  
  2. DECEASED
    Join Date
    Jun 2009
    Location
    Heaven
    Search Comp PM
    Try FFMS2 or DSS2(mod) instead of DirectShowSource()

    DirectShowSource() sucks at trimming, UNLESS the chosen splitter and decoders happen to be very-goode.

    The resultant file plays fine but when loaded into VirtualDub, it shows a Gray screen and will not play.
    Try remuxing the output MP4 with MP4Box or L-Smash, because the avformat muxers normally suck too : - /
    Quote Quote  
  3. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    What does this have to do with trim? You make a file with FFMPEG and it won't play properly in VirtualDub. That's what I'm reading, or did I miss something?
    Quote Quote  
  4. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    I'll try ffms2 and I was afraid of the remuxing A/V problems that might arise from FFMS2, which is why I tried alignedsplice(). I originally tried:

    Directshowsource("C:\Users\Bud\Desktop\Test.mp4")
    Trim(0, 77,True)++Trim(147, 0,True)

    I got the same results so I'll try mp4box and see how that works after FFMS2
    Thanks
    Quote Quote  
  5. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Ndjamena, Trim is the function of AVISynth script that is executed by FFMpeg ( All part of a program I am writing) that creates a playable file by all media players I possess but since VirtualDub shows incorrect frame count and will not play it, it has a flaw somewhere. I would rather the resulting file worked everywhere, even though I am not using VirtualDub for any part of my editing program.

    Thanks
    Quote Quote  
  6. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    No so familiar with those other 2 Source filters, but: How do you know you are trimming on GOP boundaries? If not, maybe there's a GOP decoding reference problem.

    Scott
    Quote Quote  
  7. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    TRIM is supposed to cut on whatever frame you set and it appears to do that very well. This may leave artifacts that need to be dealt with later but at least it appeared to be a frame accurate editing option. Since frame 0 is a key frame, I didn't expect that reference problem there but it is.

    Since Directshowsource is buggy everywhere, I'll start there and try another option.
    thanks
    Quote Quote  
  8. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    I still don't get what's going on, the script opens fine in VirtualDub, FFMPEG2 encodes the script fine, but when you try to play the file FFMPEG2 creates from the script using VirtualDub it goes all screwy. I ask again, what does that have to do with Trim?

    It's a playing AAC or h.264 in an MP4 using VirtualDub problem, which I don't think VirtualDub is designed to do anyway.
    Last edited by ndjamena; 14th Jun 2014 at 02:42.
    Quote Quote  
  9. I'll confess I too am a little confused regarding where the problem is..... whether it's the encoded video or playing the script in VirtualDub..... but the script in the opening post should work fine. I created a test script and loaded it into VirtualDub and the frame count was as it should be.

    Could it be some sort of odd frame rate problem. Maybe try adding the appropriate frame rate stuff:
    Directshowsource("C:\Users\Bud\Desktop\test.mp4", fps=23.976, convertfps=true).AssumeFPS(24000,1001)
    Last edited by hello_hello; 14th Jun 2014 at 03:53.
    Quote Quote  
  10. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Disregard what I said earlier.
    Troubleshoot by removing the confounding variables. Does the script work without encoding to mp4? Does the script work with encoding to another format? (Possibly alI I-frame). Does the script work without trim but encoding? Does the script work without going through Virtualdub (directly to ffmpeg)? Etc...
    Btw, what is vdub being used for here - just for checking? Because it (or its mp4 import plugin) might be just screwing up the viewing without the file actually being messed up.
    What about the Aligned splice? Have you tried a partial script with just each of the individual trim pieces?
    Stuff like that.

    Scott
    Quote Quote  
  11. Member
    Join Date
    May 2014
    Location
    Memphis TN, US
    Search PM
    Originally Posted by Budman1 View Post
    I am attempting to trim a video with an AVISynth file run thru FFMpeg. The resultant file plays fine but when loaded into VirtualDub, it shows a Gray screen and will not play. The frame number for the first frame is huge: Frame 18446744073701113439 (4294967218:4294967284:429496.

    Loading the AVISynth file into VirtualDub plays/displays correctly. The AVISynth script (trimming.avs) is:
    Directshowsource("C:\Users\Bud\Desktop\test.mp4")
    clipOne = Trim(0, 77)
    clipTwo = Trim(147, 0)
    AlignedSplice(clipOne, clipTwo)


    The ffmpeg script is:
    ffmpeg -i "Trimming.avs" -vcodec libx264 -crf 20 -acodec libvo_aacenc -ar 44.1k -b:a 128k "C:\Users\Bud\Desktop\Test_Frames_3.mp4"

    Any help as to what I am doing wrong would be greatly appreciated. My purpose is to get the edit to work correctly not to use VirtualDub. The problem is the trimmed file does not play correctly in VirtualDub, which means it did not edit correctly.
    VirtualDub didn't trim anything. All it displayed is what Avisynth and your incorrect script sent to it. The line "clipTwo = Trim(147, 0)" doesn't apply the Trim to your DirectShowSource input, but tries to apply the Trim to clipOne. The script has 4 different clip results, with only clipOne and clipTwo specifically named. Any output at all would be a surprise, LOL.

    You can code this many ways, but these worked:
    Code:
    WhateverSource(AviSource, DirectShowSource, etc., etc.)
    a=last
    clipOne = a.Trim(0, 77)
    clipTwo = a.Trim(147, 0)
    b=AlignedSplice(clipOne, clipTwo)
    return b
    Or this:
    Code:
    WhateverSource(AviSource, DirectShowSource, etc., etc.)
    a=last
    clipOne = a.Trim(0, 77)
    clipTwo = a.Trim(147, 0)
    AlignedSplice(clipOne, clipTwo)
    return last
    Or this:
    Code:
    a=WhateverSource(AviSource, DirectShowSource, etc., etc.)
    b=a.Trim(0, 77) ++ a.Trim(147, 0)
    return b
    Last edited by LMotlow; 14th Jun 2014 at 05:19.
    Quote Quote  
  12. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Originally Posted by LMotlow View Post
    VirtualDub didn't trim anything. All it displayed is what Avisynth and your incorrect script sent to it. The line "clipTwo = Trim(147, 0)" doesn't apply the Trim to your DirectShowSource input, but tries to apply the Trim to clipOne. The script has 4 different clip results, with only clipOne and clipTwo specifically named. Any output at all would be a surprise, LOL.
    Actually, since the clipOne line didn't return an actual value the 'last' return value remained the DirectShowSource clip which was then passed to the clipTwo line. The script was valid, he's just confusing everyone by blaming his problem on a redundant step in his processing.
    Quote Quote  
  13. Member
    Join Date
    May 2014
    Location
    Memphis TN, US
    Search PM
    uh, yep. You're right. I must have mistyped something my first time around and got an error. Well, as they used to say on SNL.....never mind!
    Quote Quote  
  14. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Sorry everyone that was confused and thought I was pointing blame... I was confused, which is why I asked assistance, of course.
    Scenario:

    1. I have a video (AVC/AAC.mp4) that is 1380 frames long.
    2. I wish to extract frames 0-77 (00:00:00.000-00:00:02.602) as clip1
    3. I also wanted to extract frames 147-1380 (00:00:04.904-00:00:46.046) as clip2
    4. I wanted to 'mux/merge/join/etc.' together into one video.
    5. I wished to use AVISynth's TRIM function for this and AlignedSplice to make sure each portion's audio stayed in sync.
    6. Since AVISynth does not CREATE/ENCODE a video, I decided to try FFMpeg for this, creating AVC/AAC_Frames_1.mp4
    7. It worked and the video was playable in VLC/GOM/Potplayer/Etc.
    8. I wished to see what was done as far as the changes to the key frames.
    9. I used VirtualDub to view key frames since it has a nice indicator at the bottom of it.
    10. I noticed the newly created video not only didn't play in VirtualDub but had a weird first frame number, therefore it appeared damaged during creation.
    11. I wanted to know if this could be fixed and since I was befuddled I asked for assistance from experts who are not easily confused.


    Cornucopia, Thanks for the array of suggestions that put me on the right track and after trying several of them, I believe the problem is that AVISynth presents the video in YUY2 format to FFMpeg and FFMpeg does not create a flawless video from that, or at least one with correct frame numbers (at least in the 5 versions I have tried). I have decided to have my program create the file using times:

    First:
    ffmpeg -i "C:\Users\Bud\Desktop\Test_1.mp4" -ss 00:00:00.000 -to 00:00:02.602 -vf scale=720:406,pad=720:480:0:37 -vcodec libx264 -crf 20 -acodec libvo_aacenc -ar 44.1k -b:a 128k "C:\Users\Bud\Desktop\Test_1.mp4"

    Second:
    ffmpeg -i "C:\Users\Bud\Desktop\Test_2.mp4" -ss 00:00:04.904 -to 00:00:46.046 -vf scale=720:406,pad=720:480:0:37 -vcodec libx264 -crf 20 -acodec libvo_aacenc -ar 44.1k -b:a 128k "C:\Users\Bud\Desktop\Test_2.mp4"

    Create a list:
    file 'C:\Users\Bud\Desktop\Test_1.mp4'
    file 'C:\Users\Bud\Desktop\Test_2.mp4'

    Finally Concat them:
    ffmpeg -f concat -i FileList.txt -c copy "C:\Users\Bud\Desktop\_Joined_1.mp4"

    Sounds like a hassle but it is all program automated now with only a pause to make adjustments if I wish so I gave up on AVISynth for this portion.

    Thanks to all for helping.
    Quote Quote  
  15. It works for me without having to do that workaround. I use ffmpeg frequently to encode avs scripts, with more trims and scripts more complex without issues

    How are you loading the MP4 into vdub ? What input driver, what decoder ?

    If you open the same MP4 in avidemux, what happens (it has keyframe, frametype indicaters as well)
    Quote Quote  
  16. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Assuming you diagnosed it properly it sounds like DirectShow is outputting in an undesirable colour format. Try:

    Code:
    Directshowsource("C:\Users\Bud\Desktop\test.mp4").ConvertToYV12(interlaced=false)
    clipOne = Trim(0, 77)
    clipTwo = Trim(147, 0)
    AlignedSplice(clipOne, clipTwo)
    Of course, maybe the source is YUY2 or FFMPEG converted it to YUY2 for some reason or...
    Quote Quote  
  17. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    poisondeathray,
    Loaded MP4 with directshow filter, FFmpeg filter and default filter. All fail.
    If I load the 'bad video' into AVIDemux... IT WORKS great! Correct frames, key frames and all and will create a muxed version that plays in VirtualDub.
    Looks like the 2 programs are using different decoding methods?
    Does AVIDemux have a CLI version?

    Ndjamena
    That version still fails the same way. ANY FFMpeg function even creating a video from an AVISynth file, no matter what format (it is always in RAW format of some kind) will not play in VirtualDub. I used just a plain 'WhateverSource' AVS file and used FFMpeg to create a video from it and same failure.
    Quote Quote  
  18. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    @Budman1, do a test and convert - NOT with Vdub, maybe using AVIDemux - that clip (as encoded by ffmpeg) into a standard HuffYUV or similar AVI clip. Open that in Vdub. Does it play correctly? If so, my hunch is that it is a bug in Vdub's mp4 input plugin.

    Also, note that whether it plays "right" or "wrong", whether in Vdub or AVIDemux, etc, if you start with a LongGOP media, decode & cut it, and re-encode, you WILL always end up with the GOP sequence being changed, unless you were extremely painstaking in reading & saving the IBP flow of the GOP structure to a separate file and then referring to it again when re-encoding. Think about it - it doesn't know what to use except what is right before it (unless you specifically supplied that extra info). And AVISynth is turning that original file into uncompressed YUV (or YV12 or RGB, depending upon your script), so at the point of frameserving output, there is no longer any such thing as I vs. P vs. B frames, etc.

    Pardon my answers from last night: I was dog-tired & drowsy and not too cogent in my answers.

    HTH,

    Scott
    Quote Quote  
  19. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    If I'm understanding correctly, no MP4 file created by FFMPEG2 will open in VDUB, yet if you take an FFMPEG2 MP4 and remux it back into an MP4 using AVIDemux then VDUB will play it fine?

    Are you sure you're not re-encoding with AVIDemux?
    Quote Quote  
  20. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Saving the file created by FFMpeg as a huffyuv.avi file plays correctly in virtualdub and players. Apparently reencoding the 'corrupted' video into anything else via AVIDemux or any other converter creates a file playable by VirtualDub or Media Player and Editors.

    And AVISynth is turning that original file into uncompressed YUV (or YV12 or RGB, depending upon your script), so at the point of frameserving output, there is no longer any such thing as I vs. P vs. B frames, etc.
    Yes, that makes perfect sense, after I finally realized AVISynth was presenting YUY2 data... Duh... Just took me a lot longer than it should have until I tried some of your suggestions and experimented.

    Ndjamena,
    Not positive since AVIDemux is new to me but I chose COPY video, COPY audio and MP4 Muxer??? That is NOT encoding is it?
    Last edited by Budman1; 15th Jun 2014 at 00:17.
    Quote Quote  
  21. Member
    Join Date
    Sep 2012
    Location
    Australia
    Search Comp PM
    Originally Posted by Budman1
    Not positive since AVIDemux is new to me but I chose COPY video, COPY audio and MP4 Muxer??? That is Muxing correct?
    I should think so, unless maybe it decides the elementary streams aren't compatible with it's MP4 multiplexer.

    Originally Posted by Budman1
    If I load the 'bad video' into AVIDemux... IT WORKS great! Correct frames, key frames and all and will create a muxed version that plays in VirtualDub.
    Originally Posted by Budman1
    Simply muxing the two clips or the 'corrupted' video does not fix or allow it to be played in VirtualDub.
    You're kind of hard to follow at the best of times...

    Is it possible this is a packed frames issue within VDub?
    Quote Quote  
  22. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    OK, so how about trying to remux the h.264 video into an AVI container...how does that work? If it works ok in Vdub, it clearly is the "mp4 plugin" portion and NOT the h.264 decoding portion.

    I'm pretty sure what you had done was remux, not re-encode, in AVIDemux.

    Scott
    Quote Quote  
  23. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Originally Posted by Budman1
    If I load the 'bad video' into AVIDemux... IT WORKS great! Correct frames, key frames and all and will create a muxed version that plays in VirtualDub.

    Originally Posted by Budman1
    Simply muxing the two clips or the 'corrupted' video does not fix or allow it to be played in VirtualDub.
    You're kind of hard to follow at the best of times...
    LOL... Yeah I knew someone would catch that before I did... Tried to answer 2 at once and did not correct after trials.

    CORRECTION:
    Using AVIDemux to mux 'bad' (h.264) into mp4 works all around.

    Using AVIDemux to mux 'bad' (h.264) into AVI does NOT work in Virtual Dub. Gets black screen/no video and just the audio plays. This is using FFDshow h.264 VFW filter.

    UPDATE: Unconfigured FFDshow h264 AVC codec and installed the x264 from here https://www.videohelp.com/tools/x264-VFW and no difference in results.
    Last edited by Budman1; 15th Jun 2014 at 00:25.
    Quote Quote  
  24. If the MP4 works in everything except vdub, doesn't that suggest a vdub or import issue ?

    Are you sure you are using the ffinputdriver (selected from the drop down menu) ? Try updating the plugin, because there were a few buggy releases

    Alternatively, there might be something actually wrong with the MP4 muxer by ffmpeg (less likely), but you might try updating the binary
    Quote Quote  
  25. Alternatively, there might be something actually wrong with the MP4 muxer by ffmpeg (less likely), but you might try updating the binary
    not that unlikely ffmpeg has a history of messing up mp4 files on muxing, which is why, at least I, always remux ffmpeg mp4 output with either MP4Box or L-smash.
    Quote Quote  
  26. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Update:
    Downloaded latest level of FFMpeg = No change.
    Downloaded latest levels FFimputdriver and DshowInputDriver = No Change -> (Tried Drag and drop, FFinputdriver and dshowinput driver)
    Downloaded Latest VirtualDub (1.10.3->1.10.4) = No Change
    FFMpeg -> Encoded video with libxvid codec instead of libx264 and result was playable by VirtualDub. All good.

    This makes me believe FFMpeg does not like getting RAW data and encoding into AVC/264/MP4 format since even the AVI failed with it:
    Using AVIDemux to mux 'bad' (h.264) into AVI does NOT work in Virtual Dub. Gets black screen/no video and just the audio plays.
    This would be why AVIDemux can remux into MP4 and the result plays in VirtualDub:
    Using AVIDemux to mux 'bad' (h.264) into mp4 works all around.
    The only weird part to me is that VirtualDub rejects the 'bad' MP4 video but nothing else seems to dislike it?????

    The moral of the story to me is not to try to create an MP4/AVC/h264 video from RAW data(yuy2,etc.) with FFMpeg without remuxing as Slur pointed out.
    Quote Quote  
  27. So are you suggesting that ANY ffmpeg output with h264/aac/MP4 is corrupted (when fed avs input, which is uncompressed), cannot be opened in vdub with ffinputdriver ? And that remuxing fixes it ? The suggestion is that ffmpeg MP4 muxer is the culprit. While it can produce problems (known issues) , it doesn't here

    If that were true, your script isn't really important, you can use blankclip() or colorbars(), the trims() are a "red herring" . The fact that you can preview the avs script directly in vdub suggests that your script, avisynth are ok as well. The fact that remuxing it in avidemux produces ok result in vdub suggests the actual script, libx264 encoding and aac encoding are ok



    Did you confirm what plugin is being used in vdub ? With the file loaded in vdub, file=>file information.

    I can open them (ffmpeg produced h.264/aac/mp4's with avs as input ) in vdub, with directshow driver, quicktime input driver, ffinputdriver . I think something is wrong with your vdub setup and/or plugins

    Do you have a shorter sample you can upload that fails opening in vdub? I can't get it to fail
    Last edited by poisondeathray; 15th Jun 2014 at 14:49.
    Quote Quote  
  28. DECEASED
    Join Date
    Jun 2009
    Location
    Heaven
    Search Comp PM
    Another possibility: "something" on Budman1's machine is interfering with VirtualDub.
    Maybe an "up-to-date" driver, perhaps a software recently installed/updated,
    maybe a poorly-written desktop gadget, or simply a setting in the Registry that should not exist ---

    --- go figure, Windows 7 is complicated like hell : - /
    Quote Quote  
  29. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    If it works okay for you there then it is beginning to look like my machine somewhere. I uploaded the original and the converted files and they can be downloaded at:

    Original
    Sarka Pancochova2014.mp4

    'bad'
    Sarka Pancochova2014_Frames_1_2.mp4

    If they both work on yours then that says my virtualdub only THINKS its frames numbers are wrong.
    Thanks
    Quote Quote  
  30. Yes I get the same frame number problem in vdub with the "bad" file, "Sarka Pancochova2014_Frames_1_2.mp4" with ffinputdriver, but directshow input plugin configured with lav filters works

    Was that the same avs script and ffmpeg commandline above used to produce the "bad" file ?
    Quote Quote  
Visit our sponsor! Try DVDFab and backup Blu-rays!