Convert MPEG-2 files to MPEG-4

Image result for Canon XF-105
Canon XF105

This is a note to self, and could potentially also be useful to others in need of converting “old-school” MPEG-2 files into more modern MPEG-4 files using FFmpeg.

In the fourMs lab we have a bunch of Canon XF105 video cameras that record .MXF files with MPEG-2 compression. This is not a very useful format for other things we are doing, so I often have to recompress them to something else.

Inspecting one of the files, I just also discovered that they record the audio onto two mono channels:

Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 50000 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc

Stream #0:1: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s

Stream #0:2: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s

So I also want to merge these two mono tracks (which are the left and right inputs of the camera) to a stereo track. FFmpeg comes in handy (as always), and I figured out that this little one-liner will do the trick:

ffmpeg -i input.mxf -vf yadif -vcodec libx264 -q:v 3 -filter_complex "[0:a:0][0:a:1]amerge,channelmap=channel_layout=stereo[st]" -map 0:v -map "[st]" output.mp4

An explanation of some of these settings:

  • yadif: this is for deinterlacing the video
  • libx264: this is probably unnecessary, but forces to use the better MPEG-4 compressor
  • q:v 3: I find this to be a good setting for the video compressor
  • filter_complex: this complex string (courtesy of reddit) does the merging of the two mono sources

Will probably try to add it to MGT-terminal at some point, but this blog post will suffice for now.

Simple tips for better video conferencing

Image result for video meeting

Very many people are currently moving to video-based meetings. For that reason I have written up some quick advise on how to improve your setup. This is based on my interview advise, but grouped differently.


Image result for network clipart

The first important thing is to have as good a network as you can. Video conferencing requires a lot of bandwidth, so even though your e-mail and regular browsing works fine, it may still not be sufficient for good video transmission.

  • Cabled network: If you are able to connect with an Ethernet cable to your router, that would usually always be the best and most solid solution.
  • Wireless network: If cable won’t work for you (it is also difficult logistically in my own apartment), try to get as close as possible to your wi-fi router.


Image result for headset clipart

I would argue that improving the audio is more important than the video for video conferencing. Most video conferencing systems (Skype, Zoom, etc.) will prioritize the audio channel, which means that the video may stutter while the audio is passing through fine.

The main trick is to aim for separating the “foreground” as much as possible from the “background”. There are some very basic audio principles to follow:

  • Use a headset: The best way to get decent sound for video conferencing, is to move the microphone as close as possible to your mouth. Headsets with a microphone boom in front of your face are the best, but a regular mobile phone headset (the one that came with your mobile phone, for example) would still be better than nothing.
  • Use headphones: If you for some reason do not have a headset with built-in microphone, using a regular pair of headphones is still better than using the speakers on your computer. With this setup you use the microphone on the computer, which may not be ideal, but at least you won’t get feedback problems.
  • Avoid reverberant rooms: If you aim for clarity in conversation, it is typically better to sit in a smaller and more damped room than a large one. That means that a bedroom is typically better than a larger living room. If you use a headset this is less important, but particularly if you only use the built-in microphone and speakers on a laptop, this could make a huge difference in how your voice gets through.
  • Mute yourself: In most system there is a button to mute yourself. If you are not talking all the time, it helps to mute yourself from the discussion. Just remember to unmute when you want to say something!


Image result for webcam clipart

The same principle of separating “foreground” from “background” applies to the video.

  • Lighting: To obtain the best possible video image, think about your placement with respect to lighting. It is, for example, not ideal to sit in front of a window, since a bright light in the background will make it difficult to see your face.
  • Background: The best is to sit in front of a plain wall. If that is not possible, consider whether the background of your image is what you want to show to your fellow students/colleagues.
  • Video angle: If you are using the built-in camera on your computer you may not have too many options for how to place the camera. But you may still consider shifting the camera position so that you and your surroundings look as good as possible.

Summing up

There are, of course, many ways to improve your video conferencing setup. Many people believe that you need to invest in expensive equipment to get good results. But even cheap consumer products are very capable of producing decent results these days. So it is more a matter of optimizing what you have. Good luck!

