Sign up here and you can log into the forum!

ffmpeg transcoding on the wdtv - success and failure

Discussion, features, plugins--everything about zoster's UMSP UPnP Media Server software

Re: ffmpeg transcoding on the wdtv - success and failure   

Postby mad_ady » Thu Nov 29, 2012 3:51 am

I haven't tried with avi, but I have tried with mpegts. For mpegts, not specifying -vcodec or -acodec leads to them being converted to a default format (e.g. mpeg2video/mp2 audio), and this is what I'm trying to avoid, because transcoding is an expensive proces...

I will try with avi, but I bet it will be converted to xvid or some other codec and the performance will be terrible...
User avatar
mad_ady
Developer
 
Posts: 4562
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: ffmpeg transcoding on the wdtv - success and failure   

Postby mad_ady » Thu Nov 29, 2012 7:45 am

I tried playing the files I created today, and they wouldn't play - as expected. The original recording I did on the camera (Motion_2012-11-29_10-14-11.avi) (using the camera's web interface) plays fine, though...

I also tried encoding to avi with no other parameters set, and it tries to convert to mpeg4 + ac3. It gets about 2fps...
Code: Select all
root@Deneb:/tmp/mnt/6c67aa8a-e447-4f27-be88-150f6f42fceb/test-video# ffmpeg -rtsp_transport tcp -i rtsp://192.168.1.10/camera-h264-stream.sdp -f a
vi auto-auto-avi.avi
ffmpeg version 0.11.2 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 15 2012 17:48:06 with gcc 4.3.2
  configuration: --prefix=/apps/ffmpeg --enable-cross-compile --arch=mipsel --target-os=linux --cc=/opt/mips-4.3/bin/mipsel-linux-gcc --strip=/opt/mips-4.3/bin/mipsel-linux-strip --disable-doc --disable-static --enable-shared --disable-yasm
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
[rtsp @ 0x43c470] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://192.168.1.10/camera-h264-stream.sdp':
  Metadata:
    title           : IPCam
  Duration: N/A, start: 0.000000, bitrate: 64 kb/s
    Stream #0:0: Video: h264 (Baseline), yuv420p, 640x480, 49.92 tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
File 'auto-auto-avi.avi' already exists. Overwrite ? [y/N] y
w:640 h:480 pixfmt:yuv420p tb:1/90000 sar:0/1 sws_param:flags=2
[buffersink @ 0x445480] No opaque field provided
[aformat @ 0x526590] auto-inserting filter 'auto-inserted resampler 0' between the filter 'src' and the filter 'aformat'
[aresample @ 0x4571d0] chl:mono fmt:s16 r:8000Hz -> chl:mono fmt:flt r:8000Hz
Output #0, avi, to 'auto-auto-avi.avi':
  Metadata:
    INAM            : IPCam
    ISFT            : Lavf54.6.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 640x480, q=2-31, 200 kb/s, 49.92 tbn, 49.92 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 8000 Hz, mono, flt, 96 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg4)
  Stream #0:1 -> #0:1 (pcm_alaw -> ac3)
Press [q] to stop, [?] for help
frame=   68 fps=1.9 q=13.6 size=     662kB time=00:00:35.90 bitrate= 151.1kbits/s

The video plays back at full framerate (meaning I get about 2 seconds of video from above).


... Hold on, I'm trying something else...
User avatar
mad_ady
Developer
 
Posts: 4562
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: ffmpeg transcoding on the wdtv - success and failure   

Postby mad_ady » Thu Nov 29, 2012 8:45 am

Ok, time for good news and bad news :D

First the good news - I managed to get it to play on the wdtv! Here's how:
Seeing that the default codec for avi was mpeg4, I went ahead and tried to stream from my mpeg4 stream, instead of h264 stream (The camera can stream either as h264 or as mpeg4). The reason I didn't try this before was that the mpeg4 rtsp stream does not play in VLC and I didn't want to try out something that didn't work...

So I tried this:
Code: Select all
ffmpeg -re -rtsp_transport tcp -i 'rtsp://192.168.1.10/camera-mpeg4-stream.sdp' -vcodec copy -acodec ac3 -re  -f avi mpeg4-ac3-avi.avi

When I saved to a file, the content played, but the fps was low - about 3-6 fps.
Then I tried to encode to a pipe - I don't know what got over me - but I noticed that when writing to /dev/null I got 12 FPS!

So I modified the proxy to IP Camera plugin to use the command below and now I get a nice 12fps stream that I can watch. Also, by copying the input stream, I get a high enough bandwidth so that there is no noticeable buffering when starting the video (for mpegts I had to wait about 2 minutes before playback would start).

The winning command!
Code: Select all
ffmpeg -re -rtsp_transport tcp -i 'rtsp://192.168.1.10/camera-mpeg4-stream.sdp' -vcodec copy -acodec ac3 -re  -f avi pipe:1
ffmpeg version 0.11.2 Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 15 2012 17:48:06 with gcc 4.3.2
  configuration: --prefix=/apps/ffmpeg --enable-cross-compile --arch=mipsel --target-os=linux --cc=/opt/mips-4.3/bin/mipsel-linux-gcc --strip=/opt/mips-4.3/bin/mipsel-linux-strip --disable-doc --disable-static --enable-shared --disable-yasm
  libavutil      51. 54.100 / 51. 54.100
  libavcodec     54. 23.100 / 54. 23.100
  libavformat    54.  6.100 / 54.  6.100
  libavdevice    54.  0.100 / 54.  0.100
  libavfilter     2. 77.100 /  2. 77.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 15.100 /  0. 15.100
[rtsp @ 0x43c470] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for  Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://192.168.1.10/camera-mpeg4-stream.sdp':
  Metadata:
    title           : IPCam
  Duration: N/A, start: 0.000000, bitrate: 64 kb/s
    Stream #0:0: Video: mpeg4 (Simple Profile), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 30 fps, 30 tbr, 90k tbn, 30 tbc
    Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
[aformat @ 0x452520] auto-inserting filter 'auto-inserted resampler 0' between the filter 'src' and the filter 'aformat'
[aresample @ 0x472b20] chl:mono fmt:s16 r:8000Hz -> chl:mono fmt:flt r:8000Hz
Output #0, avi, to 'pipe:1':
  Metadata:
    INAM            : IPCam
    ISFT            : Lavf54.6.100
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 30 fps, 60 tbn, 60 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 8000 Hz, mono, flt, 96 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (pcm_alaw -> ac3)
Press [q] to stop, [?] for help
frame=   84 fps= 11 q=-1.0 size=     996kB time=00:00:07.50 bitrate=1087.5kbits/s   


Now - the bad:
1. I get no audio. I could hear some cracking noises every 2-3 seconds when encoding as mp2 or ac3, but no meaningful sound. I will need to look into it.
2. The streaming breaks after a while - It usually plays fine for 2-3 minutes and then the image freezes. However, it also froze after a couple of frames, or it played fine for 20 minutes now! So, playback is a bit unreliable, but that's life (could be related to network problems/latencies - because I am streaming from a remote site (don't be fooled by the local IP address :P))...


So - let's try to find some conclusions:
1. Finding the correct codec/format combination depends on many parameters - I think I did about 50 tests before reaching this one...
2. Pipes are completely different than files!
3. MPEG4 != H.264

Thank you all for your suggestions and patience and I hope these posts may help others in the future.
Now, if you'll excuse me, I have a plugin to upload...
User avatar
mad_ady
Developer
 
Posts: 4562
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Previous

Return to UMSP Media Server

Who is online

Users browsing this forum: No registered users and 1 guest