#32 support transcode Video and Audio

open
nobody
None
5
2014-08-17
2011-02-26
hiero
No

Hello,
This patch supports transcoding for both Video and Audio using mencoder/ffmpeg as transcoder.
This uses multiple <res> elements. It means minidlna present multiple media format for one stream.
For example, in case source stream is H.264/AAC, minidlna presents both H.264/AAC and MPEG2/AC3.
If a client (TV) supports only MPEG2/AC3, it select MPEG2/AC3 stream.
All the Video stream can be transcoded to MPEG2/AC3 (DVD) stream.
All the Audio stream can be transcoded to LPCM stream.

mencoder/ffmpeg is required to be installed.

I tested on Ubunts 10.04 and Fedora 12.

I hope this patch is helpful to the users who's TV only supports MPEG2 and LPCM.

This patch is for minidlna_1.0.18_src.tar.gz.
This patch also support Toshiba TV.

heiro

Discussion

<< < 1 .. 6 7 8 (Page 8 of 8)
  • Jruuu
    Jruuu
    2013-06-22

    Yes, my conf file only lists one folder. All of my files are organized in subfolders. I tried running minidlna -d, and I also tried creating a FORCETRANSCODE folder.

    When I choose to play the file in the FORCETRANSCODE folder, minidlna skips the file and goes on to stream the first file in the next subfolder. Here is the output:

    [2013/06/22 13:20:37] upnpevents.c:422: debug: upnpevents_selectfds: 0x12a3f0 2 9
    [2013/06/22 13:21:01] upnpevents.c:457: debug: upnpevents_processfds: 0x12a3f0 2 9 0 0
    [2013/06/22 13:21:01] minidlna.c:1401: debug: HTTP connection from 192.168.7.50:3196
    [2013/06/22 13:21:01] upnpevents.c:422: debug: upnpevents_selectfds: 0x12a3f0 2 9
    [2013/06/22 13:21:01] upnpevents.c:457: debug: upnpevents_processfds: 0x12a3f0 2 9 0 0
    [2013/06/22 13:21:01] upnphttp.c:295: debug: Range Start-End: 0 - -1
    [2013/06/22 13:21:01] upnphttp.c:999: debug: HTTP REQUEST: GET /MediaItems/TranscodeVideo/NTSC/20.mp4 HTTP/1.1
    Host: 192.168.7.53:8200
    User-Agent: VLC/2.0.5 LibVLC/2.0.5
    Range: bytes=0-
    Connection: close
    Icy-MetaData: 1

    [2013/06/22 13:21:01] upnphttp.c:2406: info: TranscodeVideo/NTSC/20.mp4 is selected
    [2013/06/22 13:21:01] upnpevents.c:422: debug: upnpevents_selectfds: 0x12a3f0 2 9
    [2013/06/22 13:21:01] upnphttp.c:2599: info: Serving DetailID: 20 [/home/user/dlna/FORCETRANSCODE/engine-rebuild.mp4]
    [2013/06/22 13:21:01] upnphttp.c:2825: info: Following is the response
    HTTP/1.1 206 OK
    Content-Type: video/mpeg
    X-AvailableSeekRange : 1 npt=0.0-85033.757
    TimeSeekRange.dlna.org : npt=0.0-85033.757/236.986
    transferMode.dlna.org: Streaming
    Accept-Ranges: none
    Connection: close
    Date: Sat, 22 Jun 2013 17:21:01 GMT
    EXT:
    realTimeInfo.dlna.org: DLNA.ORG_TLAG=*
    contentFeatures.dlna.org: DLNA.ORG_PN=MPEG_PS_NTSC;DLNA.ORG_OP=10;DLNA.ORG_CI=1
    Server: Debian/7.1 DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.0.25

    [2013/06/22 13:21:01] upnphttp.c:2838: info: last_file.mime=video/mp4
    [2013/06/22 13:21:01] upnphttp.c:1811: info: start transcode and send data
    [2013/06/22 13:21:01] upnphttp.c:1813: info: fork/exec MENCODER/FFMPEG, PPID=2881, PID=2883
    [2013/06/22 13:21:01] upnphttp.c:1667: debug: streaming from: /home/user/dlna/FORCETRANSCODE/engine-rebuild.mp4
    [2013/06/22 13:21:01] upnphttp.c:1730: info: exec mencoder as follows:
    mencoder -ss 0.0 -endpos 85033.758 -msglevel all=-1 -really-quiet -oac lavc -of mpeg -mpegopts format=mpeg2:muxrate=8000:vbuf_size=1194:abuf_size=64 -vf scale=720:480,harddup -ovc lavc -channels 2 -lavdopts debug=0 -lavcopts autoaspect=1:vcodec=mpeg2video:vbitrate=8000:acodec=ac3:abitrate=128:keyint=18:vqscale=1:vqmin=2 -subdelay 20000 -ofps 30000/1001 -mc 0 -noskip -af lavcresample=48000 -srate 48000 -o - "/home/user/dlna/FORCETRANSCODE/engine-rebuild.mp4"
    [2013/06/22 13:21:02] upnphttp.c:1840: info: reached to EOF in PID:2883
    [2013/06/22 13:21:02] upnphttp.c:1874: info: kill PID(2884) : No child processes
    [2013/06/22 13:21:02] upnphttp.c:1883: info: total bytes : read=0, send=0
    [2013/06/22 13:21:02] upnpevents.c:457: debug: upnpevents_processfds: 0x12a3f0 2 9 0 0
    [2013/06/22 13:21:02] minidlna.c:1401: debug: HTTP connection from 192.168.7.50:3199
    [2013/06/22 13:21:02] upnpevents.c:422: debug: upnpevents_selectfds: 0x12a3f0 2 9
    [2013/06/22 13:21:02] upnpevents.c:457: debug: upnpevents_processfds: 0x12a3f0 2 9 0 0
    [2013/06/22 13:21:02] upnphttp.c:295: debug: Range Start-End: 0 - -1
    [2013/06/22 13:21:02] upnphttp.c:999: debug: HTTP REQUEST: GET /MediaItems/25.avi HTTP/1.1
    Host: 192.168.7.53:8200
    User-Agent: VLC/2.0.5 LibVLC/2.0.5
    Range: bytes=0-
    Connection: close
    Icy-MetaData: 1

     
    Last edit: Jruuu 2013-06-22
  • hiero
    hiero
    2013-06-23

    It seems mencoder does not transcode correctly.
    Would you execulte mencoder as follows.

    mencoder -ss 0.0 -endpos 85033.758 -oac lavc -of mpeg -mpegopts format=mpeg2:muxrate=8000:vbuf_size=1194:abuf_size=64 -vf scale=720:480,harddup -ovc lavc -channels 2 -lavdopts debug=0 -lavcopts autoaspect=1:vcodec=mpeg2video:vbitrate=8000:acodec=ac3:abitrate=128:keyint=18:vqscale=1:vqmin=2 -subdelay 20000 -ofps 30000/1001 -mc 0 -noskip -af lavcresample=48000 -srate 48000 -o test.mpg "/home/user/dlna/FORCETRANSCODE/engine-rebuild.mp4"

    If no error occured and "test.mpg" was output, try to playback it by vlc.

    Hiero

     
  • Nunnsy
    Nunnsy
    2013-06-26

    Hi there,

    first of all thanks for all the work you've put into this.

    I've run miniDlna in debug mode and it stops when it says there's no data in the pipe. I'm guessing that's because CPU enocoding of mpeg2 is too slow. I'm not sure if I need to purchase the mpeg2 license for encoding to work on the GPU. (This is on an ARM based board)

    This is the debug output:
    [2013/06/27 08:07:12] upnphttp.c:2320: info: TranscodeVideo/NTSC/7921.mkv is selected
    [2013/06/27 08:07:12] upnphttp.c:2515: info: Serving DetailID: 7921 [/mnt/usb2/media/TV Shows/Sherlock/FORCETRANSCODE/Pilot.mkv]
    [2013/06/27 08:07:12] upnphttp.c:2761: info: Following is the response
    HTTP/1.1 206 OK
    Content-Type: video/mpeg
    X-AvailableSeekRange : 1 npt=0.0-3314.599
    TimeSeekRange.dlna.org : npt=0.0-3314.599/3314.600
    transferMode.dlna.org: Streaming
    Accept-Ranges: none
    Connection: close
    Date: Wed, 26 Jun 2013 22:07:12 GMT
    EXT:
    realTimeInfo.dlna.org: DLNA.ORG_TLAG=*
    contentFeatures.dlna.org: DLNA.ORG_PN=MPEG_PS_NTSC;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01500000000000000000000000000000
    Server: 3.6.11+ DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.1.0

    [2013/06/27 08:07:12] upnphttp.c:2774: info: last_file.mime=video/x-matroska
    [2013/06/27 08:07:12] upnphttp.c:1723: info: start transcode and send data
    [2013/06/27 08:07:12] upnphttp.c:1725: info: fork/exec MENCODER/FFMPEG, PPID=3084, PID=3088
    [2013/06/27 08:07:12] upnphttp.c:1549: debug: streaming from: /mnt/usb2/media/TV Shows/Sherlock/FORCETRANSCODE/Pilot.mkv
    [2013/06/27 08:07:12] upnphttp.c:1612: info: exec mencoder as follows:
    mencoder -ss 0.0 -endpos 3314.600 -msglevel all=-1 -really-quiet -oac lavc -of mpeg -mpegopts format=mpeg2:muxrate=8000:vbuf_size=1194:abuf_size=64 -vf scale=720:480,harddup -ovc lavc -channels 2 -lavdopts debug=0 -lavcopts autoaspect=1:vcodec=mpeg2video:vbitrate=8000:acodec=ac3:abitrate=128:keyint=18:vqscale=1:vqmin=2 -subdelay 20000 -ofps 30000/1001 -mc 0 -noskip -af lavcresample=48000 -srate 48000 -o - "/mnt/usb2/media/TV Shows/Sherlock/FORCETRANSCODE/Pilot.mkv"
    [2013/06/27 08:07:16] upnphttp.c:1746: debug: poll error : No data in Pipe
    [2013/06/27 08:07:16] upnphttp.c:1792: info: kill PID(3089) : No child processes
    [2013/06/27 08:07:16] upnphttp.c:1797: info: total bytes : read=2048, send=2048
    ^C[2013/06/27 08:07:29] minidlna.c:158: warn: received signal 2, good-bye

    Thanks,
    - Nunnsy

     
    Last edit: Nunnsy 2013-06-26
  • Hey guys, I've decided to pop in to tell you that my minidlna-transcode project has been moved & renamed (according to upstream) to:

    https://bitbucket.org/stativ/readymedia-transcode

    The transcoding support resides in the transcode branch.

    When it comes to changes from the last time, it is finally possible to have different settings for different clients (more info is in minidlna.conf) and the example transcoding scripts are installed in /usr/share/minidlna/scripts.

     
  • hiero
    hiero
    2013-06-29

    Hello Nunnsy,

    The log says only 2048 was output from mencoder. It is too small data.
    Some error might occur in mencoder. Do you try to encode manually as follows.
    Something can be read in mencoder log message.

    mencoder -ss 0.0 -endpos 3314.600 -oac lavc -of mpeg -mpegopts format=mpeg2:muxrate=8000:vbuf_size=1194:abuf_size=64 -vf scale=720:480,harddup -ovc lavc -channels 2 -lavdopts debug=0 -lavcopts autoaspect=1:vcodec=mpeg2video:vbitrate=8000:acodec=ac3:abitrate=128:keyint=18:vqscale=1:vqmin=2 -subdelay 20000 -ofps 30000/1001 -mc 0 -noskip -af lavcresample=48000 -srate 48000 -o a.mpg "/mnt/usb2/media/TV Shows/Sherlock/FORCETRANSCODE/Pilot.mkv"

    Hiero

     
    • Nunnsy
      Nunnsy
      2013-06-29

      Ahh thank you. It only renders at around 3 to 4 frames per second so that's really useful. I've been trying to minimise the resources required to transcode but obviously it seems it needs more. I'm not sure whether mEncoder is using the GPU though, as I thought it would be running quite smoothly. Hmm, interesting.

      I'm trying to do this on the Raspberry Pi, and I'm not sure if it's possible but I'm giving it a shot. I've found another transcode library, omxtx, which seems to have some good reports running on the Pi. The machine has a powerful enough GPU to transcode all the video real time, it's just I'm having trouble figuring out if I need to pay for an MPEG-2 license for the GPU to transcode, rather than the CPU.

      UPDATE: I purchased the license keys. No luck for harnessing the GPU. The Pi can transcode the video to h264 at around 150 fps at a resolution of the source file being around 700x400, which most of them are. The transcode was using omxtx and was able to quickly convert the video file. Any suggestions would be greatly appreciated.

      Thanks for the time and support,
      - Nunnsy

       
      Last edit: Nunnsy 2013-06-30
  • vonmatrices
    vonmatrices
    2013-07-08

    I've just built miniDLNA with transcoding support from

    https://bitbucket.org/stativ/readymedia-transcode

    Everything is working fine - for video I have the options set so it will transcode avi containers using FFMPEG. The script I am using is the default transcode-video script provided with the above implmentation.

    I am using VLC on Debian (wheezy) to watch the videos, but when transcoding with FFMPEG, it is impossible to fast forward, rewind, or skip ahead by time (pausing works fine). Is there any options I can pass to ffmpeg to provide this functionality? This is the current script:

    !/bin/sh

    SOURCE=$1
    STARTPOSITION=$2
    DURATION=$3

    ffmpeg -ss $STARTPOSITION -t $DURATION -i "$SOURCE" -loglevel quiet -threads auto -async 2 -target pal-dvd pipe:1

     
  • hiero
    hiero
    2013-07-11

    In order to support FF, REW and SEEK for transcoded stream on DLNA, it is required to support "time based seek" functionality by the player. But, it does not seem VLC support it.

     
  • travis
    travis
    2013-11-19

    I've been having some weird trouble with the 1.1.0 patch and Shoutcast transcoding. According to the log it's running ffmpeg -i "ffmpeg -i"

    [2013/11/19 17:48:48] upnphttp.c:2838: info: last_file.mime=audio/mpeg
    [2013/11/19 17:48:48] upnphttp.c:1811: info: start transcode and send data
    [2013/11/19 17:48:48] upnphttp.c:1813: info: fork/exec MENCODER/FFMPEG, PPID=20759, PID=21163
    [2013/11/19 17:48:48] upnphttp.c:1667: debug: streaming from: http://ca.ah.fm:443
    [2013/11/19 17:48:48] upnphttp.c:1730: info: exec ffmpeg as follows:
    ffmpeg -i "ffmpeg -i " -t 86400 -v 0 -loglevel quiet -f mp3 -vn -acodec libmp3lame -ab 256k pipe:1
    [2013/11/19 17:48:49] upnphttp.c:1840: info: reached to EOF in PID:21163
    [2013/11/19 17:48:49] upnphttp.c:1874: info: kill PID(21164) : No child processes
    [2013/11/19 17:48:49] upnphttp.c:1883: info: total bytes : read=0, send=0

    Not sure what's causing this to happen. Any ideas?

    minidlna.conf: https://gist.github.com/exiva/7549595
    ffmpeg version info: https://gist.github.com/exiva/7549595#file-gistfile2-txt
    test playlist file: https://gist.github.com/exiva/7549595#file-gistfile3-txt

     
  • hiero
    hiero
    2013-12-08

    I found a bug which appears on gcc 4.8.
    This makes "ffmpeg -i " as source to access streaming as shoutcast.
    This bug is fixed in the transcode patch for minidlna-1.1.1.

     
  • hiero
    hiero
    2013-12-08

    support transcode Video and Audio patch against 1.1.1 support Linux and Cygwin

    I made a mistake to create the patch.
    The patch file was replaced with "minidlna_transcode-1.1.1.tar.gz".

     
    Last edit: hiero 2013-12-14
  • hiero
    hiero
    2014-01-11

    support transcode Video and Audio patch against 1.1.1 support Linux and Cygwin

    also worked on FreeBSD and MAC OSx

    add to support "Don't require a configured network interface to start up, and add network interface monitoring support" for Cygwin
    and fixed some minor bugs

     
    Last edit: hiero 2014-01-12
  • Krzychu
    Krzychu
    2014-02-04

    Hi, sorry for my English. I have a problem with my NAS Zyxel NSA 310. I install ffpstick 0.7 and then minidlna 1.1.0. It's working ok but it doesn't transcode to mpeg2. I have TV Sony Bravia W655a which have problem which play this videos. Can I get installed this patch on my NAS via putty? If yes what can I do it? Please for help.

     
<< < 1 .. 6 7 8 (Page 8 of 8)