Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write_videofile does not add audio #1032

Closed
cristidomsa opened this issue Nov 1, 2019 · 7 comments
Closed

write_videofile does not add audio #1032

cristidomsa opened this issue Nov 1, 2019 · 7 comments

Comments

@cristidomsa
Copy link

cristidomsa commented Nov 1, 2019

I encounter a problem on Amazon Linux.

I have a code which generates composite videos. On ubuntu 18.04 is working file, on Amazon Linux the audio is not embedded in the video. The temporary audio file contains the proper audio.
I've tried to specify the codecs or not, it's not working.

CODE:

write_videofile(self.v3_name,
                                            write_logfile=True,
                                            threads=8,
                                            preset='ultrafast',
                                            temp_audiofile='temp-audio.mp3',
                                            rewrite_audio=True,
                                            audio=True,
                                            remove_temp=False)

Here are the logs:
AUDIO:
ffmpeg version 4.2.1-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, s32le, from 'pipe:':
Duration: N/A, bitrate: 2822 kb/s
Stream #0:0: Audio: pcm_s32le, 44100 Hz, stereo, s32, 2822 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s32le (native) -> mp3 (libmp3lame))
Output #0, mp3, to 'temp-audio.mp3':
Metadata:
TSSE : Lavf58.29.100
Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s32p
Metadata:
encoder : Lavc58.54.100 libmp3lame
size= 1790kB time=00:01:54.54 bitrate= 128.0kbits/s speed= 37x
video:0kB audio:1790kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.013801%

VIDEO:
ffmpeg version 4.2.1-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, rawvideo, from 'pipe:':
Duration: N/A, start: 0.000000, bitrate: 870912 kb/s
Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1600x756, 870912 kb/s, 30 tbr, 30 tbn, 30 tbc
Input #1, mp3, from 'temp-audio.mp3':
Metadata:
encoder : Lavf58.29.100
Duration: 00:01:54.57, start: 0.025057, bitrate: 128 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.54
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
[libx264 @ 0x555556724e40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x555556724e40] profile Constrained Baseline, level 3.2, 4:2:0, 8-bit
[libx264 @ 0x555556724e40] 264 - core 157 r2969 d4099dd - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=8 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to './tmp/Client1-1572570980.295778/v3s/Rubin Guttman & Associates.mp4':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1600x756, q=-1--1, 30 fps, 15360 tbn, 30 tbc
Metadata:
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame= 3436 fps= 33 q=-1.0 Lsize= 28309kB time=00:01:54.50 bitrate=2025.4kbits/s speed=1.11x
video:28294kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.051786%
[libx264 @ 0x555556724e40] frame I:14 Avg QP:12.43 size:269914
[libx264 @ 0x555556724e40] frame P:3422 Avg QP:15.16 size: 7362
[libx264 @ 0x555556724e40] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x555556724e40] mb P I16..4: 1.1% 0.0% 0.0% P16..4: 8.0% 0.0% 0.0% 0.0% 0.0% skip:90.9%
[libx264 @ 0x555556724e40] coded y,uvDC,uvAC intra: 34.9% 41.2% 34.6% inter: 3.7% 3.9% 2.1%
[libx264 @ 0x555556724e40] i16 v,h,dc,p: 54% 38% 4% 3%
[libx264 @ 0x555556724e40] i8c dc,h,v,p: 43% 36% 18% 3%
[libx264 @ 0x555556724e40] kb/s:2023.69

  • Python Version: 3.6
  • Moviepy Version: 1.0.1
  • Platform Name: Amazon Linux
  • Platform Version:
@ghost
Copy link

ghost commented Nov 3, 2019

I faced this issue as well on a project I'm currently working on and it seems like many people are facing this issue as well. For some people, by changing the audio encoding that did the trick and fixed the issue (such as #820). However, changing the audio encoding didn't work for me, the only solution I found for this issue is one mentioned in #876 was to remove the -an from the ffmpeg_writer.py file in
\site-packages\moviepy-1.0.1-py3.7.egg\moviepy\video\io

After I removed the -an from there it all worked like a charm.

@thenewguy
Copy link

thenewguy commented Nov 18, 2019

Try specifying as audio='temp-audio.mp3' and removing the temp_audiofile option.

See my test here: https://github.com/Zulko/moviepy/pull/1037/files#diff-488857f543e242a02c35d5b0b73668eaR208

Please let me know if that fixes your problem. If not, please output the ffmpeg command line generated so I can write a test to cover your case

To get the command logged to your console (until it is merged) you can pip install https://github.com/thenewguy/moviepy/archive/log-ffmpeg-command.zip#egg=moviepy

@thenewguy
Copy link

@THConer if possible, please review my test cases. If they do not cover your case, please let me know the difference so I can update them.

@BabyCY
Copy link

BabyCY commented Nov 29, 2019

Try specifying as audio='temp-audio.mp3' and removing the temp_audiofile option.

See my test here: https://github.com/Zulko/moviepy/pull/1037/files#diff-488857f543e242a02c35d5b0b73668eaR208

Please let me know if that fixes your problem. If not, please output the ffmpeg command line generated so I can write a test to cover your case

To get the command logged to your console (until it is merged) you can pip install https://github.com/thenewguy/moviepy/archive/log-ffmpeg-command.zip#egg=moviepy

hello,the example is working,but how can i subclip the audio clip?

@UAEpro
Copy link

UAEpro commented Dec 26, 2019

I have no audio also. This is the command
Moviepy - Using FFMPEG command:
/home/XXX/anaconda3/envs/snap2/lib/python3.7/site-packages/imageio_ffmpeg/binaries/ffmpeg-linux64-v4.1 -y -loglevel error -f rawvideo -vcodec rawvideo -s 360x712 -pix_fmt rgb24 -r 30.00 -i - -an -vcodec libx264 -preset ultrafast -pix_fmt yuv420p y.72827.mp4

before it was writing the audio and then writing the video, now it's writing the video directly

------------------------------------------- edit ----------------------------------------
i Know this is strange the code was working fine before
the old code was (which suddnly it has no sound)

    with VideoFileClip(os.path.join(dir_name, file),audio=True).rotate(rotateVal) as i:
        clips.append(i)

the new edited code which has sound

    clips.append(VideoFileClip(os.path.join(dir_name, file),audio=True).rotate(rotateVal))

@tburrows13
Copy link
Collaborator

Should be fixed in #968. Feel free to reopen if not.

@zhanwenchen
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants