View Full Version : Problems adding Audio to Video
DrPhill
9th May 2012, 18:31
I have progressed a little further, and have hit another snag.
I am trying to add audio to my video, and failing.
My AVS script returns a video just dandy. I have an audio track (attempt4.mod2.wav) which plays just fine. So I thought that I could do the following:
soundTrack = WAVSource("attempt4.mod2.wav")
video = AudioDub(video, soundTrack)
Is it more complex than that? All I get is a silent video..... and I do not know where to start.
Thanks in advance for any help that you can give.
Gavino
9th May 2012, 18:54
Show your complete script. (That one obviously isn't)
How are you 'playing' the script or otherwise determining that there is no audio?
DrPhill
9th May 2012, 19:01
I am creating the m2v file using a batch file to drive HCEnc:
set here="C:\Users\Phill\VideoProject\FarleyFalls"
C:\Users\Phill\VideoProject\HC025\HCenc_025 -frames all -i %here%\Combine2.avs -o %here%\FarleyFalls.m2v
I am playing the output script in WindozeMediaPlayer.
I am using the following script - it is a little long, which is why I excerpted it:LoadPlugin("C:\Users\Phill\VideoProject\dgmpgdec158\DGDecode.dll")
root = "C:\Users\Phill\VideoProject\FarleyFalls\"
dissolveLength = 100
trimStart = 0
trimEnd = 600
imageWidth = 1280
imageHeight = 960
reference = MPEG2Source(root+"2012-01-04\output.d2v")
reference = BilinearResize(reference, imageWidth, imageHeight)
video = Trim(reference, trimStart, trimEnd)
reference = Subtitle(reference, "reference", y=40)
video = Subtitle(video, "2012-01-04 / " + String(FrameCount(video)), y = 40)
append = MPEG2Source(root+"2012-02-14\output.d2v")
append = Crop(append, 0, 0, -12, 0) # negative
append = AddBorders(append, 12, 6, 0, 0)
append = Crop(append, 0, 0, 0, -6) # negative
append = BilinearResize(append, imageWidth, imageHeight)
append = Subtitle(append, "2012-02-14 / " + String(FrameCount(append)), y=40)
# merge single frame to check alignment
#return Dissolve(Trim(reference, 1,1), Trim(append, 1,1), 0)
append = Trim (append, trimStart, trimEnd)
video = Dissolve(video, append, dissolveLength)
append = MPEG2Source(root+"2012-03-22\output.d2v")
append = AddBorders(append, 0, 2, 2, 0)
append = Crop(append, 2, 0, 0, -2) # negative
append = BilinearResize(append, imageWidth, imageHeight)
append = Subtitle(append, "2012-03-22 / " + String(FrameCount(append)), y=40)
# merge single frame to check alignment
#return Dissolve(Trim(reference, 1,1), Trim(append, 1,1), 0)
append = Trim (append, trimStart, trimEnd)
video = Dissolve(video, append, dissolveLength)
append = MPEG2Source(root+"2012-04-24\output.d2v")
append = AddBorders(append, 0, 0, 10, 0)
append = Crop(append, 10, 0, 0, 0) # negative
append = BilinearResize(append, imageWidth, imageHeight)
append = Subtitle(append, "2012-04-24 / " + String(FrameCount(append)), y=40)
# merge single frame to check alignment
#return Dissolve(Trim(reference, 1,1), Trim(append, 1,1), 0)
append = Trim (append, trimStart, trimEnd)
video = Dissolve(video, append, dissolveLength)
append = MPEG2Source(root+"2012-05-06\output.d2v")
append = AddBorders(append, 26, 6, 0, 0)
append = Crop(append, 0, 0, -26, -6) # negative
append = BilinearResize(append, imageWidth, imageHeight)
append = Subtitle(append, "2012-05-06 / " + String(FrameCount(append)), y=40)
# merge single frame to check alignment
#return Dissolve(Trim(reference, 1,1), Trim(append, 1,1), 0)
append = Trim (append, trimStart, trimEnd)
video = Dissolve(video, append, dissolveLength)
soundTrack = WAVSource(root+"attempt4.mod2.wav")
video = AudioDub(video, soundTrack)
return Trim(video, 0, 250)
Gavino
9th May 2012, 19:23
It looks like it ought to work.
Try temporarily replacing the last line by
return Trim(video, 0, 250).Info()
and see what audio properties are reported.
I am confused by your reference to HCEnc since it does not process audio, but you should hear audio if playing that script in WMP.
DrPhill
9th May 2012, 21:04
It looks like it ought to work.
Try temporarily replacing the last line by
return Trim(video, 0, 250).Info()
and see what audio properties are reported.
I am confused by your reference to HCEnc since it does not process audio, but you should hear audio if playing that script in WMP.
HCEnc is used to convert the AVS to m2v. I had assumed that it would convert the audio too. The audio was crerated using audacity.
Info from the modified output includes the following:
Has Audio: YES
Audio Channels: 1
Sample Type: Integer 16 bit
Samples per Second: 44100
Audio Length: 368970 samples 00:00:08.366
...........
The track is mono and was added to a silent video - does that have any bearing?
StainlessS
9th May 2012, 21:43
You need something that will accept an AVS file and encode the audio into eg mpa/mp2.
I use TMPGenc Plus v2.5 for such, you may be able to find the old version which was a 30 day
trial for MPEG2 video but free for MPEG1 video use. The audio encoder should work fine
and afterwards, you will need to multiplex the audio and video together
(Menu: File/MPEG Tools/ Multiplex [or SimpleMultiplex]).
Google: "TMPGENC 2.5" or find it below
http://www.tucows.com/preview/521029
There will be alternative solutions.
StainlessS
9th May 2012, 22:57
Oops, you also need to install ReadAvs,.dll. see here:
http://forum.doom9.org/showthread.php?t=55138
Need To Install READAVS.REG to use Avisynth & virtual dub frame serving.
Contents of READAVS.REG below:
REGEDIT4
; Replace the path below with the real path to the DLL.
; Be sure to type each backslash twice, as in the example.
[HKEY_CURRENT_USER\Software\VFPlugin]
"Avisynth"="C:\\NON-INSTALL\\TMPGEnc\\MyExtras\\ReadAVS.dll"
DrPhill
10th May 2012, 10:05
Thanks Stainless, but what is the underlying problem that would be solved by installing yet more software? What is defective about WavSource or AudioDub that is not defective in the software that you propose?
I suspect that there is a fault with my setup or with my audio file. In which case I could instal extra software and not see a change. Other people have used these two internal filters successfully I am sure....
@all I have reduced the script to this:
root = "C:\Users\Phill\VideoProject\FarleyFalls\"
video = BlankClip(length=300, width=640, height=480, pixel_type="RGB32", fps=24, fps_denominator=1, audio_rate=44100, stereo=False, sixteen_bit=True, color=$000000)
soundTrack = WAVSource(root+"attempt4.mod2.wav")
video = AudioDub(video, soundTrack)
return video.Info().ConvertToYUY2()
The audio now works when running the AVS file in WindozeMediaPlayer, but not when using WMP to run the m2v file produced from HCEnc..... so maybe I am doing something wrong in HCEnc? [Edited for clarity].
set here="C:\Users\Phill\VideoProject\FarleyFalls"
C:\Users\Phill\VideoProject\HC025\HCenc_025 -frames all -i %here%\testAudio.avs -o %here%\testAudio.m2v
DrPhill
10th May 2012, 10:59
In case it is my audio, I have posted a shortened version (11 seconds, 1Mb) here (http://phillvanleersum.users.sourceforge.net/Whistling/testAudio.wav).
If someone could test the above script through HCEnc on their machine for me, using the WAV file I would be very grateful. If it fails then its HCEnc, if it works then it is something about my setup.
Thanks in advance to anyone kind enough.....
Gavino
10th May 2012, 12:19
The audio now works when running the AVS file in WindozeMediaPlayer, but not when using WMP to run the m2v file produced from HCEnc..... so maybe I am doing something wrong in HCEnc?
As already stated, HCEnc does not process audio at all - it completely ignores it.
You need some other software for that.
Groucho2004
10th May 2012, 12:48
@DrPhill
A few questions that might get us somewhere:
1. What container are you planning to use for your streams?
2. What devices are your videos to be played on?
3. Why are you using PCM audio? It's a waste of space.
4. Why did you pick MPEG-2 and not H.264 which is much more efficient?
DrPhill
10th May 2012, 13:42
As already stated, HCEnc does not process audio at all - it completely ignores it.
You need some other software for that.
Aaaaah, excellent. My assumptions were wrong.
Thanks
DrPhill
10th May 2012, 14:01
@DrPhill
A few questions that might get us somewhere:
1. What container are you planning to use for your streams?
This is where my ignorance really starts to show. All I want is to create videos in some reasonably common format (with audio too). I have no preferences, other than it should be readily accessible to people on all platforms and OS's. I am so ignorant of the concept of 'container' as you have used it that I am nos sure that I have answered your question. If not, then my apologies.
2. What devices are your videos to be played on?
I guess as many as possible, but if that is a compromise with complexity for me, I will say mainly desktop computers.
3. Why are you using PCM audio? It's a waste of space.
Ignorance. The only reason I use WAV files is that Audacity produces them as the most faithful format. I used a WAV file in the script, because I always start with the internal filters and the only one for importing audio expects a WAV file. When I am happy with the audio I export it as mp3.
4. Why did you pick MPEG-2 and not H.264 which is much more efficient? Ignorance again. I really do not understand all these different formats and technologies. I seem to spend a lot of time downloading and installing stuff, some of it works, some of it does not. I just follow the line of least resistance...... for example, HCEnc was recommended to me here at one time, so I downloaded it and used it, oblivious, until now, that it ignores audio.
If H.264 is better, then what tool do I use?
My apologies for my ignorance - it must make it frustrating to try to answer my questions. I appreciate the time and effort being taken though.
Groucho2004
10th May 2012, 14:56
OK, let's start with the target format - H.264 in MKV will play almost everywhere nowadays (except SD DVD players and "older" Blu ray players). H.264 is the video format and MKV is the container.
Starting with your script I would suggest you look into a GUI like Megui. It will do almost everything for you and you don't have to get too involved in the specifics of the whole process.
DrPhill
10th May 2012, 15:00
OK, let's start with the target format - H.264 in MKV will play almost everywhere nowadays (except SD DVD players and "older" Blu ray players). H.264 is the video format and MKV is the container.
Starting with your script I would suggest you look into a GUI like Megui. It will do almost everything for you and you don't have to get too involved in the specifics of the whole process.
OK, doing that. Thanks. And my favourite price too.....
DrPhill
10th May 2012, 15:41
Same result with MeGui.
I can produce an MP4 file, but it has no sound.
I have used two methods:
- video from avs file* and audio from mp3
- video from avs and audio from avs file (sole line "return directshowsource("AileinDuinn4.2.mp3",audio=true)") as suggested in the Wiki (http://mewiki.project357.com/wiki/MeGUI/FAQ#How_do_I_import_audio.3F)
I am beginning to think this is me jinxing things...... surely it cannot be this difficult
*Script is now only:#root = "C:\Users\Phill\VideoProject\FarleyFalls\"
video = BlankClip(length=300, width=640, height=480, pixel_type="RGB32", fps=24, fps_denominator=1, audio_rate=44100, stereo=False, sixteen_bit=True, color=$000000)
#soundTrack = WAVSource(root+"testAudio.wav")
#video = AudioDub(video, soundTrack)
return video.Info().ConvertToYV12()
Groucho2004
10th May 2012, 16:50
You should probably post in the GUI forum if you have trouble with Megui. I have never used a gui so I don't know what to tell you.
Anyway, something is really bolloxed if you can't even import a mp3 file into Megui...
DrPhill
10th May 2012, 17:08
You should probably post in the GUI forum if you have trouble with Megui. I have never used a gui so I don't know what to tell you.
Anyway, something is really bolloxed if you can't even import a mp3 file into Megui...
I guess so. I bet when I find out what is wrong it will be something very simple, but very subtle...... ah well [shrug/].
Thanks for the help.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.