Hello everyone,
I'm French so sorry if I do not speak english properly.
I developped conversion software for my personal needs and I'm looking for a very long way to convert TS videos (MPEG2 and MPEG4/AVC) with Avisynth + FFmpeg without désynchronization.
If I directly use FFmpeg without Avisynth with this method is perfectly synchronized audio.
But with a script. Avs (Avisynth) in input of FFMPEG I can not get a. Mp4 file with synchronized audio. Indeed, when reading the beginning of the mp4 file is correctly synchronized but in the end there is an offset of about 10s. If I played this same script with Windows Media Player, playback is synchronized.
The script avisynth I use is very simple:
FFMPEG command line that I use for my test is also very simple:Code:DirectShowSource ("D:\videoSD.ts" convertfps = False) Clip1 = Trim (100, 98500) Return Clip1
(I added the parameter : -pix_fmt for MPEG2 videos)Code:ffmpeg -y -i D:\videoSD0.avs -pix_fmt yuv420p D:\videoSD0.mp4
Do you know how to encode these videos without désynchonisation? I tried several tools but without result, the synchronization is always (DGIndex, DGAVCIndex, FFmpegSource) and also software (MeGUI, Avanti-Gui, M4ng, XMediaRecode). Only XmediaRecode works but I must use Avisynth + FFMpeg.
Thank you very much if you can help me....
+ Reply to Thread
Results 1 to 15 of 15
-
-
you stream probably has some broken headers which will make it vfr
-> run it througj ProjectX (if the video is MPEG-2), VideoRedo or similar Software to get rid of potentially wrong timecodes.
If that is not an option, remux the stream before you convert it to mkv and use ffvideosource or LWLibavVideoSource as source filter in avisynth.
If you post a small sample which you can't convert, others can probably post an example script for you.Last edited by Selur; 26th Aug 2013 at 03:49.
-
Hello, I tried 2 opérations with ProjectX :
1 - Conversion to TS: I got a new TS file, reading the file in Windows Media Player is not correct. The player jumps entire scenes and playing time is 40 minutes (the original video is 1h54m56s).
2 - Demux: I got two files (m2v and mp2). Reading these two mp2 Windows Media Player file looks correct but the total length indicated by WMP is 40 minutes for the m2v file. (Project X eliminates useless B-Frames and rewritten the PTS time but I'm not sure that these times are correct).
Is it the correct way ? What should I do next?
Thank you very much if you can help me again. -
If the output is 40min instead of 1h54m56s it looks like your video probably is broken in a lot of places.
-> Can you playback the input file without a problem? From the looks of it, it should be really broken.
It might help to remux the file with ffmpeg before processing it:
Code:ffmpeg -i "Path to input" -acodec copy -vcodec copy "Path to output file"
-
Hello, I execute the FFmpeg command then I converted to TS with ProjectX as the last time. Now the total time indicated is 1h54m58s but when playing with WMP, it skips a lot of scenes like the last time (the duration of the scenes do not exceed 1s what makes reading very difficult).
-> Can you playback the input file without a problem? From the looks of it, it should be really broken.
Meanwhile I await your suggestions. -
try remuxing the stream with mkvtoolnix (mmg) and check if the output mkv plays fine.
-
Well, I opened. the M2V files. and Mp2 created with ProjectX as sources of mkvtoolnix. And then multiplexed. in mkv. The. Mkv is correct synch is ok.
How can I replicate this process in my software. I have to use AviSynth and FFmpeg.
Thank you very much and I look forward to following your suggestions.
I am ready for further testing. -
Okay, since the mkv plays fine your problem seems to be with the source filter you are using.
-> Have you tried FFVideoShow and LWLibavVideoSource as alternatives to DirectShowSource, like I suggested before?
If it doesn't work with these you could also try MPEG2Source and DGSource.
It none of these work, you can try if it works if you use the mkv as source for your avisynth script.
(Unsure why you use Avisynth at all since trimming could be done with ffmpeg and ffmpeg might be better in handling the source than DirectShowSource,...)
You can't. Neither Avisynth nor FFmpeg can fix transport streams like ProjectX can.
-> How you adjust your software is up to you,.... -
Hello,
Sorry for the delay but I did a lot of coding to try your solutions.
So here are my results:
with a script FFVideoSource like this :
Code:LoadCPlugin("D:\ffms2.dll") File = "D:\videoSD.ts" V = FFVideoSource(File) A = FFAudioSource(File, track=1) Video = AudioDub(V, A) Clip1 = Trim(Video, 100, 88500) Return Clip1
with a script LWLibavVideoSource like this :
Code:LoadPlugin("D:\LSMASHSource.dll") File = "D:\videoSD.ts" V = LWLibavVideoSource(File) A = LWLivavAudioSource(File) ou (File, av_sync=true) Video = AudioDub(V, A) Clip1 = Trim(Video, 100, 88500) Return Clip1
with a script Mpeg2Source like this :
Code:LoadPlugin("D:\DGDecode.dll") LoadCPlugin("D:\ffms2.dll") V = mpeg2Source("D:\videoSD.d2v") A = FFAudioSource("D:\videoSD.ts", track=1) Video = AudioDub(V, A) Clip1 = Trim(Video, 100, 88500) Return Clip1
(I did not test DGSource, DGSource needs a d2v file that I wanted to create with DGIndexNV but it requires a license).
I also tried the mkv source as entry for avisynth. The result is worse, in fact, the video track is played two times too fast while the audio track is played normally.
So if I summarize the situation, with my type of video, it seems not to be possible to use Avisynth as input stream for FFMpeg. Thank you to confirm or review.
But I would like to respond to your question because this is exactly the reason for what i use Avisynth. In fact I wanted to use Avisynth as an alternative to cutting videos with my own algoryhtme in my software, it works well but is not totally perfect. It produces some artifacts in the place of cutting occurred. I know how to do one cut with FFmpeg but for several cutting I do not know if this is possible and I do not know what FFmpeg command must be used.
If you know how to do that interest me a lot, I could in this case reject Avisynth.
Thank you if you can help me again. -
a. When you try LWLivavAudioSource try with repeat=true.
b. FFmpeg only supports a single cut. (mencoder and using an edl file should support multiple cuts)
----
btw. just to have mentioned it, you know that you could:
if the files contain MPEG-2 video:
1. demux with ProjectX
2. Cut&Remux using Cuttermaran
if the files contain MPEG-4 AVC video:
1. remux with mkvmerge
2. cut with MKVCutter
(+ there are also some commerical solutions like VideoRedo)
Cu Selur -
Hi, I Thank you very much for your help.
I do a lot of testing before deciding what solutions I use to implementer then in my software.
As you suggest I have to use different tools depending on the type of MPEG2 video or MPEG4/AVC and as you wrote it does not seem possible to use some software like ProjectX for my software (the software that you mentioned work with DOS command line?).
So I do not really see a solution for me except maybe this:
with "concat demuxer" or "contact protocol" :
http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20concatenate%20(join%2C%20merge)%20media%20files
http://www.bruzgys.eu/blog/2013/01/split-and-concatenate-videos-with-ffmpeg-its-trivial/
Do you think this is a viable solution for my software? the vidéo i use are all in .ts files. I would be interrested to have your views and find out which solutions are most likely to operate correctly (without synchronization and minimum artifacts at break points)?
EDIT : i add command : repeat=true in LWLivavVideoSource ( not LWLivavAudioSource) but i have the same issue.Last edited by Chris33; 26th Aug 2013 at 15:39.
-
ProjectX can be used through the command line, Cuttermaran not iirc.
Do you think this is a viable solution for my software? the vidéo i use are all in .ts files. I would be interrested to have your views and find out which solutions are most likely to operate correctly (without synchronization and minimum artifacts at break points)?
If you want frame accurate cutting, which requires at least partial reencoding thing get more tricky.
Since Avisynth seemed to be an option to you, I guess you plan to reencode anyway, so creating multiple cut outputs and join them at the end might be an option for you too. -
Ok, in a previous post you have mentionned MKVCutter for the cuts. and in the last post you have mentionned mkvmerge for cuts. Are you sure i can use mkvmerge for cuting video ? i don't find this feature in this software.
So Mkv containers seems to be the containers privileged to do what i need. I suppost that can apply for both type Mpeg2 or Mpeg4/AVC. (Thank you to confirm if i write a mistake).
EDIT : yes i need to rencode Anyway in Mp4 or Mkv to reduce size of video.
Anyway, thank you very much for your response because I do not have enough knowledge in video and your help is invaluable. I think I will first try the FFmpeg commands to cut and join videos. It seems to be the easiest to implementer in my software.
It is possible that I repost a new request on the site if I meet a new problem. -
Are you sure i can use mkvmerge for cuting video ?
Read "2.5. File splitting, linking, appending and concatenation (more global options" over at http://www.bunkus.org/videotools/mkvtoolnix/doc/mkvmerge.htmlLast edited by Selur; 26th Aug 2013 at 17:51.
Similar Threads
-
ffmpeg conversion from *.MOV to *.MP4 not possible?
By pxstein in forum Newbie / General discussionsReplies: 7Last Post: 5th Sep 2013, 05:34 -
Why Handbrake and FFmpeg MP4/x.264 conversion speeds are so different?
By falco2000 in forum Video ConversionReplies: 4Last Post: 30th Sep 2012, 09:10 -
ffmpeg help... convert mp4 to jpeg array, and back to mp4 - problem!
By SaskVideoMaker in forum Video ConversionReplies: 2Last Post: 4th Feb 2011, 04:53 -
FFMpeg - Mpeg2 to MP4 conversion
By gomer_3333 in forum Video ConversionReplies: 2Last Post: 1st Mar 2010, 13:10 -
converting MOD to AVI to MP4 using avisynth, x264, mp4box & ffmpeg
By Wakewatcher in forum Video ConversionReplies: 3Last Post: 27th Dec 2008, 16:58