[mythtv-users] Transcoding for best audio

Michael Stucky mike at stucky.us
Fri Jul 5 21:34:20 UTC 2013


On Fri, Jul 5, 2013 at 4:05 PM, John Pilkington <J.Pilk at tesco.net> wrote:

> On 05/07/13 18:33, Brenden Conte wrote:
>
>  Has anyone done this before?  I have some ideas on how to do #2 using
>> ffmpeg, but wanted to check to see if someone has already solved this
>> problem before I got too deep.
>>
>> Thanks!
>> -B
>>
>
> I just remembered that I used to use a very much simpler script. I think
> it was this. It's obviously out of date and it doesn't update the Myth
> database properly but it might be adaptable.  It just didn't deal with
> imperfect recordings as well as ProjectX.
>
> #!/bin/bash
>   cd /store/myth/reca
> #
> echo
> echo  "Output file $1_$2.mpg has video(0) and audioStream(0) copied "
> echo  "from video(0) and audioStream($3) of the input file  $1_$2.mpg0 "
> echo
> echo  "It will inherit the metadata of the old mythtv recording $1_$2.mpg "
> echo
> # echo "Using Channel and Start_time parameters _may_ make mythtranscode
> update database"
> if [ $# -lt 3 ]
> then
>    echo "Error: needs three arguments. Running  ffmpeg -i $1_$2.mpg0 2>&1
> | grep -C 4 Video "
>    echo
>    ffmpeg -i $1_$2.mpg0 2>&1 | grep -C 4 Video
>    echo
>    echo "Expected Command Line is of the form   ./mpg_csa 1234
> 20070927190000  0x0ac "
>    echo "                                                 chanid starttime
>       aid "
>    cd ~
>    exit 1
> fi
> echo "Command generated this time is "
> echo
> echo " nice nice mencoder -aid $3 -oac copy -ovc copy -of mpeg -mpegopts \
>  "
> echo " format=dvd:tsaf -vf harddup  -o /mnt/sam1/tempb/$1_$2.mpgx
> $1_$2.mpg0 "
> echo
> # now issue command
>
>  nice nice mencoder -aid $3 -oac copy -ovc copy -of mpeg -mpegopts \
>   format=dvd:tsaf -vf harddup  -o /mnt/sam1/tempb/$1_$2.mpgx $1_$2.mpg0
> #
> # if using two disks link to the location that myth expects
> ln -s /mnt/sam1/tempb/$1_$2.mpgx $1_$2.mpg
> # and rebuild the Keyframe Index
> #
>  nice nice mythtranscode --mpeg2 --buildindex --showprogress --chanid $1
> --starttime $2
> #
>  echo "Physical output file is /mnt/sam1/tempb/$1_$2.mpgx,"
>  echo " and is linked to  /store/myth/reca/$1_$2.mpg.  Video and audio PID
> $3 streams copied"
>
> echo
> cd ~
> exit 0
>
>
>
>
> Without getting into whether or not John's scripts are "too deep" ;^) ,
since I am a satisfied user of some of said scripts!

 I would like to discuss the root of Brenden's original question about how
mythtranscode works. I thought I had read a tread in the past that implied
that mythtranscode does not or maybe should not reverse the order of audio
tracks when more than one track exists in a recording. And that MythTV
should always be able to select and use the "best" audio track regardless
of the order (this does not help external players like VLC).

In my testing MythTV almost always reverses the order of audio tracks and
in some situations (my local NBC station) can not pick the "best" track.
Example:

mythbackend --version
Please attach all output as a file in bug reports.
MythTV Version : v0.27-pre2-1673-g168b852
MythTV Branch : master
Network Protocol : 77
Library API : 0.27.20130624-2
QT Version : 4.8.1
Options compiled in:
 linux profile use_hidesyms using_alsa using_oss using_pulse
using_pulseoutput using_backend using_bindings_perl using_bindings_python
using_bindings_php using_crystalhd using_dvb using_firewire using_frontend
using_hdhomerun using_ceton using_hdpvr using_ivtv using_joystick_menu
using_libcec using_libcrypto using_libdns_sd using_libfftw3 using_libxml2
using_lirc using_mheg using_opengl using_opengl_video using_qtwebkit
using_qtscript using_qtdbus using_sdl using_taglib using_v4l2 using_x11
using_xrandr using_xv using_bindings_perl using_bindings_python
using_bindings_php using_mythtranscode using_opengl using_vaapi using_vdpau
using_ffmpeg_threads using_mheg using_libass using_libxml2

Output of mythffmpeg from a recording before lossless mpeg2 transcode to
remove commercials:

mythffmpeg -i 1171_20130705193100.mpg
ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jul  5 2013 01:27:56 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --compile-type=profile --prefix=/usr --runprefix=/usr
--enable-crystalhd --enable-lirc --enable-audio-alsa --enable-audio-oss
--enable-dvb --enable-ivtv --enable-firewire --enable-joystick-menu
--with-bindings=perl --enable-ffmpeg-pthreads --enable-pic --enable-vaapi
--perl-config-opts='INSTALLDIRS=vendor' --enable-libvpx --enable-sdl
--enable-libmp3lame --enable-libx264 --enable-opengl-video --enable-vdpau
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[mpegts @ 0x802a20] PES packet size mismatch
    Last message repeated 1 times
Input #0, mpegts, from '1171_20130705193100.mpg':
  Duration: 00:29:00.05, start: 21639.778122, bitrate: 13544 kb/s
    Stream #0:0[0x31]: Video: mpeg2video (Main), yuv420p, 1920x1080 [SAR
1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz,
stereo, fltp, 384 kb/s
    Stream #0:2[0x35](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz,
stereo, fltp, 192 kb/s
At least one output file must be specified

Notice that there are two audio streams, 0:1[0x34](eng) and 0:2[0x35](spa),
and the the "eng" stream is 384 kb/s. Here is the output after lossless
mpeg2 transcode to remove commercials:

mythffmpeg -i 1171_20130705193100.mpg
ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
  built on Jul  5 2013 01:27:56 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --compile-type=profile --prefix=/usr --runprefix=/usr
--enable-crystalhd --enable-lirc --enable-audio-alsa --enable-audio-oss
--enable-dvb --enable-ivtv --enable-firewire --enable-joystick-menu
--with-bindings=perl --enable-ffmpeg-pthreads --enable-pic --enable-vaapi
--perl-config-opts='INSTALLDIRS=vendor' --enable-libvpx --enable-sdl
--enable-libmp3lame --enable-libx264 --enable-opengl-video --enable-vdpau
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mpeg, from '1171_20130705193100.mpg':
  Duration: 07:07:02.37, start: 0.360000, bitrate: 600 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 1920x1080 [SAR
1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x81]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 384 kb/s
At least one output file must be specified

Notice that the audio streams have been reversed, and since the mpeg format
has been changed from TS to PS the language (eng vs. spa) is lost and my
MythTV FE sometimes has to be forced to use the second audio stream via the
menu. And any external players that can not switch streams are stuck
without the ability to play the "eng" stream.

This behavior has existed at least since MythTV 0.25 and is the reason that
I use John's scripts to "cut" my recordings. It seems to me that
mythtranscode should be able to leave the audio tracks in a sensible order
( the "best" or local language first ) or/and have a way to remove the
unwanted audio track (maybe via something like the ffmpeg -map 0:1 option).

Sorry for hijacking your thread with my little rant, I'll step down from my
soapbox now...

Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20130705/fad8a44f/attachment-0001.html>


More information about the mythtv-users mailing list