Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在某些android设备(版本4+;)中播放视频时出现问题,而在其他设备中则没有_Android_Video_Ffmpeg - Fatal编程技术网

在某些android设备(版本4+;)中播放视频时出现问题,而在其他设备中则没有

在某些android设备(版本4+;)中播放视频时出现问题,而在其他设备中则没有,android,video,ffmpeg,Android,Video,Ffmpeg,按照android开发者的视频设置,我使用ffmpeg对视频进行了如下编码: ffmpeg -i gravityTrailer.mp4 -y -f mp4 -vcodec libx264 -profile:v baseline -acodec aac -strict -2 -profile:a aac_low -b:v 500k -ar 44100 -b:a 128k -ac 2 -r 30 -s 480x360 output_hq.mp4 对应于android开发者表2中的sd h

按照android开发者的视频设置,我使用ffmpeg对视频进行了如下编码:

ffmpeg -i gravityTrailer.mp4 -y -f mp4 -vcodec libx264 -profile:v baseline -acodec aac    -strict -2  -profile:a aac_low -b:v 500k -ar 44100 -b:a 128k -ac 2 -r 30 -s 480x360  output_hq.mp4
对应于android开发者表2中的sd highquality(上面的链接)

然后我把这个视频放在一个服务器上,使用android.media.MediaPlayer类从这个URL像这样复制它

问题是视频是在android版本4+上播放的

您可以在以下位置查看视频: LG G2, 索尼xperia S

您无法在以下位置查看视频: 三星galaxy S4, BQ(西班牙语)aquaris 4.5

我不知道为什么

这是ffmpeg输出:

三条建议,它们都不能直接提供解决方案,但可能会引导您找到解决方案

  • 仅尝试视频,即删除音频以查看是否存在音频编解码器问题
  • 仅尝试音频,删除视频以确认是视频问题
  • 如果两次都不起作用,那么

  • 切换到最新的ffmpeg,可能您的mp4不由设备处理

  • 如果只播放音频或视频,则必须是那边的设置。你的aac是我现在的主要嫌疑犯。试试mp3,看看会发生什么。无论哪种方式,因为我没有流或设备,我只能说我会用这种方式进行试验,以找出问题所在。

    您应该显示由
    ffmpeg
    命令产生的完整
    ffmpeg
    控制台输出/日志。感谢您的回答,我们尝试了所有这些,并使用windows中的另一个程序转换视频。它也有同样的问题。我不知道该怎么办do@anquegi仅音频或仅视频有效吗?另外,您为ffmpeg运行的确切命令行是什么?你能在某个地方共享mp4文件以供检查吗?所有的视频或音频都是一样的,只在第一个手机上有效,在另外两个手机上无效:///////我也尝试了这两个://结果相同。最后我找到了一个理想的共享程序,结果视频在我的每个测试设备上都能正常工作。fmmpeg为视频提供了以下信息:h264(受限基线)(avc1/0x31637661)、yuv420p、640x480[SAR 1:1 DAR 4:3]、1406kb/s、23.98 fps、23.98 tbr、24k tbn、59.94 tbc | |音频:aac(mp4a/0x6134706D)、44100Hz、立体声、fltp、128kb/s如何使用ffmpeg将视频准确地转换为这些内容,这应该是指令?@anquegi,我不能肯定你的问题。您希望ffmpeg提供如上所述的输出吗?然后可以使用此处指定的参数。。你想要640x480?给-s 640x480。我认为问题在于原始命令中的ref=3。给出ref=1,并检查设备。这将为您提供受约束的基线
    ffmpeg version 1.2.6 Copyright (c) 2000-2014 the FFmpeg developers
      built on Mar  5 2014 08:21:01 with gcc 4.8.2 (GCC) 20131212 (Red Hat 4.8.2-7)
      configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-frei0r --enable-gnutls --enable-libass --enable-libcelt --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
      libavutil      52. 18.100 / 52. 18.100
      libavcodec     54. 92.100 / 54. 92.100
      libavformat    54. 63.104 / 54. 63.104
      libavdevice    54.  3.103 / 54.  3.103
      libavfilter     3. 42.103 /  3. 42.103
      libswscale      2.  2.100 /  2.  2.100
      libswresample   0. 17.102 /  0. 17.102
      libpostproc    52.  2.100 / 52.  2.100
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x14e5ba0] stream 0, timescale not set
    [mov,mp4,m4a,3gp,3g2,mj2 @ 0x14e5ba0] max_analyze_duration 5000000 reached at 5013333 microseconds
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'gravityTrailer.mp4':
      Metadata:
        major_brand     : mp42
        minor_version   : 0
        compatible_brands: mp42isomavc1
        creation_time   : 2013-12-01 03:59:56
        genre           : Trailer
        artist          : Warner Bros.
        title           : Gravity - 2K Trailer
        encoder         : HandBrake 0.9.9 2013051800
        date            : 2013
      Duration: 00:02:27.07, start: 0.000000, bitrate: 20296 kb/s
        Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 2048x858, 20149 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
        Metadata:
          creation_time   : 2013-12-01 03:59:56
        Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 153 kb/s
        Metadata:
          creation_time   : 2013-12-01 03:59:56
        Stream #0:2: Video: mjpeg, yuvj420p, 102x150 [SAR 72:72 DAR 17:25], 90k tbr, 90k tbn, 90k tbc
    [libx264 @ 0x1667680] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    [libx264 @ 0x1667680] profile Constrained Baseline, level 3.0
    [libx264 @ 0x1667680] 264 - core 130 r2282 1db4621 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 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=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to 'output_hq.mp4':
      Metadata:
        major_brand     : mp42
        minor_version   : 0
        compatible_brands: mp42isomavc1
        date            : 2013
        genre           : Trailer
        artist          : Warner Bros.
        title           : Gravity - 2K Trailer
        encoder         : Lavf54.63.104
        Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 480x360, q=-1--1, 500 kb/s, 15360 tbn, 30 tbc
        Metadata:
          creation_time   : 2013-12-01 03:59:56
        Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s
        Metadata:
          creation_time   : 2013-12-01 03:59:56
    Stream mapping:
      Stream #0:0 -> #0:0 (h264 -> libx264)
      Stream #0:1 -> #0:1 (aac -> aac)
    Press [q] to stop, [?] for help
    frame= 4410 fps= 65 q=-1.0 Lsize=   11154kB time=00:02:27.07 bitrate= 621.3kbits/s dup=885 drop=0    
    video:9062kB audio:1969kB subtitle:0 global headers:0kB muxing overhead 1.115392%
    [libx264 @ 0x1667680] frame I:186   Avg QP:28.41  size:  4446
    [libx264 @ 0x1667680] frame P:4224  Avg QP:29.20  size:  2001
    [libx264 @ 0x1667680] mb I  I16..4: 75.5%  0.0% 24.5%
    [libx264 @ 0x1667680] mb P  I16..4:  7.5%  0.0%  3.6%  P16..4: 23.1%  6.2%  1.8%  0.0%  0.0%    skip:57.7%
    [libx264 @ 0x1667680] final ratefactor: 27.96
    [libx264 @ 0x1667680] coded y,uvDC,uvAC intra: 24.0% 31.9% 8.6% inter: 7.4% 7.6% 0.6%
    [libx264 @ 0x1667680] i16 v,h,dc,p: 58% 15% 13% 14%
    [libx264 @ 0x1667680] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28%  9% 27%  7%  6%  8%  5%  7%  3%
    [libx264 @ 0x1667680] i8c dc,h,v,p: 80%  7% 12%  2%
    [libx264 @ 0x1667680] ref P L0: 84.7%  9.4%  5.9%
    [libx264 @ 0x1667680] kb/s:504.98