[mythtv-users] Suggested bitrate for transcoding HD Mpeg 2 to Mpeg 4

Robert Houghton robbadler at gmail.com
Mon Jun 6 21:56:48 UTC 2011


On Mon, Jun 6, 2011 at 2:36 PM, Neil Salstrom <salstrom at gmail.com> wrote:

> On Fri, Jun 3, 2011 at 10:47 PM, Neil Salstrom <salstrom at gmail.com> wrote:
> >
> > I think you are correct.  I may compile both ffmpeg and x264 myself.
> > I had some issues with the transcoding I did.
> >
> > First, the transcode failed on a file that had two audio tracks.
> > Second, in the file that finished encoding had really distorted audio.
> >  I'm wondering if a more recent ffmpeg / x264 has fixes for those
> > issues.
> >
>
> An update to this.
>
> Over the weekend I compiled ffmpeg and x264.  The issue with distorted
> audio is gone but I'm still having issues with files with multiple
> audio tracks.  Here is what happens when I try to use this script.  It
> will make a zero byte file and insert that in to the database fine (so
> that portion of the script works) but ffmpeg chokes:
>
> mythtv at htpc:~$ ./x264_transcode_normal.pl -f 1102_20100626140000.mpg
> /multimedia/metadata/Banners/1102_20100626140000.mpg does not exist
> /multimedia/metadata/Coverart/1102_20100626140000.mpg does not exist
> sh: /usr/share/mythtv/metadata/Television/ttvdb.py: not found
> /video/Primal_Grill_With_Steven_Raichlen_06.26.2010.mp4 seems unique
> ffmpeg version git-N-30535-g124a9ed, Copyright (c) 2000-2011 the
> FFmpeg developers
>  built on Jun  4 2011 15:38:43 with gcc 4.4.5
>  configuration: --enable-gpl --enable-version3 --enable-nonfree
> --enable-postproc --enable-libfaac --enable-libmp3lame
> --enable-libopencore-amrnb --enable-libopencore-amrwb
> --enable-libtheora --enable-libvorbis --enable-libx264
> --enable-libxvid --enable-x11grab
>  libavutil    51.  4. 0 / 51.  4. 0
>  libavcodec   53.  6. 1 / 53.  6. 1
>  libavformat  53.  2. 0 / 53.  2. 0
>  libavdevice  53.  1. 0 / 53.  1. 0
>  libavfilter   2. 12. 0 /  2. 12. 0
>  libswscale    0. 14. 1 /  0. 14. 1
>   libpostproc  51.  2. 0 / 51.  2. 0
> [mpegts @ 0x1a463e0] max_analyze_duration 5000000 reached at 5005000
> Input #0, mpegts, from '1102_20100626140000.mpg':
>  Duration: 00:29:56.93, start: 75005.058000, bitrate: 3399 kb/s
>  Program 1
>    Stream #0.0[0x41]: Video: mpeg2video (Main), yuv420p, 704x480 [PAR
> 10:11 DAR 4:3], 15000 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
>    Stream #0.1[0x44](eng): Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
>    Stream #0.2[0x45](eng): Audio: ac3, 48000 Hz, mono, s16, 128 kb/s
> (visual impaired)
>    Stream #0.3[0x46](spa): Audio: ac3, 48000 Hz, mono, s16, 128 kb/s
> Output #0, mp4, to 'Primal_Grill_With_Steven_Raichlen_06.26.2010.mp4':
>    Stream #0.0: Video: libx264, yuv420p, 1280x720, q=10-51, 3300
> kb/s, 90k tbn, 29.97 tbc
>    Stream #0.1: Audio: libfaac, 48000 Hz, 6 channels, s16, 160 kb/s
> Codec type mismatch for mapping #0.0 -> #0.1
> Old file size = 763665212
> New file size = 0
> # INSERT INTO recorded
>
> (profile,findid,programid,progstart,hostname,previouslyshown,duplicate,starttime,playgroup,editing,preserve,category,transcoded,stars,watched,description,progend,filesize,title,seriesid,recgroup,bookmarkupdate,timestretch,lastmodified,commflagged,storagegroup,autoexpire,endtime,originalairdate,deletepending,transcoder,chanid,basename,subtitle,recpriority,recordid,bookmark)
> VALUES ("Default","0","EP010441480032","2010\-06\-26\
> 14\:00\:00","htpc","1","1","2010\-06\-26\
> 14\:00\:01","Default","0","0","Cooking","0","0","0","Margherita\ and\
> bacon\ potato\ wood\ oven\ pizzas\;\ sweet\-and\-sour\ duck\;\
> bone\-in\ pork\ chops\;\ grilled\ cipollini\ onions\ on\
> skewers\.","2010\-06\-26\ 14\:30\:00","0","Primal\ Grill\ With\
> Steven\ Raichlen","EP01044148","Default","0000\-00\-00\
> 00\:00\:00","1","2010\-06\-26\
> 14\:30\:05","1","Default","1","2010\-06\-26\
>
> 14\:30\:00","2010\-06\-05","0","0","1102","Primal_Grill_With_Steven_Raichlen_06\.26\.2010\.mp4","Italian\
> Fire","0","170","0");
> mythtv at htpc:~$
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://www.mythtv.org/mailman/listinfo/mythtv-users
>


The script attempts to map the video stream and audio stream in cases of
multiple audio streams being found. You have a stereo and mono source, and
this is throwing the script off. I intended it to look for 5.1 vs stereo,
not stereo vs mono.

Try looking here:

# ============================================================================
# Get ffmpegs info
#

$audiostreamstereo   = 0;
$audiostreamsurround = 0;
$command = "ffmpeg -i $dir/$file ";
open(FF_info, "$command 2>&1 |");
while ( defined(my $line = <FF_info>) ) {
	chomp($line);
	if ( $line =~ /^\s*Stream.*#(\S\.\S).*:\sVideo.*\s(\S*)\stbr/ )
	{
		$framerate = $2;
		$videostream = $1;
		next;
	}
	if ( $line =~ /^\s*Stream.*#(\S\.\S).*:\sAudio.*stereo/ )
	{
		$audiostreamstereo = $1;
		next;
	}
	if ( $line =~ /^\s*Stream.*#(\S\.\S).*:\sAudio.*5.1/ )
	{
		$audiostreamsurround = $1;
		next;
	}
	if ( $line =~ /^\s*Stream.*#(\S\.\S).*:\sAudio.*mono/ )
        {
                $audiostreammono = $1;
                next;
        }
}

and

# ============================================================================
# Third, do the transcode
#
$audiochannels = 6;
$audiostream = $audiostreamsurround;
if ( $audiostreamsurround eq "" )
{
  my $audiochannels = 2;
  my $audiostream = $audiostreamstereo;
}



Also, please provide invocation line for ffmpeg inside the script

chdir $dir;
print "$command \n";
system $command;

if ( ! -e "$dir/$newfilename" )
{   Die "Transcode failed\n"  }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.mythtv.org/pipermail/mythtv-users/attachments/20110606/0d29fc90/attachment-0001.html 


More information about the mythtv-users mailing list