Concatenate Videorecording clips with Mencoder

Hi

I am having a big issue which is taking me a long time to figure out.

I have used WOWZA’s videorecording to record 2 videos.

I am trying to cocatenate them together and the video always does this without any problems but I cannot get the audio in sync with the video.

The current mencoder command I am using is:

#mencoder -oac copy -ovc lavc -srate 11025 -vf scale=320:186,harddup recording1.flv recording2.flv -o together.flv

But i have tried it with additional options ‘-mc 0’ ‘-ofps 25’ and ‘-noskip’.

I have looked through other forum posts and cant find anything which can help.

Has anyone had any experience with using mencoder to concatenate 2 flv files together without losing audio sync?

Also I tried using the ‘copy’ codec instead of encoding it with ‘pcm’. But it requires the ‘-fafmttag’ audio format tag, i have tried ‘0xf0’ and ‘0x08’ as found in http://osflash.org/flv but I think I am missing something with this as clearly I am not a video encoding expert (or even close).

I can send you the results of ‘#mplayer -identify’ with either a recording file or my cocatenated file if it will help analyse where the audio is going wrong.

look forward to any help

regards

Craig

Hi Craig,

This worked for me:

mencoder file_0.flv file_1.flv -ovc copy -oac mp3lame -o output.flv

Another user reported success using the mp4box program on Windows: https://www.wowza.com/forums/showthread.php?12846-How-to-join-files-and-play-it&p=64435&highlight=#post64435

