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:
It works and everything is ok, except: the first 1 or 2 seconds are... BLACK. No Video, just Audio...Code: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%"
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
+ Reply to Thread
Results 1 to 7 of 7
-
-
#1 try mp4box with -splitz option instead.
https://gpac.wp.imt.fr/mp4box/mp4box-documentation/
If you have the same problem post a sample.
About black video read very last paragraph: https://trac.ffmpeg.org/wiki/Seeking
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.
-
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.
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...? -
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%"
etc.
This is for 25 fps (1000ms/25 = 40ms).
/edit:
Reported to ffmpeg bug tracker.
https://trac.ffmpeg.org/ticket/6315Last edited by sneaker; 14th Apr 2017 at 07:55.
-
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
Code: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)
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.
Code:"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"
So far I haven't had any problems cutting this way or joining with black or distortions between joins -
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.
Similar Threads
-
How to Change Aspect Ratio of MP4 Video Without Re Encode using ffmpeg?
By morsh in forum Newbie / General discussionsReplies: 8Last Post: 11th Oct 2016, 03:08 -
Avidemux messing with aspect ratio
By Everend in forum EditingReplies: 1Last Post: 27th Sep 2016, 20:30 -
problem with avidemux change aspect ratio
By jalea148 in forum Video ConversionReplies: 2Last Post: 18th Oct 2015, 15:50 -
Aspect ratio of 1.375? Can Avidemux solve that?
By MovingParts in forum Newbie / General discussionsReplies: 14Last Post: 23rd Sep 2015, 13:40 -
FFMPEG help needed - trying to capture screenshots at correct aspect ratio
By bergqvistjl in forum Newbie / General discussionsReplies: 4Last Post: 12th Aug 2014, 11:30