使用来自互联网或http的ffmpeg转码视频

时间:2015-07-19 12:11:46

标签: django ffmpeg

我有一个转码视频的项目。现在我将视频的绝对路径作为输入变量传递,如下:

inputfile = str(MEDIA_ROOT)+'/'+str(video.original_video)

  

这里MEDIA_ROOT是/ home / user / code / Project / Viu / static / media

然后

subprocess.call(
        'ffmpeg -i '+ inputfile +' -codec:v libx264 -crf 23 -preset faster -codec:a libfdk_aac -vbr 4 \-movflags faststart -vf scale="720:trunc(ow/a/2)*2",format=yuv420p '+ outputfile,
        shell=True
    )

现在可以了。但我会将这些视频保存在服务器的不同位置,如何通过互联网或http转换该位置的视频?

我试过了:

inputfile = 'http://localhost:8000/media/'+str(video.original_video)

但是我得到了错误

[2015-07-19 13:27:14,933: INFO/MainProcess] Received task: vids.tasks.convert_video[41e36bc6-0d6a-4756-99fb-cb8005a4fbe3]
[2015-07-19 13:27:14,944: INFO/Worker-2] running
ffmpeg version N-73632-g39a04eb Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libdcadec --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvo-aacenc --enable-libvidstab
  libavutil      54. 28.100 / 54. 28.100
  libavcodec     56. 47.100 / 56. 47.100
  libavformat    56. 40.100 / 56. 40.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 21.100 /  5. 21.100
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
[h264 @ 0x9d46060] AVC: nal size 371788
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -530775991
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size 1666002647
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -1986130888
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -710433401
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -723464079
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size 378679291
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size 1766542096
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -470898291
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -402699497
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size 64441658
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size 1892506351
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size 1362707160
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -1845744002
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -327264949
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -14647022
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size 332446592
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -673972274
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size 2091272674
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -1219100086
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -1117890504
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -1221891828
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size 1674360084
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size 1114909540
[h264 @ 0x9d46060] no frame!
[h264 @ 0x9d46060] AVC: nal size -1619615275
[h264 @ 0x9d46060] no frame!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x9d43be0] decoding for stream 0 failed
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x9d43be0] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none(bt470bg/bt709/bt709), 1920x1080, 43842 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://localhost:8000/media/uploaded_files/1437312433_3_test1.MOV':
  Metadata:
    major_brand     : qt  
    minor_version   : 537331968
    compatible_brands: qt  CAEP
    creation_time   : 2014-07-25 22:11:02
  Duration: 00:00:48.68, start: 0.000000, bitrate: 8611 kb/s
    Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), none(bt470bg/bt709/bt709), 1920x1080, 43842 kb/s, 25 fps, 25 tbr, 25k tbn, 50k tbc (default)
    Metadata:
      creation_time   : 2014-07-25 22:11:02
    Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2014-07-25 22:11:02
[buffer @ 0x9d47c40] Unable to parse option value "-1" as pixel format
    Last message repeated 1 times
[buffer @ 0x9d47c40] Error setting option pix_fmt to value -1.
[graph 0 input from stream 0:0 @ 0x9de4d00] Error applying options to the filter.
Error opening filters!

我将非常感谢您的帮助和指导。谢谢。

0 个答案:

没有答案