Testing simple camera and microphone setups for quick interviews

We just started a new run of our free online course Music Moves. Here we have a tradition of recording wrap-up videos every Friday, in which some of the course educators answer questions from the learners. We have recorded these in many different ways, from using high-end cameras and microphones to just using a handheld phone. We have found that using multiple cameras and microphones is too time-consuming, both in setup and editing. Using only a mobile phone is extremely easy to set up, but we have had challenges with the speech’s audibility. Before recording this semester’s wrapup videos, I, therefore, decided to test out some solutions based on the equipment I had lying around:

  • Sony RX100 V
  • GoPro Hero 7 w/o audio connector
  • Zoom Q8
  • Samsung Galaxy Note 8
  • Røde Smartlav+ lavalier microphone
  • DPA Core 4060 lavalier microphone

In the following I will show some of the results of the testing.

Testing various devices in my office.

Sony RX 100 V

First out was the Sony RX 100 V, which is my preferred stills camera. It is small, yet has a large image chip. This makes it able to capture much nicer photos than my phone. The biggest problem with the Sony camera is that it does not have a separate microphone input. So I had to rely on the sound from the built-in microphones. As can be imagined, the image quality is good, although the focus is slightly off in this recording. The audio is ok, but the built-in microphone picks up a lot of ambient sounds. It works, but it is clearly not a good solution for this type of setup.

GoPro Hero 7

Then I moved on to the GoPro Hero 7 with just the built-in microphone. This worked much better than expected. The audio is quite clear, and it is easy to hear what I am saying. The colours of the video are vivid, but the image is compressed quite a bit. The video is very wide-angled, which is super-practical for such an interview setting, although it looks slightly skewed on the edges. But overall this was a positive surprise.

Connecting a Røde Smartlav+ to the GoPro results in an immaculate sound. In fact, this could have been a very nice setup, had it not been for some challenges with placing the camera. That is because the audio dongle for the GoPro is (1) bent downwards and (2) this makes it impossible to use the housing needed to put it on a tripod (as can be seen in the picture to the right). This makes it super-clumsy to use this setup in a real-life situation. I hear rumours about a new audio add-on for new GoPro cameras, which may be very interesting to check out.

Zoom Q8

My next device is Zoom Q8. This is actually a sound recorder with a built-in camera, so one would expect audio to be the main priority. This is also the case. The video is quite noisy, but the sound quality is much better than with the GoPro. Still, I find that the microphone picks up quite a bit of the room. This is good for music recordings, but not so good when the focus is on speech quality.

Hooking up a DPA 4060 lavalier microphone to the Zoom Q8 definitely helps. This is a high-quality microphone, and it needs phantom power (which the Zoom Q8 can deliver). As expected, this gives great sound, loud and clear. The downside is that it requires bringing an extra XLR cable together with the microphone and camera since the DPA cable is too short for such an interview setup. I like the wide-angle of the video, but the quality of the video is not very good.

Samsung Galaxy Note 8

Mobile phones are becoming increasingly powerful, and I also had to try the camera of my Samsung Galaxy Note 8. I have a small Manfrotto mobile phone stand, making it possible to place it on a tripod at a suitable distance. After recording, I realized how much less wide-angle the phone image is than the GoPro and Zoom cameras, leaving my head cut off in the shots. This doesn’t matter for the testing here, however. The first video is using the built-in microphone of the mobile phone. I am very positively surprised about how crisp and clear my voice is coming through here. In fact, it is quite similar to the GoPro. The video quality is also very good—clearly, the runner-up after the Sony camera.

And, finally, I connected the SmartLav+ lavalier microphone to the Samsung phone. Here the sound is, of course, very similar to the GoPro recordings.


