[mythtvnz] Cutting H.264 DVB-T files with ffmpeg without transcoding
Craig Blaikie
craig at gregor.co.nz
Tue Jul 20 12:30:09 BST 2010
On 18/07/10 15:19, David Moore wrote:
> Jonathan Hoskin wrote:
>> Anybody worked out a reliable way to cut recordings from Freeview
>> terrestrial using ffmpeg?
>>
>>
>> Nope. I wonder if the developers have properly addressed it / been made
>> aware of it.
>>
>>
>
> I've seen a lot of posts from (I think) ffmpeg devs on various lists
> which seem to say "too bad, it's the recording that's bad, not a bug in
> ffmpeg".
>
>> ffmpeg -async 1 -ss [start time] -t [duration] -i recording.mpg
-vcodec
>>
>> copy -acodec ac3 -ab 384k -f dvd cut_recording.mpg
>>
>> The "-async 1" seems to be needed to keep audio in sync with video.
The
>> "-f dvd" might (not sure yet) be a fix for av mux errors. Audio is
>> transcoded to AC3 since most channels only have LATM AAC audio.
>>
>>
>> "-f dvd" uses a MPEG2-PS container - H.264 isn't supported in the
>> MPEG-PS file format:
>> http://www.gossamer-threads.com/lists/mythtv/mythtvnz/417130#417130
>>
>>
>
> Thanks for that. I have tried MPEG-TS format as well but also with no
> joy. Latest semi-successful attempts have involved extracting the video
> to raw H264 format and transcoding the audio to raw AC3 then remuxing to
> mpg (without the -f dvd option). Unfortunately I get audio/video sync
> problems now. I don't see how I can easily resolve this because (I
> assume) the raw formats have no timestamps or have timestamps which are
> slightly out of sync.
>
> Seems that timestamps may be the root of the problem because I was
> previously getting the ffmpeg "non-monotone timestamp" error and weird
> start times reported by ffmpeg. I have no idea how to fix this without a
> lot of manual audio/video syncing
>
>Look for the "P"s and "B"s from peoples lips, they're percussive sounds
>and you can sync the "P"s and "B"s from the audio to them - the attack
>of the audio should match the 1st frame the lips part. Unless the rate
>of picture and audio vary against each other, you should only have to do
>this once per recording:)
>Have fun.
>M.
Found a problem clip in my system where the audio and video timestamps? are
out of sync at the beginning, if played in VLC the video pauses on the start
frame for a second, while the audio keeps playing. Once the video starts,
the audio is in sync, and it all looks normall. This always seemed to make
the final video that came out from ffmpeg to have video and audio that was
out of sync, and a -vsync 1 inserted into the ffmpeg command line fixed it
for me. Not sure if it would work for you as you are cutting, not encoding,
but worth a try.
The -vsync 1 command makes ffmpeg insert/drop frames until everything
matches.
Cheers,
Craig
More information about the mythtvnz
mailing list