Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: MythTV: Mythtvnz

Re: Cutting H.264 DVB-T files with ffmpeg without transcoding

 

 

First page Previous page 1 2 Next page Last page  View All MythTV mythtvnz RSS feed   Index | Next | Previous | View Threaded


dmoo1790 at ihug

Jul 17, 2010, 8:19 PM

Post #1 of 29 (2804 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding

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. I wonder how myth copes with the same
recordings when ffmpeg has problems? Might have to dig into the myth and
ffmpeg source code to try and find the differences.

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


craig at gregor

Jul 18, 2010, 5:17 AM

Post #2 of 29 (2731 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

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


David Moore wrote
>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. I wonder how myth copes with the same
>recordings when ffmpeg has problems? Might have to dig into the myth and
>ffmpeg source code to try and find the differences.

You could try using vlc, as I found it was able to play the recorded video
files with sound, use it to convert the audio to mp4a and then use ffmpeg to
do the cutting or compression, I know it's an extra step, and you end
needing free space to have an almost identical copy of the file there, but
it seems to work, and the audio appears to stay in sync. I couldn't get VLC
to cut and convert the video without totally messing it up, hence the extra
ffmpeg step.

Use command line version of VLC to copy video and transcode audio.

nice -n 15 cvlc input_filename.mpg --sout="#transcode{acodec=mp4a, ab=192,
channels=2, samplerate=48000}:standard{mux=ts, dst=temp_filename.mp4,
access=file}:sout-transcode-soverlay=0" vlc://quit

then use ffmpeg to cut, or in this example, convert to iPod.

nice -n 15 ffmpeg -i temp_filename.mp4 -vcodec libxvid -b 512kb -qmin 3
-qmax 5 -bufsize 4096 -g 300 -acodec libfaac -ab 192kb -s 736x416 -aspect
16:9 output_filename.mp4

Cheers,
Craig



_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


nick.rout at gmail

Jul 18, 2010, 9:41 PM

Post #3 of 29 (2711 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

On Mon, Jul 19, 2010 at 12:17 AM, Craig Blaikie <craig [at] gregor> 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
>
>
> David Moore wrote
>>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. I wonder how myth copes with the same
>>recordings when ffmpeg has problems? Might have to dig into the myth and
>>ffmpeg source code to try and find the differences.
>
> You could try using vlc, as I found it was able to play the recorded video
> files with sound, use it to convert the audio to mp4a and then use ffmpeg to
> do the cutting or compression, I know it's an extra step, and you end
> needing free space to have an almost identical copy of the file there, but
> it seems to work, and the audio appears to stay in sync. I couldn't get VLC
> to cut and convert the video without totally messing it up, hence the extra
> ffmpeg step.
>
> Use command line version of VLC to copy video and transcode audio.
>
> nice -n 15 cvlc input_filename.mpg --sout="#transcode{acodec=mp4a, ab=192,
> channels=2, samplerate=48000}:standard{mux=ts, dst=temp_filename.mp4,
> access=file}:sout-transcode-soverlay=0" vlc://quit
>
> then use ffmpeg to cut, or in this example, convert to iPod.
>
> nice -n 15 ffmpeg -i temp_filename.mp4 -vcodec libxvid -b 512kb -qmin 3
> -qmax 5 -bufsize 4096 -g 300 -acodec libfaac -ab 192kb -s 736x416 -aspect
> 16:9 output_filename.mp4

Has anyone tried SmartLabs tsMuxeR? It seems to be designed for these
types of files, but it seems to only be able to do a single cut (ie a
start and end cut, meaning you only get one chunk of the file.) (at
least in the windows gui version).

But I guess a script could run over the file several times, cutting
out each "non advert bit" and then stitch them back together.

Can anyone point me to a suitable file to try it out on?

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


dmoo1790 at ihug

Jul 18, 2010, 9:46 PM

Post #4 of 29 (2774 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

Craig Blaikie 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
>
>
> David Moore wrote
>> 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. I wonder how myth copes with the same
>> recordings when ffmpeg has problems? Might have to dig into the myth and
>> ffmpeg source code to try and find the differences.
>
> You could try using vlc, as I found it was able to play the recorded video
> files with sound, use it to convert the audio to mp4a and then use ffmpeg to
> do the cutting or compression, I know it's an extra step, and you end
> needing free space to have an almost identical copy of the file there, but
> it seems to work, and the audio appears to stay in sync. I couldn't get VLC
> to cut and convert the video without totally messing it up, hence the extra
> ffmpeg step.
>
> Use command line version of VLC to copy video and transcode audio.
>
> nice -n 15 cvlc input_filename.mpg --sout="#transcode{acodec=mp4a, ab=192,
> channels=2, samplerate=48000}:standard{mux=ts, dst=temp_filename.mp4,
> access=file}:sout-transcode-soverlay=0" vlc://quit
>
> then use ffmpeg to cut, or in this example, convert to iPod.
>
> nice -n 15 ffmpeg -i temp_filename.mp4 -vcodec libxvid -b 512kb -qmin 3
> -qmax 5 -bufsize 4096 -g 300 -acodec libfaac -ab 192kb -s 736x416 -aspect
> 16:9 output_filename.mp4
>
> Cheers,
> Craig
>

Thanks Craig. Your advice about using VLC helped a lot. I still took a
while to fully solve my problems though. What I wanted to do was snip
about 15 mins off the end of one recording and then join it to another
recording. Here is what I did:


Step 1: Transcode the whole of the first file with VLC:

cvlc 2 file1.mpg :sout="#transcode{acodec=a52, ab=384, channels=2,
samplerate=48000}:standard{mux=ps, dst=file1a.mpg,
access=file}:sout-transcode-soverlay=0" vlc://quit

Step 2: Snip the end off the transcoded file with ffmpeg:

ffmpeg -async 1 -ss 01:55:17 -i file1a.mpg -vcodec copy -acodec copy
file1b.mpg

Step 3: Transcode the second file with VLC:

cvlc file2.mpg --sout="#transcode{acodec=a52, ab=384, channels=2,
samplerate=48000}:standard{mux=ps, dst=file2a.mpg,
access=file}:sout-transcode-soverlay=0" vlc://quit

Step 4: Fix the timestamps in file2a so that they start just after the
end of file1b. (Before I did this ffmpeg reported a start time of around
8800 seconds for file2a!? I've seen this sort of thing on lots of my
recordings.)

ffmpeg -itsoffset 881.58 -i file2a.mpg -vcodec copy -acodec copy file2b.mpg

Step 5: Cat the two files into the final product:

cat file1b.mpg file2b.mpg > final_file.mpg


This may not be the most efficient way to get what I wanted but the end
result looks good with only a minor glitch at the join, good audio/video
sync and is seekable.

I found the vlc "mux=ps" option to be a lot faster than "mux=ts".

The ffmpeg "itsoffset" option didn't work as I expected. It seems to
need an absolute time, not an offset time. The value I entered ended up
as the value for the start time of the second file. This value was the
length of the first file so "catting" the files together ended up with
good timestamps in the final file, if you follow what I'm trying to say.

I'm still pretty sure that most of my problems are due to bad
timestamps. Need to do more tests to find a final solution.

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


stephen_agent at jsw

Jul 18, 2010, 10:29 PM

Post #5 of 29 (2717 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

On Mon, 19 Jul 2010 16:46:02 +1200, you wrote:

>Craig Blaikie 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
>>
>>
>> David Moore wrote
>>> 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. I wonder how myth copes with the same
>>> recordings when ffmpeg has problems? Might have to dig into the myth and
>>> ffmpeg source code to try and find the differences.
>>
>> You could try using vlc, as I found it was able to play the recorded video
>> files with sound, use it to convert the audio to mp4a and then use ffmpeg to
>> do the cutting or compression, I know it's an extra step, and you end
>> needing free space to have an almost identical copy of the file there, but
>> it seems to work, and the audio appears to stay in sync. I couldn't get VLC
>> to cut and convert the video without totally messing it up, hence the extra
>> ffmpeg step.
>>
>> Use command line version of VLC to copy video and transcode audio.
>>
>> nice -n 15 cvlc input_filename.mpg --sout="#transcode{acodec=mp4a, ab=192,
>> channels=2, samplerate=48000}:standard{mux=ts, dst=temp_filename.mp4,
>> access=file}:sout-transcode-soverlay=0" vlc://quit
>>
>> then use ffmpeg to cut, or in this example, convert to iPod.
>>
>> nice -n 15 ffmpeg -i temp_filename.mp4 -vcodec libxvid -b 512kb -qmin 3
>> -qmax 5 -bufsize 4096 -g 300 -acodec libfaac -ab 192kb -s 736x416 -aspect
>> 16:9 output_filename.mp4
>>
>> Cheers,
>> Craig
>>
>
>Thanks Craig. Your advice about using VLC helped a lot. I still took a
>while to fully solve my problems though. What I wanted to do was snip
>about 15 mins off the end of one recording and then join it to another
>recording. Here is what I did:
>
>
>Step 1: Transcode the whole of the first file with VLC:
>
>cvlc 2 file1.mpg :sout="#transcode{acodec=a52, ab=384, channels=2,
>samplerate=48000}:standard{mux=ps, dst=file1a.mpg,
>access=file}:sout-transcode-soverlay=0" vlc://quit
>
>Step 2: Snip the end off the transcoded file with ffmpeg:
>
>ffmpeg -async 1 -ss 01:55:17 -i file1a.mpg -vcodec copy -acodec copy
>file1b.mpg
>
>Step 3: Transcode the second file with VLC:
>
>cvlc file2.mpg --sout="#transcode{acodec=a52, ab=384, channels=2,
>samplerate=48000}:standard{mux=ps, dst=file2a.mpg,
>access=file}:sout-transcode-soverlay=0" vlc://quit
>
>Step 4: Fix the timestamps in file2a so that they start just after the
>end of file1b. (Before I did this ffmpeg reported a start time of around
>8800 seconds for file2a!? I've seen this sort of thing on lots of my
>recordings.)
>
>ffmpeg -itsoffset 881.58 -i file2a.mpg -vcodec copy -acodec copy file2b.mpg
>
>Step 5: Cat the two files into the final product:
>
>cat file1b.mpg file2b.mpg > final_file.mpg
>
>
>This may not be the most efficient way to get what I wanted but the end
>result looks good with only a minor glitch at the join, good audio/video
>sync and is seekable.
>
>I found the vlc "mux=ps" option to be a lot faster than "mux=ts".
>
>The ffmpeg "itsoffset" option didn't work as I expected. It seems to
>need an absolute time, not an offset time. The value I entered ended up
>as the value for the start time of the second file. This value was the
>length of the first file so "catting" the files together ended up with
>good timestamps in the final file, if you follow what I'm trying to say.
>
>I'm still pretty sure that most of my problems are due to bad
>timestamps. Need to do more tests to find a final solution.

Just using cat to join those files is not valid. There are headers on
the front of each file .mpg file. So you will probably get a playback
glitch when the second set headers gets read as bad data.

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


dmoo1790 at ihug

Jul 18, 2010, 10:58 PM

Post #6 of 29 (2777 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

Stephen Worthington wrote:
> On Mon, 19 Jul 2010 16:46:02 +1200, you wrote:
>
>> Craig Blaikie 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
>>>
>>> David Moore wrote
>>>> 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. I wonder how myth copes with the same
>>>> recordings when ffmpeg has problems? Might have to dig into the myth and
>>>> ffmpeg source code to try and find the differences.
>>> You could try using vlc, as I found it was able to play the recorded video
>>> files with sound, use it to convert the audio to mp4a and then use ffmpeg to
>>> do the cutting or compression, I know it's an extra step, and you end
>>> needing free space to have an almost identical copy of the file there, but
>>> it seems to work, and the audio appears to stay in sync. I couldn't get VLC
>>> to cut and convert the video without totally messing it up, hence the extra
>>> ffmpeg step.
>>>
>>> Use command line version of VLC to copy video and transcode audio.
>>>
>>> nice -n 15 cvlc input_filename.mpg --sout="#transcode{acodec=mp4a, ab=192,
>>> channels=2, samplerate=48000}:standard{mux=ts, dst=temp_filename.mp4,
>>> access=file}:sout-transcode-soverlay=0" vlc://quit
>>>
>>> then use ffmpeg to cut, or in this example, convert to iPod.
>>>
>>> nice -n 15 ffmpeg -i temp_filename.mp4 -vcodec libxvid -b 512kb -qmin 3
>>> -qmax 5 -bufsize 4096 -g 300 -acodec libfaac -ab 192kb -s 736x416 -aspect
>>> 16:9 output_filename.mp4
>>>
>>> Cheers,
>>> Craig
>>>
>> Thanks Craig. Your advice about using VLC helped a lot. I still took a
>> while to fully solve my problems though. What I wanted to do was snip
>> about 15 mins off the end of one recording and then join it to another
>> recording. Here is what I did:
>>
>>
>> Step 1: Transcode the whole of the first file with VLC:
>>
>> cvlc 2 file1.mpg :sout="#transcode{acodec=a52, ab=384, channels=2,
>> samplerate=48000}:standard{mux=ps, dst=file1a.mpg,
>> access=file}:sout-transcode-soverlay=0" vlc://quit
>>
>> Step 2: Snip the end off the transcoded file with ffmpeg:
>>
>> ffmpeg -async 1 -ss 01:55:17 -i file1a.mpg -vcodec copy -acodec copy
>> file1b.mpg
>>
>> Step 3: Transcode the second file with VLC:
>>
>> cvlc file2.mpg --sout="#transcode{acodec=a52, ab=384, channels=2,
>> samplerate=48000}:standard{mux=ps, dst=file2a.mpg,
>> access=file}:sout-transcode-soverlay=0" vlc://quit
>>
>> Step 4: Fix the timestamps in file2a so that they start just after the
>> end of file1b. (Before I did this ffmpeg reported a start time of around
>> 8800 seconds for file2a!? I've seen this sort of thing on lots of my
>> recordings.)
>>
>> ffmpeg -itsoffset 881.58 -i file2a.mpg -vcodec copy -acodec copy file2b.mpg
>>
>> Step 5: Cat the two files into the final product:
>>
>> cat file1b.mpg file2b.mpg > final_file.mpg
>>
>>
>> This may not be the most efficient way to get what I wanted but the end
>> result looks good with only a minor glitch at the join, good audio/video
>> sync and is seekable.
>>
>> I found the vlc "mux=ps" option to be a lot faster than "mux=ts".
>>
>> The ffmpeg "itsoffset" option didn't work as I expected. It seems to
>> need an absolute time, not an offset time. The value I entered ended up
>> as the value for the start time of the second file. This value was the
>> length of the first file so "catting" the files together ended up with
>> good timestamps in the final file, if you follow what I'm trying to say.
>>
>> I'm still pretty sure that most of my problems are due to bad
>> timestamps. Need to do more tests to find a final solution.
>
> Just using cat to join those files is not valid. There are headers on
> the front of each file .mpg file. So you will probably get a playback
> glitch when the second set headers gets read as bad data.
>

I'm not sure how significant the mpg headers are but the file does play
with only a small glitch at the join and the time/duration reported by
myth as it plays is correct. The glitch may be due to missing frames in
the original recording and it is very minor and would be hard to spot if
I didn't kow where it was.

I have seen other stuff on the web that says you can cat mpg files but
the timestamps in the final file need reprocessing. This is essentially
what I did by processing the second file so that it had timestamps
starting at the duration of the first file. Not saying my method is
fool-proof but seems to work so far.

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


stevehodge at gmail

Jul 18, 2010, 11:07 PM

Post #7 of 29 (2714 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

On Mon, Jul 19, 2010 at 5:58 PM, David Moore <dmoo1790 [at] ihug> wrote:

> Stephen Worthington wrote:
> > Just using cat to join those files is not valid. There are headers on
> > the front of each file .mpg file. So you will probably get a playback
> > glitch when the second set headers gets read as bad data.
> >
>
> I'm not sure how significant the mpg headers are but the file does play
> with only a small glitch at the join and the time/duration reported by
> myth as it plays is correct. The glitch may be due to missing frames in
> the original recording and it is very minor and would be hard to spot if
> I didn't kow where it was.
>
> I have seen other stuff on the web that says you can cat mpg files but
> the timestamps in the final file need reprocessing. This is essentially
> what I did by processing the second file so that it had timestamps
> starting at the duration of the first file. Not saying my method is
> fool-proof but seems to work so far.
>

Are those TS or PS files? If they are TS files then cat should be fine. If
they are PS then there is a header and you'd be better off using something
designed for the purpose.

Cheers,
Steve


mstuff at read

Jul 20, 2010, 2:34 AM

Post #8 of 29 (2677 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

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.


--
Morgan Read
NEW ZEALAND
<mailto:mstuffATreadDOTorgDOTnz>

fedora + freedom; fact || fiction?
http://fedoraproject.org/wiki/Overview
get freed-ora!
http://www.fsfla.org/svnwiki/selibre/linux-libre/freed-ora

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


craig at gregor

Jul 20, 2010, 4:30 AM

Post #9 of 29 (2727 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

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



_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


dmoo1790 at ihug

Jul 20, 2010, 6:06 PM

Post #10 of 29 (2679 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

Craig Blaikie wrote:
>
> 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
>
Thanks Craig. I have tried the various vsync and async options before. I
use "-async 1" most of the time and that works fine _if_ ffmpeg
doesn't choke on the recording. The sync options don't help if ffmpeg
hangs or fails in some other catastrophic way.

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