It is not entirely straight forward to conclude from this testing, but here are some of my thoughts after this very rapid and not very systematic testing:

  • Using on-body microphones (lavalier) greatly improves the audibility as compared to using built-in microphones.
  • The DPA 4060 is great, but the Smartlav+ is more than good enough for interviews.
  • The GoPro could have been a great device for such interviews, had it not been for the skewed image and the clumsiness of the audio adaptor.
  • Unfortunately, even though the Zoom Q8 is the best audio device (as it should!), its video is too bad to be used for such recordings.
  • All in all, I think that the easiest and best solution is the Samsung phone with Smartlav+.

Testing Blackmagic Web Presenter

Blackmagic Web PresenterWe are rapidly moving towards the start of our new Master’s programme Music, Communication & Technology. This is a unique programme in that it is split between two universities (in Oslo and Trondheim), 500 kilometres apart. We are working on setting up a permanent high-quality, low-latency connection that will be used as the basis for our communication. But in addition to this permanent setup we need solutions for quick and easy communication. We have been (and will be) testing a lot of different software and hardware solutions, and in a series of blog posts I will describe some of the pros and cons of these.

Today I have been testing the Blackmagic Web Presenter. This is a small box with two video inputs (one HDMI and one SDI), and two audio inputs (one XLR and one stereo RCA). The box functions as a very basic video/audio mixer, but the most interesting thing is that it shows up as a normal web camera on the computer (even in Ubuntu, without drivers!). This means that it can be used in most communication platforms, including Skype, Teams, Hangouts,, Zoom, etc., and be the centerpiece of slightly more advanced communication.

My main interest in testing it now was to see if I could connect a regular camera (Canon XF105) and a document camera (Lumens DC193) to the device. As you can see in the video below, this worked flawlessly, and I was able to do a quick recording using the built-in video recorder (Cheese) in Ubuntu.

So to the verdict:


  • No-frills setup, even on Ubuntu!
  • Very positive that it scales the video correctly. My camera was running 1080i and the document camera 780p, and the scaling worked flawlessly (you need the same inputs for video transition effects to work, though, but not really a problem for my usage).
  • Hardware encoding makes it easy to connect also to fairly moderate PCs.
  • Nice price tag (~$500).


  • Most people have HDMI devices, but SDI is rare. We have a lot of SDI stuff, so it works fine for our use.
  • No phantom power for the XLR. This is perhaps the biggest problem, I think. You can use a dynamic microphone, but I would have preferred a condenser. Now I ended up connecting a wireless lavalier microphone, with a line-level XLR connection in the receiver. It is also possible to use a mixer, but the whole point of this box is to have a small, portable and easy set up.
  • 720p output is ok for many things we will use it for, but is not particularly future-proof.
  • It has a fan. It makes a little more noise than when my laptop fan kicks in, but is not noticeable if it is moved one meter away.

Not perfect, but for its usage I think it works very nicely. For meetings and teaching where it is necessary to have a little more than just a plain web camera, I think it does it job nicely.

Trim video files using FFmpeg

This is a note to self, and hopefully to others, about how to easily and quickly trim videos without recompressing the file.

I often have long video recordings that I want to split or trim (side note: sometimes people call this “cropping”, but in my world cropping is to cut out parts of the image, that is, a spatial transformation. Splitting and trimming are temporal transformations).

You can split and trim files in most graphical video editing software, but these will typically also recompress the file on export. This reduces the quality of the video, and it also takes a long time. A much better solution is to perform “lossless” trimming. Fortunately, there is a way to do this with the wonderful command-line utility FFmpeg. It is available for most platforms and has a ton of different options. So to remember how it is done, here is a simple one-liner:

ffmpeg -i input.mp4 -ss 01:19:27 -to 02:18:51 -c:v copy -c:a copy output.mp4

This will cut out the section from about 1h19min (after the -ss command) to 2h18min (after the -to command). The copy parts of the command are meant to copy both the original audio and video content without recompressing. This means that the above command only takes a few seconds to run.

You may instead want to specify a fixed duration to extract, in which case you can use:

ffmpeg -i input.mp4 -ss 00:01:10 -t 00:01:05 -c:v copy -c:a copy output.mp4

This will extract 1min5sec (using the -t flag) starting from 1min10sec (the -ss flag) in the file. Happy trimming!