How to install transcode

  • prioryjim

    prioryjim - 2013-02-19

    There seems to be a minidlna-transcode project
    Does/Has anyone manage to use this ?
    Is it a stand alone build ?
    Or do you need to build minidlna first and the add it afterwards some how ?
    Any assistance appreciated.

  • prioryjim

    prioryjim - 2013-02-19

    OK thanks for the quick reply.
    Eventually I want to play my Humax TS files to my Sony KDL-40W5500U tv
    And I think the transcoding is more basic and under my control.

  • prioryjim

    prioryjim - 2013-02-20

    OK so far
    I already had minidlna installed with apt-get
    So as root to remove it I did
    apt-get -purge remove minidlna
    installed the src tar into a directory then cd to directory
    cd minidlna-1.0.25
    Installed the dependancies/
    apt-get install libexif-dev libjpeg8-dev libid3tag0-dev libflac-dev libvorbis-dev libsqlite3-dev libavcodec-dev libavformat-dev
    In the minidlna src directory ran
    patch -dry-run -p1 </home/jim/minidlna-1.0.25_transcode.patch
    which looked OK so for real…
    patch  -p1 </home/jim/minidlna-1.0.25_transcode.patch

    make install

    Twiddled the minidlna.conf as required
    and the ran it with
    minidlna -f /opt/minidlna-1.0.25/minidlna.conf

    It seems to be running OK and listening on port 8200
    netstat -an | grep 8200

    Can't test it as all this is a remote login.
    So tonight when I get home I might give it a quick test.
    But main twiddling will  be weekend.
    Thanks and bye for now.

  • Craig Chambers

    Craig Chambers - 2013-02-20

    You may not need to transcode at all if you are using broadcast TV transport streams.  I'm not certain if a Humax PVR saves ts files in some way that's non-standard, but it's possible that they will work on the W5500 without any issues, or at most with a database tweak.

    My main TV is a 40W5500, and I am able to play ts and m2ts files.  The only issue I have is where I've re-encoded an SD recording that has MP2 audio to use h.264 video, but not changed the audio, and I fix these with a database script.


  • prioryjim

    prioryjim - 2013-02-21

    I have a Raspberry PI plus purchased codecs .
    It has XBMC loaded. Most things worked a treat, even rewind/FF and the position slider.

    The Sony TV partially worked. Some files from a video camera worked OK although no pause/rewind/FF it said something about feature not available. I know it can work as running against Win7 media server it work OK even rewind/FF.

    The ts (and mts) files showed up but when played just showed black and no Audio. Not surprised as most of the other servers did the same. Only WIN7 worked OK.

    Still quite happy at the result so far as I can now try playing around with transcode at the weekend.

    Any comments, particularly on Rewind/FF would be good.
    Not sure why rewind/FF seem a bit of a problem on the Sony.


  • Craig Chambers

    Craig Chambers - 2013-02-21

    I'm not certain, but support for these features of older sets, the W5500 is nearly 3 years old (an age in embedded a/v client terms), seems to rely heavily on regular key frames (i.e. essentially a full still image, rather than a 'difference' frame) in the video stream.  This is especially true for HD video, but also affects SD too. 
    In my experience, these are usually present in large numbers in Blu-Ray encodes, but also in (HD)TV broadcasts.

    I think that the issue may be how much memory buffer the client has before the next key frame appears.  When dealing with a stream at several (or tens of) Mbps, you could be talking more than 100 MB in the buffer before another keyframe appears.  Not a problem for a PC or even for an RPi, but very problematic for a TV with a 1st gen embedded video player with only a sliver of memory.

    From what I've read, the standard for Blu-Ray is several key frames per second, and my W5500 is happy with seeking on very high bitrate blu-ray rips like Watchmen. 
    Blu-ray video is actually quite size inefficient, while at the same time being seek friendly.  Those frequent keyframes are costly in terms of size, and the quality is fairly high.  After all, you have a 47 GB disk to put the film on, why compress the hell out of it?

    Quick calculation…
    38 GB file = 304 Gb file. = 304,000,000,000 bytes
    304,000,000,000 / 188 (length in minutes) / 60 (seconds) = 26,950,354.6099 bps = approx 27 Mbps

    But there are several key frames in there for every second of video, reducing the amount of memory in the buffer between key frames, and allowing easy seeking.

    My experience is that even SD mkv files that I may have 'stumbled upon', that have h.264 video (I just need to repackage the contents into an m2ts container, and perhaps convert the audio from AAC to AC3) will not seek well at all on my TVs. 

    Conversely, I converted all my DVD rips from MPEG2 video to h.264, and as my main viewing platform was the TV,  I want them to seek and I don't want them to look shoddy, I encoded them with a reasonable quality setting and with 1 key frame per second.

    Personally, I don't use the transcode patch as I do a one-time high-quality re-encode for my TVs on my MPEG2 videos, and I don't need to re-encode my Blu-ray rips or HDTV recordings.
    You might want to see if there's an option for key frame interval in there (for ffmpeg/x264 this is the keyint value, set as number of frames between key frames e.g. keyint=24 , meaning 1 key frame for every 24 frames)

    Enjoy :-)


  • prioryjim

    prioryjim - 2013-02-22

    Thanks, jobs for the weekend !

  • prioryjim

    prioryjim - 2013-02-25

    My plan was as follow.
    Using ffmpeg convert my example TS file to some format and see if it would play and FF/rewind etc.
    Once to that stage would look into transcode using those parameters using ffmpeg.
    The Sony seems to like -g 15 and -r 30
    Can you suggest a file format/type and example ffmpeg line.
    I can then do a test conversion.
    Transcode on back burner for moment.
    Yesterday I watch a TS file using Windows 7 media server, this worked OK and FF/R worked well.
    So it can work, don't know what Media server does different.

  • Craig Chambers

    Craig Chambers - 2013-02-25

    I think that Windows 7 server probably is transcoding, it might be worth watching CPU usage on the PC while watching :-)

    Formats - the TV will be happy with either .ts or .m2ts.  Both are MPEG transport streams, the former being MPEG1, the latter being MPEG2.

    I'm not sure about your ffmpeg parameters, they are not one that I use as I generally retain the framerate of the incoming video (framerate has never given me any issues: 24, 50 and 60 all work fine), and set the keyframes in the x264 parameters.

    I inherit most settings from the ffmpeg preset, then I add parameters into the x264 options…

    ffmpeg -i filename.ts -acodec copy -vcodec libx264 -preset slow -level 4.1 -b-pyramid strict -crf 18 -x264opts keyint=24:slices=4:bframes=3:nal-hrd=vbr:aud=1:vbv-bufsize=30000:vbv-maxrate=40000 out/filename.m2ts

    If you needed to convert the audio to AC3 too, you would replace "-acodec copy" with:

    -acodec ac3 -ac 2 -ab 128k (or)
    -acodec ac3 -ac 6 -ab 384k (or)
    -acodec ac3 -ac 6 -ab 640k (if downconverting from HD audio)

    All of the above work on my TVs.

    I wrote a blog post on AVForums on this subject, with various jobs that I have done some time ago:

    I'd be intrigued to know what the stream formats of your Humax files are.  As I say, I'd expect broadcast streams to work without transcoding , though maybe needing a container switch.


  • prioryjim

    prioryjim - 2013-02-25

    Thanks for the reply.
    I feel I am making progress and will try the options above.
    Probably be weekend when I get time to investigate more.

    Any way to determine what format Win7 Media Player is using.
    Does it produce a log file.
    Any network tools to see what's happening.
    I have wireshark ?
    Re I'd be intrigued to know : would output from ffmpeg -i help ?
    Thanks again

  • prioryjim

    prioryjim - 2013-02-26

    Got up early today, 03:45 to try the ffmpeg.
    Converted 480 seconds (-t 480 ) but the rest of the ffmpeg command was the same.
    Sony showed it a MPEG2 but when I played it the Sony said playback not available.
    Didn't have time to play with the parameters.
    The Sony TV is at home so can't use that in the day.
    But can log in from work and try ffmpeg etc.

  • Cecil Coupe

    Cecil Coupe - 2013-02-26

    Hi. FWIW, I gave up on making my dlna servers transcode (Plex can do it if you can suffer the interface). My TV is picky picky about many things. I discovered that Handbrake (defaults) can convert my wild collection of formats into  mp4 files that my TV likes (and minidlna can parse and serve). I bit the bullet and converted them all by hand via the Handbreak GUI. That was a one time hit to my time and cpu time. Transcoding on the fly is a cpu hit all the time and every time and it may not be fast enough for real time playback (shudder to think about rewind or fast forward)

    Try Handbrake (its free in cost) to convert a file.  If it works then you can poke around to see what its doing and then set ffmpeg parameters. Or convert all your files with it. I choose not to go into that ffmpeg maze. No one survives unless they get lucky.

  • Craig Chambers

    Craig Chambers - 2013-02-26

    As I said above, I also never tried the transcode patch.  Like ccoupe I went down the one time only re-encode route.  As I only ripped my DVDs when I got my TV (4 years ago, not 3 as I said above) I chose a format that the TV was happy with. Initially that format was MPEG 2 (.mpg i.e. straight rip from disk with no conversion). 

    Later, when I got a more beefy PC, I re-encoded my MPEGs into h.264 video in m2ts containers.  The reason for picking that container was that it's the only one that the W5500 and my EX403 support for h.264.

    Rather than Handbrake, I used a command line with some loops to traverse my folder system (as described in the blog post).  The settings posted above work for me from miniDLNA to my Bravia W5500, but my videos are a re-encode, not a an on-the-fly transcode.


  • prioryjim

    prioryjim - 2013-02-26

    Not up to trans-coding stage as yet.
    Just getting a conversion to play on my Sony with FF/R
    I will look at handbrake
    Plus your ffmpeg suggestion and link about formats should give me enough to play around for a while.

    Any ideas on discovering what format WIN 7 media server sends the Sony ?

  • Craig Chambers

    Craig Chambers - 2013-02-26

    I'm not sure how to find out what it's doing.  I'd suggest it's possibly MPEG 2, as that is the lowest common denominator in terms of DLNA video support (IIRC it''s the only mandatory format to be certified as a video server/renderer). 
    That's not *necessarily* a bad thing, but from what I've seen on various forums, the problem is that Win 7 doesn't do a very good job - it produces a low quality transcode, and resizes HD to SD.

    Good luck with the re-encode.  I tried Handbrake, but gave up on producing anything that the W5500 liked.  It's really quite picky, but the settings that I used work fine for all my media.

  • prioryjim

    prioryjim - 2013-02-28

    OK thanks for the assistance so far, will take a while to evaluate various formats.
    It's getting better in that I can get some to play and FF/R but need to work out what works and what doesn't.

    Might try your format again as I think the TV has some memory issues.
    Often what did work suddenly doesn't. A mains power cycle of the TV and things work again !


Log in to post a comment.