dmoo1790 at ihug

Jul 20, 2010, 6:10 PM

Post #11 of 29 (2672 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

Morgan Read wrote:
>
> 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.
>
Thanks Morgan. Another technique I have used to check sync is percussive
sounds like clapping, gunshots or similar. But I only use these to check
the final product. I don't really want to manually sync reordings if I
can avoid it which I have so far done albeit with a fair bit of hoop
jumping. :-)

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


dmoo1790 at ihug

Jul 20, 2010, 6:37 PM

Post #12 of 29 (2671 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

Thanks everyone for the feedback. I have discovered a few useful things:

- When using the itsoffset option in ffmpeg combined with cutting a
section of a recording you need to add the offset to the total time you
want to cut. For example, cutting 600s from 1000s into a recording and
offsetting the timestamps 300s at the same time means you need something
like this: "ffmpeg -ss 1000 -t 900 -itsoffset 300 -i file......." Note
the "-t 900", not "-t 600".

- I solved one recording that ffmpeg could not cut by first running the
whole recording through ffmpeg like this:

ffmpeg -async 1 -i infile.mpg -vcodec copy -acodec copy -map 0.0:0.2
-map 0.2 outfile.mpg

and then cutting it like this:

ffmpeg -ss [start time] -t [duration] -i outfile.mpg -vcodec copy
-acodec copy outfile2.mpg

This was a TV3 recording with an AC3 audio track so I did not need to do
any transcoding.

- I have successfully joined two videos so far using the method
described in an earlier post where I cat files together after adjusting
the timestamps in the second file. The first step is to process the
files with vlc like this:

cvlc infile.mpg --sout '#transcode{acodec=a52, ab=384, channels=2,
samplerate=48000}:standard{mux=ps, dst=outfile.mpg, access=file}' vlc://quit

Funny thing is that the vlc web site says the ps mux handles mpeg 1/2
but it seems to also handle h264 fine and seems to be faster than the ts
mux.

Lots more to learn no doubt. :-) All feedback appreciated.

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


ross.jemima at gmail

Jul 21, 2010, 1:28 AM

Post #13 of 29 (2648 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

David Moore wrote:
> Lots more to learn no doubt. :-) All feedback appreciated.
>

Have you considered putting a script together which could be run as a
user job? Then some of those of us that are interested in getting this
to work could do some actual testing and spread the workload.

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


jonathan.hoskin at gmail

Jul 21, 2010, 1:32 AM

Post #14 of 29 (2650 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

> Have you considered putting a script together which could be run as a
> user job? Then some of those of us that are interested in getting this
> to work could do some actual testing and spread the workload.


+1 to that


dmoo1790 at ihug

Jul 21, 2010, 3:48 AM

Post #15 of 29 (2648 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

Ross and Jemima Knudsen wrote:
> David Moore wrote:
>> Lots more to learn no doubt. :-) All feedback appreciated.
>>
>
> Have you considered putting a script together which could be run as a
> user job? Then some of those of us that are interested in getting this
> to work could do some actual testing and spread the workload.
>

I guess so. What exactly would you like to do? If you mean a myth user
job that runs automatically for every recording then I'm not sure what
you have in mind. Or do you mean a script you run from the command line,
e.g., to trim recordings or join recordings?

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


ross.jemima at gmail

Jul 21, 2010, 12:00 PM

Post #16 of 29 (2636 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

David Moore wrote:
> I guess so. What exactly would you like to do? If you mean a myth user
> job that runs automatically for every recording then I'm not sure what
> you have in mind. Or do you mean a script you run from the command line,
> e.g., to trim recordings or join recordings?
>

See this link:

http://www.mythtv.org/wiki/User_Jobs

Basically you write a script in what ever language you want and what you
would normally type into the command line is what you would put into the
user job setup and Myth will run the job either automatically or you can
manually select it to run. The above link shows that there are some
variables which Myth can provide to make it work generically (eg
filename, filepath)

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


dmoo1790 at ihug

Jul 21, 2010, 5:01 PM

Post #17 of 29 (2640 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

Ross and Jemima Knudsen wrote:
>
> David Moore wrote:
>> I guess so. What exactly would you like to do? If you mean a myth user
>> job that runs automatically for every recording then I'm not sure what
>> you have in mind. Or do you mean a script you run from the command line,
>> e.g., to trim recordings or join recordings?
>>
>
> See this link:
>
> http://www.mythtv.org/wiki/User_Jobs
>
> Basically you write a script in what ever language you want and what you
> would normally type into the command line is what you would put into the
> user job setup and Myth will run the job either automatically or you can
> manually select it to run. The above link shows that there are some
> variables which Myth can provide to make it work generically (eg
> filename, filepath)
>

