FFMPEG Transcoding

[Introduction]

        When the video is streaming over enough bandwidth networks, the delivered video quality is good. But when the link is congested and bandwidth is not enough to transmit all the video packets, the delivered video quality is worse. So in this case, we can use transcoding to let the bandwidth requirement for video streaming become less. Then the delivered video quality may not be good, but can still be acceptable.

 

[Prerequisite]

        Please read this lab first.

 

[Test Case 1: when the bandwidth is enough]

#!/usr/bin/python

 

"""

This example shows how to work with different APs

"""

from mininet.net import Mininet

from mininet.node import  Controller, RemoteController, OVSKernelSwitch

from mininet.cli import CLI

from mininet.log import setLogLevel

from mininet.link import TCLink

 

def topology():

    "Create a network."

    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

 

    print "*** Creating nodes"

    h1 = net.addHost( 'h1', ip="192.168.10.1/24", mac='00:00:00:00:00:01')  #video sender

    h2 = net.addHost( 'h2', ip="192.168.10.2/24", mac='00:00:00:00:00:02')  #video receiver

    h3 = net.addHost( 'h3', ip="192.168.10.3/24", mac='00:00:00:00:00:03')  #video transcoder. not used in this case

    s1 = net.addSwitch( 's1', listenPort=6673, mac='00:00:00:00:00:03')

    c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633 )

 

    print "*** Adding Link"

    net.addLink(h1, s1)

    net.addLink(s1, h2, bw=1, max_queue_size=100)

    net.addLink(s1, h3)

 

    print "*** Starting network"

    net.build()

    c0.start()

    s1.start( [c0] )

    print "*** Running CLI"

    CLI( net )

    print "*** Stopping network"

    net.stop()

 

if __name__ == '__main__':

    setLogLevel( 'info' )

    topology()

 

 

At the receiver side (h2), run the command as shown below.

 

At the sender side (h1), run the command as shown below.

 

When the transmission is finished, use ctrl+c to terminate the receiving process at h2.

Decoding the ts to yuv format.

 

Compare the rec.yuv with original yuv file to get the PSNR.

 

We can get the average PSNR, 37.1788.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                                                                        

 

[Test 2: when the bandwidth is not enough]

#!/usr/bin/python

 

"""

This example shows how to work with different APs

"""

from mininet.net import Mininet

from mininet.node import  Controller, RemoteController, OVSKernelSwitch

from mininet.cli import CLI

from mininet.log import setLogLevel

from mininet.link import TCLink

 

def topology():

    "Create a network."

    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

 

    print "*** Creating nodes"

    h1 = net.addHost( 'h1', ip="192.168.10.1/24", mac='00:00:00:00:00:01')  #video sender

    h2 = net.addHost( 'h2', ip="192.168.10.2/24", mac='00:00:00:00:00:02')  #video receiver

    h3 = net.addHost( 'h3', ip="192.168.10.3/24", mac='00:00:00:00:00:03')  #video transcoder. not used in this case

    s1 = net.addSwitch( 's1', listenPort=6673, mac='00:00:00:00:00:03')

    c0 = net.addController('c0', controller=Controller, ip='127.0.0.1', port=6633 )

 

    print "*** Adding Link"

    net.addLink(h1, s1)

    net.addLink(s1, h2, bw=0.4, max_queue_size=50)  #not enough bw for video transmission

    net.addLink(s1, h3)

 

    print "*** Starting network"

    net.build()

    c0.start()

    s1.start( [c0] )

    print "*** Running CLI"

    CLI( net )

    print "*** Stopping network"

    net.stop()

 

if __name__ == '__main__':

    setLogLevel( 'info' )

    topology()

 

We can get worse PSNR values.

 

Test 3: transcoding

Minint script is the same as Test 2.

 

Receiver (h2)

 

Transcoder (h3)

 

Sender (h1)

 

Then we can get better PSNR values.

 

[Reference]

https://trac.ffmpeg.org/wiki/StreamingGuide

 

Dr. Chih-Heng Ke (smallko@gmail.com)

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan.