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

Mailing List Archive: MythTV: Mythtvnz

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

 

 

MythTV mythtvnz RSS feed   Index | Next | Previous | View Threaded


dmoo1790 at ihug

Jul 16, 2010, 9:32 PM

Post #1 of 12 (2011 views)
Permalink
Cutting H.264 DVB-T files with ffmpeg without transcoding

Anybody worked out a reliable way to cut recordings from Freeview
terrestrial using ffmpeg? I get different problems with different
recordings, e.g., sometimes ffmpeg seems to hang and other times it
produces files myth won't play. I don't want to transcode the video
because it takes forever on my system so I'm trying to use the "-vcodec
copy" option.

So far this is the best I have come up with after a lot of trial and error:

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.

I have ffmpeg SVN-r23148 patched with Paul Kendall's LATM patch to
handle the audio on TV1, TV2, etc.

_______________________________________________
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 17, 2010, 2:56 PM

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

>
> 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.


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


g8ecj at gilks

Jul 21, 2010, 3:37 AM

Post #3 of 12 (1907 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

I take it that all the effort is due to nuvexport not working for H264
files (well it doesn't for me anyway).

Am I right?

--
Robin Gilks



_______________________________________________
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, 4:01 AM

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

Robin Gilks wrote:
>>> 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
>
> I take it that all the effort is due to nuvexport not working for H264
> files (well it doesn't for me anyway).
>
> Am I right?
>

Actually I've never tried nuvexport. There's a lot I don't know about
myth. :-) I have tried mythtranscode but never got it to work. I'm just
looking for some tools to cut and join recordings reasonably reliably. I
don't need an "all-in-one" tool as I'm happy to do stuff from the
command line so it's just a matter of finding the right progs and
learning the syntax for me.

_______________________________________________
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 21, 2010, 5:32 AM

Post #5 of 12 (1906 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.
>
>
> 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?

I've been putting together a hdvideo2ipod.sh script that I'm happy to share,
it works but is a bit rough around the edges.

It uses ffmpeg to see if the audio is ok, then parses to VLC to convert LTAM
audio to something useful, then hands the whole lot back to ffmpeg to do the
final transcoding.

I've put it up on my blog at
http://craigosaurous.blogspot.com/2010/07/hdvideo2ipodsh.html

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 21, 2010, 4:52 PM

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

Craig Blaikie 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?
>
> I've been putting together a hdvideo2ipod.sh script that I'm happy to share,
> it works but is a bit rough around the edges.
>
> It uses ffmpeg to see if the audio is ok, then parses to VLC to convert LTAM
> audio to something useful, then hands the whole lot back to ffmpeg to do the
> final transcoding.
>
> I've put it up on my blog at
> http://craigosaurous.blogspot.com/2010/07/hdvideo2ipodsh.html
>
> Cheers,
> Craig
>

That's cool Craig. I was thinking of using ffmpeg to analyse the
recording in a similar way to what you have done in your script. Couple
of things: TV3 has an AC3 audio track that I use without transcoding
(might not matter in your application) and it looks like the end of some
of the script lines have been clipped off.

_______________________________________________
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 21, 2010, 6:22 PM

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

> Craig Blaikie wrote:
>
> > I've been putting together a hdvideo2ipod.sh script that I'm happy to
share,
> > it works but is a bit rough around the edges.
> >
> > It uses ffmpeg to see if the audio is ok, then parses to VLC to convert
LTAM
> > audio to something useful, then hands the whole lot back to ffmpeg to do
the
> > final transcoding.
> >
> > I've put it up on my blog at
> > http://craigosaurous.blogspot.com/2010/07/hdvideo2ipodsh.html
> >
> > Cheers,
> > Craig
> >
>
> That's cool Craig. I was thinking of using ffmpeg to analyse the
> recording in a similar way to what you have done in your script. Couple
> of things: TV3 has an AC3 audio track that I use without transcoding
> (might not matter in your application) and it looks like the end of
> some
> of the script lines have been clipped off.

Hopefully the missing data should be there, either wrapped, or off the edge
of the page.
I'll also put up a link to a clean copy tonight.
The script detects if there is a ffmpeg compatible audio stream, and skips
the VLC part.
I also roughly detect the resolution and set the aspect ratio so things look
normal on the final output files.

I'll check it with a file from TV3 with AC3 and try that tonight also.

Cheers,
Craig


_______________________________________________
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, 6:48 PM

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

>
> Hopefully the missing data should be there, either wrapped, or off the edge
> of the page.
> I'll also put up a link to a clean copy tonight.
>

Might I suggest using an online SCM like http://gist.github.com, which
allows others who are keen (like me) to fork and contribute to the work,
which everyone can then benefit from?

Jonathan


killerkiwi2005 at gmail

Jul 24, 2010, 5:19 AM

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

On 24 July 2010 23:03, Jonathan Hoskin <jonathan.hoskin [at] gmail> 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.

vb would be fine on mono, ubuntu ships with the mono runtime ie tomboy
and fspot both run on mono
That dosn't mean the winforms you might be used to just the core .net framework

That being said i think the python bindings for mythtv are uptodate
and if you look into quickly you could package into a ppa very easily
without needing any packaging knowledge (always a bonus)

http://www.mythtv.org/wiki/0.23_Python_bindings
https://wiki.ubuntu.com/Quickly

--
"Weekends don't count unless you spend them doing something completely
pointless. " - Calven

_______________________________________________
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 24, 2010, 2:50 PM

Post #10 of 12 (1823 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.
>
>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.

[Craig Blaikie]
I haven't seen the frame offset issue in MythTV, is it only in the final
ffmpeg'ed file? If it's a constant offset then it might be easier to add an
adjustment/offset value.
Looks like mythcommflag can do most of the heavy lifting with --getcutlist
which returns a nicely formatted set of cut points, (still in frames) then
using --clearcutlist and --rebuild to reset the seektable. I'll have a go
at putting it together, might take me a few days...

Cutlist: 0-1220,17379-21140,33779-39043,49604-54116,66654-71917,83563-136461



_______________________________________________
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 24, 2010, 3:52 PM

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

On Sun, Jul 25, 2010 at 12:19 AM, Jason Taylor <killerkiwi2005 [at] gmail> wrote:
> On 24 July 2010 23:03, Jonathan Hoskin <jonathan.hoskin [at] gmail> 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.
>
> vb would be fine on mono, ubuntu ships with the mono runtime ie tomboy
> and fspot both run on mono
> That dosn't mean the winforms you might be used to just the core .net framework
>
> That being said i think the python bindings for mythtv are uptodate
> and if you look into quickly you could package into a ppa very easily
> without needing any packaging knowledge (always a bonus)
>
> http://www.mythtv.org/wiki/0.23_Python_bindings
> https://wiki.ubuntu.com/Quickly

Why on earth would you bother with VB? There are great python bindings
for mythtv.

Also has anyone tried tsmuxer instead of ffmpeg? It seems better
designed for the job. It's cutpoints have to be measured in time units
not frames, but conversion is a simple multiplication or division by
25 (frames per second) (in NZ anyway).

_______________________________________________
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 24, 2010, 4:59 PM

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

Craig Blaikie 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.
>>
>> 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.
>
> [Craig Blaikie]
> I haven't seen the frame offset issue in MythTV, is it only in the final
> ffmpeg'ed file? If it's a constant offset then it might be easier to add an
> adjustment/offset value.
> Looks like mythcommflag can do most of the heavy lifting with --getcutlist
> which returns a nicely formatted set of cut points, (still in frames) then
> using --clearcutlist and --rebuild to reset the seektable. I'll have a go
> at putting it together, might take me a few days...
>
> Cutlist: 0-1220,17379-21140,33779-39043,49604-54116,66654-71917,83563-136461
>

What I have seen is when you're editing a recording in myth it displays
the time for the cut points. But when you look at the frame numbers in
recordedmarkup they don't exactly match the times displayed by myth. I
haven't checked a final file yet.

The cut list wasn't so hard after all. Simple use of mysql to store the
cuts and cut types in an array and then a little code to convert to
times and use them in ffmpeg.

I'm thinking I'll use mythcommflag for the final cleanup to rebuild the
seek table and clear the cutlist.

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

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.