Yes I understand that. Sorry but what I meant was what is your end
objective of running the user job? Transcode? Cut? Something else?
Wouldn't be too hard to script the transcoding using a similar technique
to Craig B's hdvideo2ipod.sh script. Cutting would be harder because (I
think) it would involve sql to access the cutlist in the myth database.
I'm a fairly basic sql user and I haven't used it from a script yet so
this would be a bit of a learning curve for me.

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


nick.rout at gmail

Jul 21, 2010, 6:17 PM

Post #18 of 29 (2626 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

On Thu, Jul 22, 2010 at 12:01 PM, David Moore <dmoo1790 [at] ihug> wrote:
> Ross and Jemima Knudsen wrote:
>>
>> David Moore wrote:
>>> I guess so. What exactly would you like to do? If you mean a myth user
>>> job that runs automatically for every recording then I'm not sure what
>>> you have in mind. Or do you mean a script you run from the command line,
>>> e.g., to trim recordings or join recordings?
>>>
>>
>> See this link:
>>
>> http://www.mythtv.org/wiki/User_Jobs
>>
>> Basically you write a script in what ever language you want and what you
>> would normally type into the command line is what you would put into the
>> user job setup and Myth will run the job either automatically or you can
>> manually select it to run.  The above link shows that there are some
>> variables which Myth can provide to make it work generically (eg
>> filename, filepath)
>>
>
> Yes I understand that. Sorry but what I meant was what is your end
> objective of running the user job? Transcode? Cut? Something else?
> Wouldn't be too hard to script the transcoding using a similar technique
> to Craig B's hdvideo2ipod.sh script. Cutting would be harder because (I
> think) it would involve sql to access the cutlist in the myth database.
> I'm a fairly basic sql user and I haven't used it from a script yet so
> this would be a bit of a learning curve for me.

Take a look at these recent conversations on the -users list:

http://www.gossamer-threads.com/lists/mythtv/users/442784#442784

http://www.gossamer-threads.com/lists/mythtv/users/442240#442240

I am pretty sure how to extract the cutlist is discussed there
somewhere, or appears in the code they are discussing.


basically I think you are looking in the recordedmarkup table

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


ross.jemima at gmail

Jul 23, 2010, 3:03 AM

Post #19 of 29 (2562 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

David Moore wrote:
> Yes I understand that. Sorry but what I meant was what is your end
> objective of running the user job? Transcode? Cut? Something else?
> Wouldn't be too hard to script the transcoding using a similar technique
> to Craig B's hdvideo2ipod.sh script. Cutting would be harder because (I
> think) it would involve sql to access the cutlist in the myth database.
> I'm a fairly basic sql user and I haven't used it from a script yet so
> this would be a bit of a learning curve for me.
>

Ok, sorry I thought it was a funny question ;-).

I think a good place to start would be with say Craig's script. I
haven't personally done a lot of scripting in bash (or any other linux
scripting langauge). I can do sql but I'm not sure what functionality
is available via bash to work with data from the DB (maybe you can use
arrays?). Maybe another language would be better?

I'd say the objective would be to transcode losslessly to remove the
LATM part and remux the file into a new container as the basic function
of the script. It should then be able to accept a flag to tell it to
observe the cutlist from the DB to cut the file as appropriate.

It should also accept a flag to replace the file in the DB or save it
externally. If it replaces the original recording then it should update
the DB to remove the cutlist and update the seek table.

This way we will have a minimal recording with basically no loss in
information (only around where the cuts are) which can then be further
encoded or archived as desired through separate means. Is this what
others are after, have I missed anything useful?

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


dmoo1790 at ihug

Jul 23, 2010, 3:40 AM

Post #20 of 29 (2569 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

