VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 7 of 7
  1. Hi everybody,
    I am stuck and hopefully someone can show me great resolutions:

    Problem #1
    I want to cut a Video (MP4) with FFMpeg directly (no re-encoding) with this command:
    ffmpeg -ss 00:00:00 -i "%sourcefile%" -b 128k -map 0 -acodec copy -vcodec copy -async 1 -y -ss 00:05:00.000 -to 00:07:00.000 "%targetfile%"
    It works and everything is ok, except: the first 1 or 2 seconds are... BLACK. No Video, just Audio...
    Some people wrote is has to do with iframes or something...But: I opened the video with AviDemux to find to correct position (i.e. 00:06:12.405 ) to cut and tried the command with exact position-information, but there ist still a black screen for the first seconds...
    How to fix this?

    Problem #2
    I want to cut a Video with AviDemux (no re-encoding)
    The Video has 720x480 (AR 4:3)
    After the cutting, the Video has no information about the aspect ratio anymore..what makes some players to show the Video in a wrong Aspect Ratio.
    FFMpeg does preserve the information about the aspect ratio. Why not AviDemux...?

    This just makes me crazy. FFMpeg doesnt cut the video correctly without a black screen and avidemux doesnt preserve information about the aspect ratio.
    All i want is to cut a Video without re-encoding...

    Thank you for your help
    Quote Quote  
  2. #1 try mp4box with -splitz option instead.
    If you have the same problem post a sample.

    About black video read very last paragraph:
    Are you 100% sure you specified a keyframe? If so: post sample.

    #2 Sounds like a bug you should report to the AviDemux team.
    Last edited by sneaker; 14th Apr 2017 at 06:18.
    Quote Quote  
  3. Originally Posted by sneaker View Post
    About black video read very last paragraph:
    thank you, thats exactly the point that makes me confuse.
    Using -ss as input option together with -c:v copy might not be accurate since ffmpeg is forced to only use/split on i-frames. Though it will—if possible—adjust the start time of the stream to a negative value to compensate for that. Basically, if you specify "second 157" and there is no key frame until second 159, it will include two seconds of audio (with no video) at the start, then will start from the first key frame. So be careful when splitting and doing codec copy.
    Thats why I opened the Video with AviDemux to find a time position, where an iframe starts. AviDemux has two buttons to jump to next iframe...

    Still, with exact time position, there is still a black screen. Is it possible just to tell FFMpeg to select the nearest iframe to the wished time position...?
    Quote Quote  
  4. Hmm... I think I can reproduce the problem. Probably has something to do with the edit lists/CTS of the mp4 container. Looks like an ffmpeg bug. But without a sample I can't tell if it's the same problem.

    As a work-around you can try slightly incrementing starting time like this:
    ffmpeg -ss 00:05:00.040 -i "%sourcefile%" -map 0 -c copy -to 00:02:00.000 "%targetfile%"
    ffmpeg -ss 00:05:00.080 -i "%sourcefile%" -map 0 -c copy -to 00:02:00.000 "%targetfile%"
    ffmpeg -ss 00:05:00.120 -i "%sourcefile%" -map 0 -c copy -to 00:02:00.000 "%targetfile%"
    This is for 25 fps (1000ms/25 = 40ms).

    Reported to ffmpeg bug tracker.
    Last edited by sneaker; 14th Apr 2017 at 07:55.
    Quote Quote  
  5. Member Budman1's Avatar
    Join Date
    Jul 2012
    Search Comp PM
    Be sure of the exact time for the Keyframe ("I Frame"). I use Avisynth to display the video and display the Keyframe type at the bottom

    FFmpegSource2("C:\Users\Bud\Desktop\Beautiful Romantic Spanish Guitar Music.mp4", atrack=-1).Crop(0,0,-0,-0)
    ScriptClip(Last, """Subtitle("[ "+Chr(FFPICT_TYPE)+" ]", size=(Height*56.0/720), align=2)""", after_frame=true)
    Subtitle("C:\Users\Bud\Desktop\Various test Formats\Beautiful Romantic Spanish Guitar Music.mp4", x=480, y=200, font="Arial", size=24, text_color=$ff0000, align=3)
    ShowFrameNumber(scroll=true, x=10, y=27, font="Arial", size=24, text_color=$ff0000)
    ShowTime(x=72, y=44, font="Arial", size=24, text_color=$ff0000)
    ShowSMPTE(fps=29.97, x=68, y=61, font="Arial", size=24, text_color=$ff0000)
    Click image for larger version

Name:	Key Frame.jpg
Views:	69
Size:	72.7 KB
ID:	41249

    Then verify this by retrieving a list with ffmpeg. FFmpeg sometimes adds a decimal to the times, consistant throughout and starting at Frame "0", so I just subtract as shown to verify with Player times.

    "C:\Users\Bud\Desktop\ffmpeg.exe" -i "C:\Users\Bud\Desktop\Various test Formats\Beautiful Romantic Spanish Guitar Music.mp4" -vf select="eq(pict_type\,PICT_TYPE_I)" -vsync 2 -f null NUL -loglevel debug 2>&1| for /f "tokens=4,8,9 delims=. " %d in ('findstr "pict_type:I"') do echo %d %e.%f>>"C:\Users\Bud\Desktop\Beautiful Romantic Spanish Guitar Music_KeyFrames.txt"
    Click image for larger version

Name:	Key Frame 2.jpg
Views:	78
Size:	105.9 KB
ID:	41250

    So far I haven't had any problems cutting this way or joining with black or distortions between joins
    Quote Quote  
  6. if you want exact cutting do this: ffmpeg -i imput.whatever -ss 00:00;00.00 -t 00:00:00.00.
    so the -ss option after the inputfile
    Quote Quote  
  7. Member Budman1's Avatar
    Join Date
    Jul 2012
    Search Comp PM
    Searching after the input with ffmpeg is accurate but if you do not reencode as is the wish, theres no telling what may display on playback since the first frames may be incomplete B or P frames. Im not sure if ffmpeg will even allow this if you do a vcodec copy.
    Quote Quote  

Similar Threads