In your current setup the Flash player is acting as the encoder. It is connecting to the web camera, encoding the video and audio stream as Sorenson Spark and Speex (or NellyMoser ASAO) and sending it to Wowza over RTMP for saving to an FLV file. There are two potential ways to get this to an H.264/AAC solution.

  • Replace Flash on the client-side with an encoder such as Wirecast, Adobe Flash Media Live Encoder (read the EULA) or Nanocosmos (http://nanocosmos.de). This encoding solution would capture web camera video and encode to H.264 or AAC then send it to Wowza for recording.

  • Capture the video server-side and transcode it on the fly from Sorenson Spark and Speex to H.264 and AAC. This woud require a decoder and encoder server-side. Wowza Media Server 3 (due out later this year) will include a transcoder. We are not sure if we will have a solution for Sorenson Spark and Speex in the initial release but that may be an option. This solution would require enough CPU or GPU resources to handle all the incoming transcoding. If you have a high volume site, this could be quite expensive.

    I hope this helps.

    Charlie

You can record video from Wirecast. Just use the live-record stream type.

Charlie

It is not possible. The only way to capture H.264/AAC video and record it server side is to use an encoder that needs to be installed and replaces the Flash player as the encoder.

The next version of the Flash player may add support for H.264 encoding (not sure about AAC) so this might be an option in the future.

Charlie

I will leave it up to you to interpret Adobe’s EULA. The other options are Wirecast, FFMpeg, VLC and Nanocosmo.

Charlie

FMLE is an encoder. It broadcasts live video.

FFMpeg and VLC can also be used to broadcast video:

https://www.wowza.com/docs/how-to-use-vlc-as-a-live-stream-encoder-with-wowza-media-server-mpeg-ts)

https://www.wowza.com/docs/how-to-use-ffmpeg-with-wowza-media-server-mpeg-ts)

Charlie

Thanks for reporting back, Craig.

I assume you did have mp3lame installed when you tried my suggestion? Also, did you consider having Wowza record directly to mp4?

Please feel free to post all the steps that worked for you, in case they might help another user.

Hi

I have tried the above already unfortunately (using ‘mp3lame’ audio and ‘copy’ video), but no luck. I have made sure that the settings in the Flash file are as they were when I installed the videorecording application (it has improved things slightly, audio only 1-2 seconds off now and doesnt overlap)

I had seen mp4box but was unsure if it could convert FLV and if it worked on linux (debian or ubuntu) which are both requirements.

I will have a go now at trying to get it working on Linux and with a flv file and keep you posted on how it goes.

thanks

Seems MP4Box does work well on a Linux os. But the video format must be mp4 (as the title suggests, lol).

So I converted them both to mp4 before passing to MP4Box ensuring ‘-async 1’ was set so the audio was kept in sync.

ffmpeg -i recording1.flv -ar 11025 -r 30 -async 1 recording1.mp4

ffmpeg -i recording2.flv -ar 11025 -r 30 -async 1 recording2.mp4

MP4Box -cat recording1.mp4 -cat recording2.mp4 -new output.mp4

NOTE->seems to help to add the ‘-new’ property, else it would loop.

The recordings mp4 files are great but after using MP4Box for the concatenation the audio (right at the very end of the video) is off again. I even tried changing the first ‘-cat’ to ‘-add’ which I read could help. But no joy.

Strangely when I view a recordings mp4 and the main mp4 via 'file ’ command I see the below:

recording1 and 2 get “ISO Media, MPEG v4 system, version 1”

and output.mp4 gets “ISO Media, MPEG v4 system, version 2”

I am stumped again why this still isnt syncing the audio yet is fine for the video. I have tried with other MP4Box options ‘-rate 11025’, ‘-nodrop’, ‘-sync’ and ‘-ismax’ too.

Seems MP4Box is having same issue here as mencoder…purhaps it is the flv files themselves…or possible the bitrate (not sure as video’s ok) or sample rate (seeming as it is an audio issue), which is set to 11025khz inside the Flash file.

Am going to re-record the video’s again as strangely there is a moment at the beginning of video 2 when some frames are dropped but the audio is fine. The mp4 file for recording2 is fine too, but it appears to be at this point when the audio becomes out of sync for MP4Box.

Wish I was an expert on this.

regards

Craig

Hi

It seems fixing the Frame Dropping was the solution for the MP4Box audio out of sync.

I fixed up some details in the Flash file so that it buffers the recording without frame dropping and now the new recording MP4’s can concatenate staying in sync.

It definitely helped to use MP4Box as when I try using Mencoder with the FLV or even the MP4 files, the audio becomes out of sync. No matter what options I set.

I am now using FFMPEG again to convert it back to FLV so that it can play it in JW Player (command is below) as a Macromedia Flash File:

ffmpeg -y -i output.mp4 -f flv output.flv

Thanks for the help

regards

Craig

hi randall

really sorry for not responding quicker to this.

yes I believe i did have mp3lame installed (although my understanding was that to use mp3lame can bring on certain legal issues if used commercially).

I checked ‘mencoder -oac help’ and can see mp3lame in the list.

I never thought of recording directly to mp4, is this accomplished using the API’s then (im guessing so) ?

Unfortunately I am having further issues now converting a larger recorded FLV (500K and up) file to mp4 using ffmpeg, it always crashes. Even with a simple command like below.

’ffmpeg -y -i recording.flv recording.mp4’

I have tried various video and audio codecs solutions and none have helped.

It seems your idea to record directly to mp4 could be a solution here. I will give it a try

thanks

craig

Hi

Have managed to get it recording mp4’s…but I have to use FFMPEG (to add the AC3 audio codec and MPEG4 video codec) but it comes out worse quality v/a after this (i am unable to play it before this as the codecs are set to the Flash players, i.e. sorenson and nellymoser). I think i may need to find the way to get around this and possibly use H264.

For anybody else who wants to write files as MP4 with Wowza’s API…see the bottom of the below link:

regards

craig

Could anybody explain where the 3rd party encoder (for encoding H264 with the MP4 container) would sit and how it would work with the VideoRecording Flash object?

I have seen Wirecast been advised but its a Windows program and I am unsure how it fits into an application which is hosted on a Debian server.

If the Flash container uses Sorenson and Nellymoser codecs (even with an MP4 file) how would a 3rd party encoder be implemented with e.g. Wowza’s VideoRecording application?

I am very sorry about all the questions but I have large gaps in my knowledge with relation to recording video in a high quality MP4 container.

regards

Craig

Hi

Thanks for clarifying that all for me.

My understanding is that AFMLE can only be used with Flash Media Server or with Flash Video Streaming Service, so I am correct in saying I am unable to use this in conjunction with Wowza? Also it seems using AFMLE will be in violation of their EULA.

Unfortunately Nanocosmos is not compatible with Mac users yet, which is a requirement.

The only viable option I feel is Wirecast but even after viewing the tutorial for this from Wowza (on https://www.wowza.com/docs/how-to-use-telestream-wirecast-live-encoder-with-wowza-streaming-engine) I am unsure how I could get this to work with the VideoRecording example, is this possible (seems not as every example of Wirecast has the user using the Wirecast user interface for the recording) ?

I am also investigating using VLC now.

Sorry Charlie I should have clarified.

I would need to record the video using a Flash object (i.e. VideoRecording.swf) NOT directly with Wirecast.

We need the functionality for an online Web application so the user recording the video needs to be able to do so without downloading Wirecast.

This isnt possible is it?

I am really struggling to find a live encoder which I can plugin to flash or something so it can sit online and tap into the webcam like the VideoRecording app does (but record using H264 codec).

regards

Craig

Hi Charlie

Do you know of any encoders that can be installed and used client-side inside of a PHP/HTML web application in partnership with Wowza running server-side?

This is what I have been struggling to find, that was why Wowza is so marvellous but its unfortunate Flash doesn’t support those codecs at this time.

regards

Craig

Hi Charlie

You mentioned Adobe Flash Media Live Encoder earlier.

My understanding is that AFMLE can only be used with Flash Media Server or with Flash Video Streaming Service, I am correct in saying I am unable to use this in conjunction with Wowza? Also it seems using AFMLE will be in violation of their EULA.

I do believe I am out of options and luck :frowning:

regards

Craig

Hi Charlie

But does AFMLE record or just broadcast?

FFMPEG and VLC are surely just server-side utilities which can be used POST recording?

Its unfortunate Nanocosmo doesnt work on Mac as its API looks pretty good (expensive though…EURO 2500).

Thanks for your help thus far Charlie, I appreciate it alot.

regards

Craig

thanks for those links. Useful notes there.

I am currently investigating why our FFMPEG hangs with FLV’s above a certain size as when I try the same conversion on an Ubuntu distro, no problems.

regards

Craig