Ross and Jemima Knudsen wrote:
> David Moore wrote:
>> Yes I understand that. Sorry but what I meant was what is your end
>> objective of running the user job? Transcode? Cut? Something else?
>> Wouldn't be too hard to script the transcoding using a similar technique
>> to Craig B's hdvideo2ipod.sh script. Cutting would be harder because (I
>> think) it would involve sql to access the cutlist in the myth database.
>> I'm a fairly basic sql user and I haven't used it from a script yet so
>> this would be a bit of a learning curve for me.
>>
>
> Ok, sorry I thought it was a funny question ;-).
>
> I think a good place to start would be with say Craig's script. I
> haven't personally done a lot of scripting in bash (or any other linux
> scripting langauge). I can do sql but I'm not sure what functionality
> is available via bash to work with data from the DB (maybe you can use
> arrays?). Maybe another language would be better?
>
> I'd say the objective would be to transcode losslessly to remove the
> LATM part and remux the file into a new container as the basic function
> of the script. It should then be able to accept a flag to tell it to
> observe the cutlist from the DB to cut the file as appropriate.
>
> It should also accept a flag to replace the file in the DB or save it
> externally. If it replaces the original recording then it should update
> the DB to remove the cutlist and update the seek table.
>
> This way we will have a minimal recording with basically no loss in
> information (only around where the cuts are) which can then be further
> encoded or archived as desired through separate means. Is this what
> others are after, have I missed anything useful?
>

I get the picture now. I also am new to anything in linux really but I'm
prepared to give it a go. With my minimal experience I believe you can
do pretty much anything in a bash script although the built-in script
features are not as flash as something like perl.

I like your ideas. I'll get started but it will probably take me a while
so don't hold your breath. :-)

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


ross.jemima at gmail

Jul 23, 2010, 2:21 PM

Post #21 of 29 (2548 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

David Moore wrote:
>
> I get the picture now. I also am new to anything in linux really but I'm
> prepared to give it a go. With my minimal experience I believe you can
> do pretty much anything in a bash script although the built-in script
> features are not as flash as something like perl.
>
> I like your ideas. I'll get started but it will probably take me a while
> so don't hold your breath. :-)
>
Yeah, as with any FOSS can't expect anyone to do anything.

Only other option I thought of just now is whether writing it in VB.net
(or C#.net) would be worthwhile as mono have pretty good libraries now.
I know VB fairly well but last time I tried using a mono based IDE on
Ubuntu I couldn't get it to work.

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


dmoo1790 at ihug

Jul 23, 2010, 5:38 PM

Post #22 of 29 (2549 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

Ross and Jemima Knudsen wrote:
> David Moore wrote:
>> I get the picture now. I also am new to anything in linux really but I'm
>> prepared to give it a go. With my minimal experience I believe you can
>> do pretty much anything in a bash script although the built-in script
>> features are not as flash as something like perl.
>>
>> I like your ideas. I'll get started but it will probably take me a while
>> so don't hold your breath. :-)
>>
> Yeah, as with any FOSS can't expect anyone to do anything.
>
> Only other option I thought of just now is whether writing it in VB.net
> (or C#.net) would be worthwhile as mono have pretty good libraries now.
> I know VB fairly well but last time I tried using a mono based IDE on
> Ubuntu I couldn't get it to work.
>

I've used VB a fair bit also but I don't think it's a good idea to rely
on something which isn't pretty standard in Ubuntu for portability
reasons. Turns out sql in bash is really simple. Just echo the sql
commands through a pipe to mysql and catch the results. Dead easy. :-)
Hardest thing will be understanding which tables need updating.
Recordedseek and recordedmarkup are the ones I know of so far.

Actually looks like the trickiest thing is handling the cuts. Myth cuts
in recordedmarkup table are in frames whereas ffmpeg uses times so need
to do some maths to convert frame to time. Bash doesn't do floating
point maths but there is a linux utility called bc to do this so that's
no problem. Could be a problem with cut accuracy however. I had a look
at one of my recordings last night and it seems that the time myth shows
for the cut points is not exactly equal to the cut point frame number x
25 (fps). I'm guessing there might be some issue with the start time for
the recording but not sure yet.

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


ross.jemima at gmail

Jul 24, 2010, 2:02 AM

Post #23 of 29 (2537 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

On 24/07/2010 12:38 p.m., David Moore wrote:
>
> I've used VB a fair bit also but I don't think it's a good idea to rely
> on something which isn't pretty standard in Ubuntu for portability
> reasons. Turns out sql in bash is really simple. Just echo the sql
> commands through a pipe to mysql and catch the results. Dead easy. :-)
> Hardest thing will be understanding which tables need updating.
> Recordedseek and recordedmarkup are the ones I know of so far.
>

You'd just want to drop all the markings for the particular recording
after doing any of the transcoding as potentially the timestamps may be
altered. So something like:
'delete from `recordedmarkup` where `chanid` = X and `starttime` = Y'
and 'delete from `recordedseek` where `chanid` = X and `starttime` = Y

http://www.mythtv.org/wiki/Recordedmarkup_table
http://www.mythtv.org/wiki/Recordedseek_table

To fix the entries in the seek table just take the lazy way out and use
one of the methods here:
http://www.mythtv.org/wiki/Repairing_the_Seektable

PS I thought that mono libraries were installed as default on Ubuntu?...
> Actually looks like the trickiest thing is handling the cuts. Myth cuts
> in recordedmarkup table are in frames whereas ffmpeg uses times so need
> to do some maths to convert frame to time. Bash doesn't do floating
> point maths but there is a linux utility called bc to do this so that's
> no problem. Could be a problem with cut accuracy however. I had a look
> at one of my recordings last night and it seems that the time myth shows
> for the cut points is not exactly equal to the cut point frame number x
> 25 (fps). I'm guessing there might be some issue with the start time for
> the recording but not sure yet.
>
>

Maybe using Avidemux might be feasible if you can get it to work on the
commandline. It uses frame numbers (I believe).



_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/


jonathan.hoskin at gmail

Jul 24, 2010, 4:03 AM

Post #24 of 29 (2535 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

>
> > I've used VB a fair bit also but I don't think it's a good idea to rely
> > on something which isn't pretty standard in Ubuntu for portability
> > reasons. Turns out sql in bash is really simple. Just echo the sql
> > commands through a pipe to mysql and catch the results. Dead easy. :-)
> > Hardest thing will be understanding which tables need updating.
> > Recordedseek and recordedmarkup are the ones I know of so far.
>


If you have the appetite to learn a bit of Ruby, Nick Ludlam has done some
excellent work on an easy-to-use Ruby API implementation for MythTV:
http://github.com/nickludlam/ruby-mythtv

I originally contributed some work to add support for 0.23, and have just
pushed up support for Myth protocol version # 23056 to my fork:
http://github.com/jonathanhoskin/ruby-mythtv

The Ruby API doesn't have currently support for querying the recordedmarkup
table, but it would be straight-forward to pick that up through
ActiveRecord.

Whatever language you use, best of luck - the Myth backend stack is a scary
place.


nick.rout at gmail

Jul 24, 2010, 3:49 PM

Post #25 of 29 (2502 views)
Permalink
Re: Cutting H.264 DVB-T files with ffmpeg without transcoding [In reply to]

On Sat, Jul 24, 2010 at 9:02 PM, Ross and Jemima Knudsen
<ross.jemima [at] gmail> wrote:
> On 24/07/2010 12:38 p.m., David Moore wrote:
>>
>> I've used VB a fair bit also but I don't think it's a good idea to rely
>> on something which isn't pretty standard in Ubuntu for portability
>> reasons. Turns out sql in bash is really simple. Just echo the sql
>> commands through a pipe to mysql and catch the results. Dead easy. :-)
>> Hardest thing will be understanding which tables need updating.
>> Recordedseek and recordedmarkup are the ones I know of so far.
>>
>
> You'd just want to drop all the markings for the particular recording
> after doing any of the transcoding as potentially the timestamps may be
> altered.  So something like:
> 'delete from `recordedmarkup` where `chanid` = X and `starttime` = Y'
> and 'delete from `recordedseek` where `chanid` = X and `starttime` = Y
>
> http://www.mythtv.org/wiki/Recordedmarkup_table
> http://www.mythtv.org/wiki/Recordedseek_table
>
> To fix the entries in the seek table just take the lazy way out and use
> one of the methods here:
> http://www.mythtv.org/wiki/Repairing_the_Seektable
>
> PS I thought that mono libraries were installed as default on Ubuntu?...
>> Actually looks like the trickiest thing is handling the cuts. Myth cuts
>> in recordedmarkup table are in frames whereas ffmpeg uses times so need
>> to do some maths to convert frame to time. Bash doesn't do floating
>> point maths but there is a linux utility called bc to do this so that's
>> no problem. Could be a problem with cut accuracy however. I had a look
>> at one of my recordings last night and it seems that the time myth shows
>> for the cut points is not exactly equal to the cut point frame number x
>> 25 (fps). I'm guessing there might be some issue with the start time for
>> the recording but not sure yet.
>>
>>
>
> Maybe using Avidemux might be feasible if you can get it to work on the
> commandline.  It uses frame numbers (I believe).
>


avidemux works from the commandline. It uses frame numbers.

_______________________________________________
mythtvnz mailing list
mythtvnz [at] lists
http://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/

First page Previous page 1 2 Next page Last page  View All MythTV mythtvnz RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.